Skip to content

Commit

Permalink
Add comment and update changelog for #1664 (#1668)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored May 30, 2022
1 parent 22bbcde commit e85afb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* Added Stopwatch class to replace Timer: [#1638](https://github.com/dartsim/dart/pull/1638)
* Removed Boost dependency: [#1648](https://github.com/dartsim/dart/pull/1648), [#1651](https://github.com/dartsim/dart/pull/1651)

* Collision Detection

* Updated to use convex mesh of Bullet when possible: [#1664](https://github.com/dartsim/dart/pull/1664), [#1667](https://github.com/dartsim/dart/pull/1667)

* Dynamics

* Added deep copy for shapes: [#1612](https://github.com/dartsim/dart/pull/1612)
Expand Down
18 changes: 11 additions & 7 deletions dart/collision/bullet/BulletCollisionDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,20 +1066,24 @@ std::unique_ptr<BulletCollisionShape> createBulletCollisionShapeFromHeightmap(
//==============================================================================
bool isConvex(const aiMesh* mesh, float threshold)
{
// Check whether all the other vertices on the mesh is on the internal side of
// the face, assuming that the direction of the normal of the face is pointing
// external side.
//
// Reference: https://stackoverflow.com/a/40056279/3122234

const auto points = mesh->mVertices;
btVector3 vertices[3];
for (auto i = 0u; i < mesh->mNumFaces; ++i)
{
btVector3 vertices[3];
for (auto j = 0u; j < 3; ++j)
{
const aiVector3D& vertex = mesh->mVertices[mesh->mFaces[i].mIndices[j]];
vertices[j] = btVector3(vertex.x, vertex.y, vertex.z);
}
btVector3 A = vertices[0];
btVector3 B = vertices[1];
btVector3 C = vertices[2];
B -= A;
C -= A;
const btVector3& A = vertices[0];
const btVector3 B = vertices[1] - A;
const btVector3 C = vertices[2] - A;

const btVector3 BCNorm = B.cross(C).normalized();

Expand All @@ -1088,7 +1092,7 @@ bool isConvex(const aiMesh* mesh, float threshold)
points[0].x - A.x(), points[0].y - A.y(), points[0].z - A.z())
.dot(BCNorm);

for (unsigned long j = 0; j < mesh->mNumVertices; j++)
for (auto j = 0u; j < mesh->mNumVertices; ++j)
{
float dist
= btVector3(
Expand Down

0 comments on commit e85afb9

Please sign in to comment.