C4 Engine
C4 Engine API Documentation


Defined in:  C4Physics.h
Called when a new contact is made with a geometry node.

virtual RigidBodyStatus HandleNewGeometryContact(const GeometryContact *contact);

contact The new contact.
The HandleNewGeometryContact function is called by the Physics Manager when a rigid body makes a new contact with a geometry node. This function can be overridden in a subclass of RigidBodyController in order to carry out a specialized response to a collision.

The contact parameter specifies the newly created GeometryContact object, which is an edge in the contact graph maintained by the Physics Manager. The rigid body for which the HandleNewGeometryContact function is called is always the start element of this edge, and a special null body is the finish element.

The HandleNewGeometryContact function should return one of the following constants.
kRigidBodyUnchanged No change was made to the rigid body or its contacts.
kRigidBodyContactsBroken One or more contacts with the rigid body were broken or may have been broken.
kRigidBodyDestroyed The rigid body was destroyed.
An implementation of the HandleNewGeometryContact function is allowed to destroy the contact specified by the contact parameter using the delete operator. In this case, the function must return kRigidBodyContactsBroken.

If the implementation of the HandleNewGeometryContact function destroys the geometry node referenced by the contact (retrieved with the GeometryContact::GetContactGeometry function), then the PhysicsController::PurgeGeometryContacts should be called for the same geometry node, and the HandleNewGeometryContact function should return kRigidBodyContactsBroken. This is demonstrated by the following code:
Geometry *geometry = contact->GetContactGeometry();
delete geometry;
return (kRigidBodyContactsBroken);
The default implementation of the HandleNewGeometryContact function calls the World::HandleNewGeometryContact function.
See Also