RigidBodyController::HandleNewGeometryContact
Defined in:
Called when a new contact is made with a geometry node.
C4Physics.h
Prototype
virtual RigidBodyStatus HandleNewGeometryContact(const GeometryContact *contact);
Parameters
contact |
The new contact. |
Description
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. |
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();
GetPhysicsController()->PurgeGeometryContacts(geometry);
delete geometry;
...
return (kRigidBodyContactsBroken);
The default implementation of the GetPhysicsController()->PurgeGeometryContacts(geometry);
delete geometry;
...
return (kRigidBodyContactsBroken);
HandleNewGeometryContact
function calls the World::HandleNewGeometryContact
function.
See Also
RigidBodyController::HandleNewRigidBodyContact
World::HandleNewGeometryContact
RigidBodyController::PurgeContacts