Space::~Space() { UpdateBodies(); // make sure anything waiting to be removed gets removed before we go and kill everything else for (std::list<Body*>::iterator i = m_bodies.begin(); i != m_bodies.end(); ++i) KillBody(*i); UpdateBodies(); }
void cWorld3D::Update(float afTimeStep) { START_TIMING(Physics); if(mpPhysicsWorld) mpPhysicsWorld->Update(afTimeStep); STOP_TIMING(Physics); START_TIMING(Entities); UpdateEntities(afTimeStep); STOP_TIMING(Entities); START_TIMING(Bodies); UpdateBodies(afTimeStep); STOP_TIMING(Bodies); START_TIMING(Particles); UpdateParticles(afTimeStep); STOP_TIMING(Particles); START_TIMING(Lights); UpdateLights(afTimeStep); STOP_TIMING(Lights); START_TIMING(SoundEntities); UpdateSoundEntities(afTimeStep); STOP_TIMING(SoundEntities); }
void Space::TimeStep(float step) { m_frameIndexValid = m_bodyIndexValid = m_sbodyIndexValid = false; // XXX does not need to be done this often CollideFrame(m_rootFrame.Get()); // update frames of reference for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->UpdateFrame(); // AI acts here, then move all bodies and frames for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->StaticUpdate(step); m_rootFrame->UpdateOrbitRails(m_game->GetTime(), m_game->GetTimeStep()); for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->TimeStepUpdate(step); // XXX don't emit events in hyperspace. this is mostly to maintain the // status quo. in particular without this onEnterSystem will fire in the // frame immediately before the player leaves hyperspace and the system is // invalid when Lua goes and queries for it. we need to consider whether // there's anything useful that can be done with events in hyperspace if (m_starSystem) { LuaEvent::Emit(); Pi::luaTimer->Tick(); } UpdateBodies(); }
void Space::TimeStep(float step) { m_frameIndexValid = m_bodyIndexValid = m_sbodyIndexValid = false; // XXX does not need to be done this often CollideFrame(m_rootFrame.Get()); // update frames of reference for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->UpdateFrame(); // AI acts here, then move all bodies and frames for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->StaticUpdate(step); m_rootFrame->UpdateOrbitRails(m_game->GetTime(), m_game->GetTimeStep()); for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) (*i)->TimeStepUpdate(step); // XXX don't emit events in hyperspace. this is mostly to maintain the // status quo. in particular without this onEnterSystem will fire in the // frame immediately before the player leaves hyperspace and the system is // invalid when Lua goes and queries for it. we need to consider whether // there's anything useful that can be done with events in hyperspace if (m_starSystem) { Pi::luaOnEnterSystem->Emit(); Pi::luaOnLeaveSystem->Emit(); Pi::luaOnFrameChanged->Emit(); Pi::luaOnShipHit->Emit(); Pi::luaOnShipCollided->Emit(); Pi::luaOnShipDestroyed->Emit(); Pi::luaOnShipDocked->Emit(); Pi::luaOnShipAlertChanged->Emit(); Pi::luaOnShipUndocked->Emit(); Pi::luaOnShipLanded->Emit(); Pi::luaOnShipTakeOff->Emit(); Pi::luaOnJettison->Emit(); Pi::luaOnCargoUnload->Emit(); Pi::luaOnAICompleted->Emit(); Pi::luaOnCreateBB->Emit(); Pi::luaOnUpdateBB->Emit(); Pi::luaOnShipFlavourChanged->Emit(); Pi::luaOnShipEquipmentChanged->Emit(); Pi::luaOnShipFuelChanged->Emit(); Pi::luaTimer->Tick(); } UpdateBodies(); }
int main() { PopulateBodyVectorDisk(&Bodies, NumParticles, SimWidth, SimHeight, DiskRadiusMax, DiskRadiusMin, ObjectMassMin, ObjectMassMax, GalaticCenterMass); if (!IsPaused) //These will not if the simulation is paused { AttractToCenter(Bodies, SimWidth, SimHeight, GalaticCenterMass); UpdateBodies(Bodies); ResetForces(Bodies); GlobalNode.Reset(); GlobalNode.SetParam(Bodies, SimWidth, SimHeight); OctreeBodyAttraction(); } DeleteBodies(Bodies); }