![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Vision/MeshGroupCollisionDetection.h>
Test for collision between two groups of meshes. More...
Test for collision between two groups of meshes.
This class allows to define groups of Mesh objects, and to check if any Mesh from a group collides with any from another group. It is also possible to specify a minimum safety distance that must be kept between the two models to avoid a collision.
When the meshes are passed to the algorithm, their format is converted (this is an expensive operation). Subsequent calls to the algorithm make use of this optimized format.
For optimal performance, it is advised to specify a new position for each mesh if the respective object has moved, without resetting the mesh itself.
It is also possible to check for collision between a single mesh and a whole group, or between a single mesh and another mesh. Each particular case is optimized. To avoid false positives, the mesh should not belong to the other group, or to the group of the other mesh.
Public Types | |
| using | GroupID = int |
| using | MeshID = int |
| using | ConstMeshRef = std::reference_wrapper<const Mesh> |
Public Member Functions | |
| MeshGroupCollisionDetection (const std::vector< std::vector< ConstMeshRef > > &meshGroups) | |
| Set the mesh objects (the pose will be extracted from the object's matrix). | |
| MeshID | addMeshToGroup (const Mesh &m, GroupID groupID) |
| Add a Mesh to the group identified by the ID (if the group doesn't exist yet, it will be created). | |
| bool | removeMeshFromGroup (MeshID id, GroupID groupID) |
| Remove a Mesh given its ID from a group identified by the groupID (if the group or mesh doesn't exist, it will do nothing). | |
| bool | isMeshInGroup (MeshID id, GroupID groupID) const |
| Checks if the provided mesh id is assigned to the group identified by the groupID. | |
| void | newMeshPose (MeshID meshID, const mat4 &newPose) |
| Update the pose of the object with the specified ID. | |
| bool | doMeshGroupsCollide (GroupID group1ID, GroupID group2ID) const |
| Check for compenetration between the two mesh groups. | |
| bool | doMeshAndGroupCollide (MeshID meshID, GroupID groupID) const |
| Check for compenetration between the a mesh and a whole group. | |
| bool | doMeshesCollide (MeshID mesh1ID, MeshID mesh2ID) const |
| Check for compenetration between two single meshes. | |
| bool | doMeshesCollide (MeshID mesh1ID, MeshID mesh2ID, float safetyDistance) const |
| Check if the minimum distance between two meshes is above a given value. | |
| bool | doMeshGroupsCollide (GroupID group1ID, GroupID group2ID, float safetyDistance) const |
| Check if the minimum distance between each mesh of two mesh groups is above a given value. | |
| float | meshMinDistance (GroupID group1ID, GroupID group2ID) const |
| MeshID ImFusion::MeshGroupCollisionDetection::addMeshToGroup | ( | const Mesh & | m, |
| GroupID | groupID ) |
| bool ImFusion::MeshGroupCollisionDetection::removeMeshFromGroup | ( | MeshID | id, |
| GroupID | groupID ) |
Remove a Mesh given its ID from a group identified by the groupID (if the group or mesh doesn't exist, it will do nothing).
| bool ImFusion::MeshGroupCollisionDetection::isMeshInGroup | ( | MeshID | id, |
| GroupID | groupID ) const |
Checks if the provided mesh id is assigned to the group identified by the groupID.
| bool ImFusion::MeshGroupCollisionDetection::doMeshGroupsCollide | ( | GroupID | group1ID, |
| GroupID | group2ID ) const |
Check for compenetration between the two mesh groups.
| bool ImFusion::MeshGroupCollisionDetection::doMeshAndGroupCollide | ( | MeshID | meshID, |
| GroupID | groupID ) const |
Check for compenetration between the a mesh and a whole group.
| bool ImFusion::MeshGroupCollisionDetection::doMeshesCollide | ( | MeshID | mesh1ID, |
| MeshID | mesh2ID ) const |
Check for compenetration between two single meshes.
| bool ImFusion::MeshGroupCollisionDetection::doMeshesCollide | ( | MeshID | mesh1ID, |
| MeshID | mesh2ID, | ||
| float | safetyDistance ) const |
Check if the minimum distance between two meshes is above a given value.
| safetyDistance | Minimum distance between two points belonging to each mesh |
| bool ImFusion::MeshGroupCollisionDetection::doMeshGroupsCollide | ( | GroupID | group1ID, |
| GroupID | group2ID, | ||
| float | safetyDistance ) const |
Check if the minimum distance between each mesh of two mesh groups is above a given value.
| safetyDistance | Minimum distance between two points belonging to each mesh |