Distances and Collision Detection
Distances between different objects can be calculated with the help of
IMetrics
interface. IsCloserThan of the
same interface is helpful for collision detection during simulation or animation
of movements or geometry modifications of an object.
Collision sample demonstrates a
simple case of such application.
The main issue with programming collision detection is that during the
movement simulation the above methods have to be called frequently numerous
times and because they apply heavy computational load the process may be slow.
Below are few hints to alleviate the problem.
- Avoid using includeChildren flag from
the contexts structure during the calls to IMetrics.Dist
or IsCloserThan methods. and
needAllflag during calls to IsCloserThan
- Choose carefully other parameters from the context structures
- Complexity of surface of both objects affect significantly the
performance so it is recommended to create surrogate invisible copies of the
objects with fewer level of details and detect collision between them
instead. It is best to make the surrogate a child of the actual object so
they will be moved synchronously.
- Often it is know in advance which part of the object can collide with
other objects. So the surrogate can be made to represent this part of the
object. Clip planes is one good method to
extract such part of the object.
- Further optimization of the process can be done when path of the
movement is known beforehand and the problem is to find the moment when and
if the collision occurs. Contact us if you
need assistance with this technique.
See Also: Collision Sample
Path Collision Detection
Path Collision Detection
is another, higher level technology in DG Kernel for collision detection.
Path Collision Detection
assumes that movement of objects is known in advance. This allows further
optimization of performance inside DG Kernel component. It is assumed that the
objects do not initially interfere with each other. The result may be
incorrect if it is not true. Number of objects which participate on collision
detection is not limitedThe functionality is
provided by DG Kernel Collision Detector. Collision Detector takes a set of
sections (objects) along with paths of their movement. Result of the Collision
Detection operation is the time moment when the first collision has occurred.
To perform
Path Collision Detection:
- Create movement one per each object involved in collision detection with
IDIObjGenerator.Create(EObjectType.eObjTypeMove).
- Query IMove_KC
from the return of the above call and modify the movement as described in
Movements topic
- Create an instance of Collision Detector with a call to
IDIObjGenerator.Create
with eType parameter set to eObjTypePathCollisionDetector member of the EObjectType
enumeration.
- Query
IKCPathCollisionDetector interface from the return of
IDIObjGenerator.Create
- Query
IKinematicSet_KC from the IKCPathCollisionDetector
- Use
IKinematicSet_KC.AddObject to add objects
along with their movements for detection
- Call
IKCPathCollisionDetector.Detect to obtain the
moments when collision happened
- Optional: Call
IKinematicSet_KC.SetPosition
to display position of objects when the collision occurred
- Optional: Call IMetrics.Dist
to obtain extended information about nearest points at collision
configuration
Note that Path Collision Detection is extremely computation intensive this
means that only necessary object should be added for detection and various
settings like precision in
IKCPathCollisionDetector.Detect
call, geometric resolution of the objects and sampling of the movement paths
should be set to lowest acceptable values, which can be tuned in after a number
of tests.
See Also: Collision Path
Sample
|