Skip to content

Commit

Permalink
reordering collision results between shapes and meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Tonneau committed Aug 20, 2015
1 parent fdd6d8d commit 177fb1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/hpp/fcl/collision_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ struct CollisionResult
contacts.clear();
cost_sources.clear();
}

/// @brief reposition Contact objects when fcl inverts them
/// during their construction.
friend void invertResults(CollisionResult& result);
};


Expand Down
20 changes: 20 additions & 0 deletions src/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ std::size_t collide(const CollisionObject* o1, const CollisionObject* o2,
nsolver, request, result);
}

// reorder collision results in the order the call has been made.
void invertResults(CollisionResult& result)
{
const CollisionGeometry* otmp;
int btmp;
for(std::vector<Contact>::iterator it = result.contacts.begin();
it != result.contacts.end(); ++it)
{
otmp = it->o1;
it->o1 = it->o2;
it->o2 = otmp;
btmp = it->b1;
it->b1 = it->b2;
it->b2 = btmp;
}
}

template<typename NarrowPhaseSolver>
std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
const CollisionGeometry* o2, const Transform3f& tf2,
Expand Down Expand Up @@ -96,7 +113,10 @@ std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
res = 0;
}
else
{
res = looktable.collision_matrix[node_type2][node_type1](o2, tf2, o1, tf1, nsolver, request, result);
invertResults(result);
}
}
else
{
Expand Down

0 comments on commit 177fb1f

Please sign in to comment.