Game Development Reference
In-Depth Information
ParticleWorld(unsigned maxContacts, unsigned iterations=0);
};
At each frame the startFrame method is first called, which sets up each object
ready for the force accumulation:
Excerpt from include/cyclone/pworld.h
/**
* Keeps track of a set of particles, and provides the means to
* update them all.
*/
class ParticleWorld
{
/**
* Initializes the world for a simulation frame. This clears
* the force accumulators for particles in the world. After
* calling this, the particles can have their forces for this
* frame added.
*/
void startFrame();
};
Excerpt from src/pworld.cpp
void ParticleWorld::startFrame()
{
ParticleRegistration *reg = firstParticle;
while (reg)
{
// Remove all forces from the accumulator.
reg->particle->clearAccumulator();
// Get the next registration.
reg = reg->next;
}
}
Additional forces can be applied after calling this method.
We will also create another system to register contacts. Just as we saw for force
generators, we create a polymorphic interface for contact detectors.
Excerpt from include/cyclone/pcontacts.h
/**
* This is the basic polymorphic interface for contact generators
* applying to particles.
Search Nedrilad ::




Custom Search