Game Development Reference
In-Depth Information
/**
* Holds the maximum displacement at the joint before the
* joint is considered to be violated. This is normally a
* small, epsilon value. It can be larger, however, in which
* case the joint will behave as if an inelastic cable joined
* the bodies at their joint locations.
*/
real error;
/**
* Generates the contacts required to restore the joint if it
* has been violated.
*/
unsigned addContact(Contact *contact, unsigned limit) const;
};
Within this class there is a checkJoint method that generates contacts based on the
current configuration of the joint. In this way it acts very much like a collision detec-
tor: looking at the state of rigid bodies and generating contacts accordingly.
In the demo the joints are considered in order during the physics update:
Excerpt from src/demos/ragdoll/ragdoll.cpp
void RagdollDemo::generateContacts()
{
// Create the ground plane data.
cyclone::CollisionPlane plane;
plane.direction = cyclone::Vector3(0,1,0);
plane.offset = 0;
// Perform exhaustive collision detection on the ground plane.
cyclone::Matrix4 transform, otherTransform;
cyclone::Vector3 position, otherPosition;
for (Bone *bone = bones; bone < bones+NUM_BONES; bone++)
{
// Check for collisions with the ground plane.
if (!cData.hasMoreContacts()) return;
cyclone::CollisionDetector::boxAndHalfSpace(*bone, plane, &cData);
}
// Check for joint violation.
for (cyclone::Joint *joint = joints;
joint < joints+NUM_JOINTS; joint++)
{
if (!cData.hasMoreContacts()) return;
Search Nedrilad ::




Custom Search