Game Development Reference
In-Depth Information
* class can only generate a single contact, so the
* pointer can be a pointer to a single element. The limit
* parameter is assumed to be at least one (zero isn't valid),
* and the return value is either 0, if the cable wasn't
* overextended, or one if a contact was needed.
*/
virtual unsigned fillContact(ParticleContact *contact,
unsigned limit) const = 0;
};
/**
* Cables link a pair of particles, generating a contact if they
* stray too far apart.
*/
class ParticleCable : public ParticleLink
{
public:
/**
* Holds the maximum length of the cable.
*/
real maxLength;
/**
* Holds the restitution (bounciness) of the cable.
*/
real restitution;
public:
/**
* Fills the given contact structure with the contact needed
* to keep the cable from overextending.
*/
virtual unsigned fillContact(ParticleContact *contact,
unsigned limit) const;
};
Excerpt from src/plinks.cpp
real ParticleLink::currentLength() const
{
Vector3 relativePos = particle[0]->getPosition() -
particle[1]->getPosition();
return relativePos.magnitude();
}
Search Nedrilad ::




Custom Search