I have a qeustion regarding the book's content, namely resting contacts. I suppose only people who have read the book might be able to answer my question but if you would like to help me but has not read it I can provide any problem's details if necessary.
I created a very simple sample using your framework. There is a particle
resting on position (0.0, -0.1, 0.0). Collision happens when Y
coordinate is below -0.1 so this contact is indeed resting. I also add
(0.0, -1.0, 0.0) force each frame. Since the contact is resting I
thought the particle would stand on the ground but it appears to be
bouncing. Why is that so?
Here is the Particle Contact Generator:
class CG : public cyclone::ParticleContactGenerator
{
public:
cyclone::Particle *particle;
virtual unsigned addContact(
cyclone::ParticleContact *contact,
unsigned limit
) const
{
if (particle->getPosition().y <= -0.1f)
{
contact->contactNormal = cyclone::Vector3(0.0f, 1.0f, 0.0f);
contact->restitution = 1.0f;
contact->particle[0] = particle;
contact->particle[1] = nullptr;
contact->penetration = -0.1 - particle->getPosition().y;
return 1;
}
return 0;
}
};
myPart particle creation:
cg.particle = &myPart;
world.getContactGenerators().push_back(&cg);
myPart.setPosition(0.1f, -0.1f, 0.0f);
myPart.setVelocity(0.0f, 0.0f, 0.0f);
myPart.setDamping(1.0f);
myPart.setAcceleration(0.0f, 0.0f, 0.0f);
myPart.setMass(1.0f);
myPart.clearAccumulator();
world.getParticles().push_back(&myPart);
and force that I apply in the update function:
myPart.addForce(cyclone::Vector3(0.0f, -1.0f, 0.0f));
Is that correct that particle myPart should be resting instead of
bouncing off the -0.1 ground?