ImFusion SDK 4.3
MeshGroupCollisionDetection Class Reference

#include <ImFusion/Vision/MeshGroupCollisionDetection.h>

Test for collision between two groups of meshes. More...

Detailed Description

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.

Note
Performance: using a minimum distance makes early exits on the first colliding triangle impossible and might significantly increase processing times. If feasible, consider using actually enlarged geometry to repeatedly perform these checks.

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
 

Member Function Documentation

◆ addMeshToGroup()

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)

Returns
The ID of the Mesh, to be used to update its pose

◆ removeMeshFromGroup()

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)

Returns
true if successfull, else false

◆ isMeshInGroup()

bool isMeshInGroup ( MeshID id,
GroupID groupID ) const

Checks if the provided mesh id is assigned to the group identified by the groupID.

Returns
true if the mesh is part of the given group, else false

◆ doMeshGroupsCollide() [1/2]

bool doMeshGroupsCollide ( GroupID group1ID,
GroupID group2ID ) const

Check for compenetration between the two mesh groups.

Returns
true if the meshes collide, else false

◆ doMeshAndGroupCollide()

bool doMeshAndGroupCollide ( MeshID meshID,
GroupID groupID ) const

Check for compenetration between the a mesh and a whole group.

Returns
true if the meshes collide

◆ doMeshesCollide() [1/2]

bool doMeshesCollide ( MeshID mesh1ID,
MeshID mesh2ID ) const

Check for compenetration between two single meshes.

Returns
true if the meshes collide, else false

◆ doMeshesCollide() [2/2]

bool doMeshesCollide ( MeshID mesh1ID,
MeshID mesh2ID,
float safetyDistance ) const

Check if the minimum distance between two meshes is above a given value.

Warning
See performance warning in class documentation
Parameters
safetyDistanceMinimum distance between two points belonging to each mesh
Returns
true if the objects are within the safety distance, else false

◆ doMeshGroupsCollide() [2/2]

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.

Warning
See performance warning in class documentation
Parameters
safetyDistanceMinimum distance between two points belonging to each mesh
Returns
true if the objects are within the safety distance, else false

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close