DG Kernel (ActiveX) Documentation


Skip Navigation Links.
Skip Navigation LinksHome Page > Models > Entities > Movement > Collision Detection Go to DGKC docs Search Documentation


Distances and Collision Detection

Distances between different objects can be calculated with the help of IMetrics_DG 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_DG.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.
  • 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 limited

The functionality is provided by DG Kernel Collision Detector. Collision Detector takes a set of entities (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:

  1. Create movement one per each object involved in collision detection with IMove_DG iMove = IObjectGenerator_DG.Create("IMove_DG").
  2. Modify the movement as described in Movements topic
  3. Create an instance of Collision Detector with a call IPathCollisionDetector_DG iDetector = IObjectGenerator_DG.Create("IPathCollisionDetector_DG"); 
  4. Query IKinematicSet_DG from iDetector.
  5. Use IKinematicSet_DG.AddObject to add objects along with their movements for detection
  6. Call IPathCollisionDetector_DG.Detect to obtain the moments when collision happened
  7. Optional: Call IKinematicSet_DG.SetPosition to display position of objects when the collision occurred
  8. Optional: Call IMetrics_DG.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 IPathCollisionDetector_DG.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