// // Display // void Display( Bool simFrame) { Vid::RenderBegin(); Vid::RenderClear(); if (Vid::Config::TrilinearOff()) { // turn trilinear back on for terrain U32 filter = *Vid::Var::varFilter ? Vid::filterFILTER : 0; if (*Vid::Var::varMipmap) { filter |= Vid::filterMIPMAP; } if (*Vid::Var::varMipfilter) { filter |= Vid::filterMIPFILTER; } Vid::SetFilterStateI( filter); } if (Vid::renderState.status.mirror) { DisplayMirror(); } // Inform client PERF_S("BuildDisplayList") MapObjCtrl::BuildDisplayList(Team::GetDisplayTeam(), simFrame); PERF_E("BuildDisplayList") // Render PERF_S("Terrain::Render"); Terrain::Sky::Render(); Client::Display::PreTerrain(); Terrain::Render(); Environment::Render(); Vid::FlushBuckets(); PERF_E("Terrain::Render"); if (Vid::Config::TrilinearOff()) { // turn trilinear filtering off for models Vid::SetFilterStateI( Vid::renderState.status.filter & ~Vid::filterMIPFILTER); } PERF_S("MapObjCtrl::Render"); MapObjCtrl::Render(); Vid::FlushBuckets(); PERF_E("MapObjCtrl::Render"); PERF_S("Particles::Render"); ParticleSystem::Render(Vid::CurCamera()); PERF_E("Particles::Render"); PERF_S("Client::Render"); Client::Display::Render(); PERF_E("Client::Render"); }
// // Display // void DisplayMirror() { if (!Vid::Mirror::Start()) { return; } while (U32 val = Vid::Mirror::LoopStart()) { Terrain::Sky::Render(); // if (val > 1) { // test for clip against mirror plane // MapObjCtrl::BuildMirrorList(); // Render PERF_S("Terrain::Render"); if (Vid::renderState.status.mirTerrain) { Terrain::Render(); } Vid::FlushBuckets(); PERF_E("Terrain::Render"); PERF_S("MapObjCtrl::Render"); if (Vid::renderState.status.mirObjects) { MapObjCtrl::RenderMirror(); } Vid::FlushBuckets(); PERF_E("MapObjCtrl::Render"); PERF_S("Particles::Render"); if (Vid::renderState.status.mirParticles) { ParticleSystem::Render(Vid::CurCamera()); } PERF_E("Particles::Render"); } Vid::Mirror::LoopStop(); } Vid::Mirror::Stop(); }
// // Display // void DisplayMirror() { if (!Vid::Mirror::Start()) { return; } while (U32 val = Vid::Mirror::LoopStart()) { // test for clip against mirror plane // MapObjCtrl::BuildMirrorList(); Terrain::Sky::Render(); // if (val > 1) { PERF_S("Terrain::Render"); if (Vid::renderState.status.mirTerrain) { Terrain::Render(); } if (Vid::renderState.status.mirEnvironment) { Environment::Render(); } Vid::FlushBuckets(); PERF_E("Terrain::Render"); PERF_S("MapObjCtrl::Render"); if (Vid::renderState.status.mirObjects) { MapObjCtrl::RenderMirror(); } PERF_E("MapObjCtrl::Render"); } Vid::Mirror::LoopStop(); } Vid::Mirror::Stop(); }
// // Process // void Process() { switch (migration) { case NORMAL: { // Sample game speed frameRate.Sample(Main::elapTime); // Process the client Client::Events::Process(); // Process real time camera things independent of display Viewer::GameTimeSim(); if (Viewer::movie) { GameTime::Test(); PERF_S("RenderFlush"); Vid::RenderFlush(); PERF_E("RenderFlush"); return; } // Should we display or skip this frame Bool display = Vid::isStatus.active && GameTime::DisplayCount(); Bool disPost = *Vid::Var::varRenderPostSim && display; U32 displayTime = 0; if (display) { Client::Display::PreRender(); if (!*Vid::Var::varRenderPostSim) { PERF_S("Render"); { U32 start = Clock::Time::UsLwr(); Display( TRUE); displayTime += Clock::Time::UsLwr() - start; // Post render parallel code - NON SYNC if (!GameTime::Paused()) { Terrain::Simulate( Main::elapSecs); } } PERF_E("Render"); } } // update auto mrm error factor // //Mesh::Manager::UpdateMRMFactor(); // Pause when a modal control is active if (allowModalPause) { if (IFace::GetModal()) { if (!GameTime::Paused()) { GameTime::Pause(FALSE); modalPause = TRUE; } } else { if (GameTime::Paused() && modalPause) { GameTime::Pause(FALSE); modalPause = FALSE; } } } // Reset mode BEFORE GameTime::Test Utils::FP::Reset(); // Is it time to do the next game processing U32 gameTest = GameTime::Test(); if (gameTest) { SYNC_BRUTAL("Mode: " << Utils::FP::GetState() << " Random: " << Random::sync.Raw()) // Blip an order #ifdef SYNC_BRUTAL_ACTIVE if (!Missions::ShellActive()) { Orders::SendBlip(); } #endif #ifdef SYNC_BRUTAL_ACTIVE SYNC(" === SIM START ===") Sync::SyncObjects(TRUE); SYNC(" ___ SIM START ___") #endif PERF_S("Simulation"); // prepare state0 world matrices and state1 anim targets for this frame // PERF_S("UpdateMapPos"); MapObjCtrl::UpdateMapPos(); PERF_E("UpdateMapPos"); PERF_S("SimulateInt"); MapObjCtrl::SimulateInt( GameTime::SimTime()); PERF_E("SimulateInt"); SYNC_BRUTAL("Mode: " << Utils::FP::GetState()) } if (disPost) { PERF_S("Render"); U32 start = Clock::Time::UsLwr(); Display( gameTest); displayTime += Clock::Time::UsLwr() - start; // Post render parallel code - NON SYNC if (!GameTime::Paused()) { Terrain::Simulate( Main::elapSecs); } PERF_E("Render"); } if (gameTest) { // Reset mode Utils::FP::Reset(); SYNC_BRUTAL("Mode: " << Utils::FP::GetState()) // Sync vars which should be synced SYNC ( Vid::Var::Terrain::shroud ) // Process Environment PERF_S("Environment"); Environment::Process(); PERF_E("Environment"); // Perform AI Processing PERF_S("AI"); AI::Process(); PERF_E("AI"); // Perform Game Object Thinking PERF_S("ObjectThought"); GameObjCtrl::ProcessObjectThought(); PERF_E("ObjectThought"); // FX processing // MUST be before particle and mesheffect processing // MUST be before GameObjCtrl::DeleteDyingObjects // MUST be after ProcessObjectThought // PERF_S("FX"); FX::Process(); PERF_E("FX"); GameObjCtrl::DeleteDyingObjects(); // Perform Path Searching PERF_S("PathSearching"); PathSearch::ProcessRequests(); PERF_E("PathSearching"); // Movement collision resolution PERF_S("Movement::Mediate"); Movement::Mediator::Process(); PERF_E("Movement::Mediate"); // Do all per-cycle object processing MapObjCtrl::ProcessObjects(); // Perform collision fixups // // this resets the world matrices // should be after all object position updates // PERF_S("Collision Resolve"); CollisionCtrl::Resolve(); PERF_E("Collision Resolve"); // Perform Particle Processing PERF_S("ParticleSimulate"); ParticleSystem::Simulate( GameTime::SimTime()); ParticleSystem::SimulateInt( Main::elapSecs); PERF_E("ParticleSimulate"); // Perform Team Processing PERF_S("Team"); Team::ProcessAll(); PERF_E("Team"); #ifdef SYNC_BRUTAL_ACTIVE SYNC(" === SIM END ===") Sync::SyncObjects(TRUE); SYNC(" ___ SIM END ___") #endif SYNC_BRUTAL("Mode: " << Utils::FP::GetState()) // Update line of sight display PERF_S("Sight::DetachedList"); Sight::ProcessDetachedList(); PERF_E("Sight::DetachedList"); // Update line of sight display PERF_S("Sight Display"); Sight::UpdateDisplay( Team::GetDisplayTeam()); PERF_E("Sight Display"); // Tell game time to recompute the display cycles per game cycle GameTime::Compute(); // NON-SYNC client side processing that is done at the sim rate PERF_S("Demo"); Demo::Process(); PERF_E("Demo"); PERF_E("Simulation"); } else // Process interpolation if (Vid::renderState.status.interpMesh && !GameTime::Paused() && !GameTime::IsStalled()) { PERF_S("Interpolate"); MapObjCtrl::SimulateInt( Main::elapSecs); PERF_E("Interpolate"); if (disPost) { PERF_S("Render"); U32 start = Clock::Time::UsLwr(); Display( FALSE); displayTime += Clock::Time::UsLwr() - start; // Post render parallel code - NON SYNC if (!GameTime::Paused()) { Terrain::Simulate( Main::elapSecs); } PERF_E("Render"); } ParticleSystem::SimulateInt( Main::elapSecs); } // Main rendering code if (display) { PERF_S("PostRender"); U32 start = Clock::Time::UsLwr(); // Finish render Vid::RenderEnd(); PERF_S("RenderFlush"); Vid::RenderFlush(); PERF_E("RenderFlush"); displayTime += Clock::Time::UsLwr() - start; PERF_E("PostRender"); // Notify client that rendering is finished Client::Display::PostRender(); // Report display time to GameTime GameTime::DisplaySample(displayTime); displayRate.Sample(displayTime / 1000); triCount.Sample(Main::triCount); } break; } case MIGRATING: if (!MultiPlayer::Data::Online()) { migration = NORMAL; LOG_DIAG(("Switching to NORMAL")) return; } // Process input events if (Main::active) { IFace::Process(); } if (!MultiPlayer::Data::Online()) { migration = NORMAL; LOG_DIAG(("Switching to NORMAL")) return; }
// // Display // void Display() { Vid::RenderBegin(); Vid::RenderClear(); if (Vid::Config::TrilinearOff()) { // turn trilinear back on for terrain U32 filter = *Vid::Var::varFilter ? Vid::filterFILTER : 0; if (*Vid::Var::varMipmap) { filter |= Vid::filterMIPMAP; } if (*Vid::Var::varMipfilter) { filter |= Vid::filterMIPFILTER; } Vid::SetFilterStateI( filter); } if (Vid::renderState.status.mirror) { DisplayMirror(); } MapObjCtrl::BuildDisplayList( NULL, TRUE); PERF_S("Terrain::Render"); Terrain::Sky::Render(); Terrain::Render(); Environment::Render(); Vid::FlushBuckets(); PERF_E("Terrain::Render"); if (Vid::Config::TrilinearOff()) { // turn trilinear filtering off for models Vid::SetFilterStateI( Vid::renderState.status.filter & ~Vid::filterMIPFILTER); } MapObjCtrl::Render(); PERF_S("Flush buckets"); Vid::FlushBuckets(); PERF_E("Flush buckets"); ParticleSystem::Render(Vid::CurCamera()); // Display debug information #ifdef DEVELOPMENT Common::Display::RenderDebug(); #endif // Notify the brush to do all predrawing data.brush->Notify("System::PreDraw"); PERF_S("Flush buckets"); Vid::FlushBuckets(); Vid::FlushTranBuckets(); PERF_E("Flush buckets"); // Render interface IFace::Render(); // Notify the brush to do all postdrawing data.brush->Notify("System::PostDraw"); // Finish 3D rendering Vid::RenderEnd(); }
// // Object::Process // // Perform processing for this strategic object // void Object::Process() { // Transfer the notifications to a processing list to prevent recursion NList<Notification> process(&Notification::node); notifications.Transfer(process); // Process Notifications Notification *notification; NList<Notification>::Iterator n(&process); while ((notification = n++) != NULL) { // Send it to the base manager baseManager.Notify(*notification); // Send it to the script manager scriptManager.Notify(*notification); // Send it to the transport manager transportManager.Notify(*notification); // Dispose of the notification process.Dispose(notification); } U32 i; PERF_S("Asset"); // Process Asset Manager for (i = 0; i < ITERATIONS_ASSET_MANAGER; i++) { assetManager.Process(); } PERF_E("Asset"); PERF_S("Base"); // Process Base Manager for (i = 0; i < ITERATIONS_BASE_MANAGER; i++) { baseManager.Process(); } PERF_E("Base"); PERF_S("Bombardier"); // Process the Bombardier manager for (i = 0; i < ITERATIONS_BOMBARDIER_MANAGER; i++) { bombardierManager.Process(); } PERF_E("Bombardier"); PERF_S("Intel"); // Process the Intel manager for (i = 0; i < ITERATIONS_INTEL_MANAGER; i++) { intelManager.Process(); } PERF_E("Intel"); PERF_S("Placement"); // Process the Placement manager for (i = 0; i < ITERATIONS_PLACEMENT_MANAGER; i++) { placementManager.Process(); } PERF_E("Placement"); PERF_S("Resource"); // Process the Resource manager for (i = 0; i < ITERATIONS_RESOURCE_MANAGER; i++) { resourceManager.Process(); } PERF_E("Resource"); PERF_S("Water"); // Process the Resource manager for (i = 0; i < ITERATIONS_WATER_MANAGER; i++) { waterManager.Process(); } PERF_E("Water"); PERF_S("Rule"); // Process the Rule manager for (i = 0; i < ITERATIONS_RULE_MANAGER; i++) { ruleManager.Process(); } PERF_E("Rule"); PERF_S("Script"); // Process Script Manager for (i = 0; i < ITERATIONS_SCRIPT_MANAGER; i++) { scriptManager.Process(); } PERF_E("Script"); }
// // ProjectileObj::ProcessCycle // // Per-cycle processing // void ProjectileObj::ProcessCycle() { PERF_S(("ProjectileObj")) Bool boom = FALSE; // Has a proximity distance been specifed ? F32 proximity2 = ProjectileType()->GetProximity2(); if (proximity2 && GetTarget().Alive()) { // Is the target close enough ? Vector target = GetTarget().GetLocation() - Position(); // Proximity type checks switch (ProjectileType()->GetProximityType()) { case ProjectileObjType::PROXIMITY_NORMAL: if (target.Magnitude2() < proximity2) { boom = TRUE; } break; case ProjectileObjType::PROXIMITY_XZ: if (target.MagnitudeXZ2() < proximity2) { boom = TRUE; } break; case ProjectileObjType::PROXIMITY_Y: if ((GetVelocity().y < 0.0F) && (fabs(target.y) < ProjectileType()->GetProximity())) { boom = TRUE; } break; } if (boom) { // Kaboom Detonate(); } } // Has the fuse expired ? if ( !boom && !ProjectileType()->GetImpact() && GameTime::SimTotalTime() - GetBirthTime() > ProjectileType()->GetFuse() ) { // Kaboom Detonate(); } // Perform type specific physics if (!deathNode.InUse()) { Matrix m = WorldMatrix(); Vector s; ProjectileType()->ProcessProjectilePhysics(*this, m, s); // Update odometer and position distTravelled += s.Magnitude(); m.posit += s; SetSimTarget(m); // Register movement with the collision system CollisionCtrl::AddObject(this); } PERF_E(("ProjectileObj")) // Call base class MapObj::ProcessCycle(); }