From Newton Wiki
Jump to: navigation, search


NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* newtonWorld, int count, NewtonCollision* const collisionPrimitiveArray[], int shapeID);


Creates a single collision object from multiple collision objects to represent a more complex shape. For example, several elongated box shapes can be put together to form a scaffold-like structure. Or, 3 spheres can make a snowman shape. Convex hulls may also be used in compound collisions to generate a huge variety of concave shapes.


  • const NewtonWorld *newtonWorld - is the pointer to the Newton world.
  • int shapeID - ID to associate with the collision shape.


  • Pointer to the compound object


Compound shape.jpg Warbird.jpg

Creates a Compound mesh primitive for collision from a set of various objects. This is very useful, when you need to build complex non-static concave shapes, for instance a complex detailed car shape or a spaceship.

You can look at compound collision object the same way you look at other rigid bodies.

To make a rigid body you do:

  1. create collision
  2. create body, passing the collision
  3. release collision

For objects with compound collision, same process

  1. create all sub collision primitives and place then into an array
  2. create compound collision, passing the array of collision primitives
  3. create rigid body, passing the compound collision
  4. release the compound collision
  5. release all sub-collision primitives

As you can see, it is the same creation wrapped in the sub collision primitive create-release extatement. You can not add collision tres, terrains, or user collision since this can only be static.


Compound collison can only be built using the closed (convex) shape collision primitives such as boxes, capsules, cylinders, convex hulls, etc.
That means, you can not create a compound collision that uses collision trees, terrains, or user collision as parts since these primitives can only be static.
You can also not use other compound collisions as parts. But you can include their pieces. 
You can use NewtonCollisionGetInfo to find out of which type a collision primitive is.


See also

NewtonCompoundCollisionBeginAddRemove, NewtonCompoundCollisionAddSubCollision, NewtonCompoundCollisionEndAddRemove, NewtonCompoundCollisionRemoveSubCollision