cWorld3D::~cWorld3D() { if(cHaptic::GetIsUsed()) { //mpHaptic->GetLowLevel()->DestroyAllShapes(); //Not so good to do it here.. } STLDeleteAll(mlstMeshEntities); STLDeleteAll(mlstLights); STLDeleteAll(mlstBillboards); STLDeleteAll(mlstBeams); STLDeleteAll(mlstColliders); STLDeleteAll(mlstParticleSystems); STLDeleteAll(mlstStartPosEntities); STLMapDeleteAll(m_mapAreaEntities); STLDeleteAll(mlstAINodeContainers); STLDeleteAll(mlstAStarHandlers); STLMapDeleteAll(m_mapTempNodes); if(mpScript){ mpResources->GetScriptManager()->Destroy(mpScript); } if(mpPhysicsWorld && mbAutoDeletePhysicsWorld) mpPhysics->DestroyWorld(mpPhysicsWorld); //So that bodies can stop sound entities on destruction. STLDeleteAll(mlstSoundEntities); hplDelete(mpPortalContainer); hplDelete(mpRootNode); }
cScene::~cScene() { Log("Exiting Scene Module\n"); Log("--------------------------------------------------------\n"); STLDeleteAll(mlstWorld3D); STLDeleteAll(mlstCamera); hplDelete(mpCollider2D); Log("--------------------------------------------------------\n\n"); }
cAnimationState::~cAnimationState() { STLDeleteAll(m_vEvents); if (m_pAnimationManager) m_pAnimationManager->Destroy(m_pAnimation); }
void cMapHandler::Reset() { #ifdef DEMO_VERSION glNumOfLoads = 0; #endif mMapChanger.mbActive = false; msCurrentMap = ""; if(mpInit->mbResetCache) mpWorldCache->DecResources(); mvLoadedMaps.clear(); //Timers STLDeleteAll(mlstTimers); DestroyAll(); //Haptic if(mpInit->mbHasHaptics) { mpInit->mpGame->GetHaptic()->GetLowLevel()->DestroyAllShapes(); mpInit->mpGame->GetHaptic()->GetLowLevel()->StopAllForces(); } //World3D if(mpScene->GetWorld3D()) mpScene->DestroyWorld3D(mpScene->GetWorld3D()); mpScene->SetWorld3D(NULL); //Make sure no occulssion queries are left. mpInit->mpGame->GetGraphics()->GetRenderer3D()->GetRenderList()->Clear(); }
void cGameMessageHandler::Update(float afTimeStep) { if(mpInit->mpPlayer->IsDead()) { STLDeleteAll(mlstMessages); mlstMessages.clear(); return; } int lCount=0; tGameMessageListIt it = mlstMessages.begin(); for(;it != mlstMessages.end(); ++lCount) { cGameMessage *pMess = *it; pMess->Update(afTimeStep); if(lCount==0 && pMess->mbActive==false) { hplDelete( pMess ); it = mlstMessages.erase(it); } else { ++it; } } }
void cGameMessageHandler::Reset() { STLDeleteAll(mlstMessages); mlstMessages.clear(); mbFocusIsedUsed = false; }
void iPhysicsWorld::DestroyAll() { STLDeleteAll(mlstCharBodies); //Bodies tPhysicsBodyListIt it = mlstBodies.begin(); for(; it != mlstBodies.end(); ++it) { iPhysicsBody *pBody = *it; pBody->Destroy(); hplDelete(pBody); } mlstBodies.clear(); STLDeleteAll(mlstShapes); STLDeleteAll(mlstJoints); STLDeleteAll(mlstControllers); STLMapDeleteAll(m_mapMaterials); }
cPhysics::~cPhysics() { Log("Exiting Physics Module\n"); Log("--------------------------------------------------------\n"); STLDeleteAll(mlstWorlds); STLMapDeleteAll(m_mapSurfaceData); Log("--------------------------------------------------------\n\n"); }
void cMapHandler::DestroyAll() { mbDestroyingAll = true; RemoveLocalTimers(); //Game entities STLMapDeleteAll(m_mapGameEntities); m_mapGameEntities.clear(); mlstGameEnemies.clear(); mlstGameItems.clear(); //Light flashes STLDeleteAll(mlstLightFlashes); mlstLightFlashes.clear(); mbDestroyingAll = false; }
cGraphicsDrawer::~cGraphicsDrawer() { ClearBackgrounds(); STLDeleteAll(mlstGfxObjects); }
void cGuiClipRegion::Clear() { STLDeleteAll(mlstChildren); }
cSurfaceData::~cSurfaceData() { STLDeleteAll(mvImpactData); STLDeleteAll(mvHitData); }
cNumericalPanel::~cNumericalPanel(void) { STLDeleteAll(mlstButtons); }
cSector::~cSector() { STLDeleteAll(mlstPortals); }
cAStarHandler::~cAStarHandler() { STLDeleteAll(m_setClosedList); STLDeleteAll(m_setOpenList); }
cVideoManager::~cVideoManager() { STLDeleteAll(mlstVideoLoaders); }
iGameEntity::~iGameEntity() { cWorld3D *pWorld = mpInit->mpGame->GetScene()->GetWorld3D(); ////////////////////////////////////////////// // Remove all references to from all otter //Log("Deleting '%s'\n",msName.c_str()); //Player mpInit->mpPlayer->RemoveCollideScriptWithChildEntity(this); //Other entities (check so not all entities are being destroyed, // in that case it is not needed and might be bad). if(mpInit->mpMapHandler->IsDestroyingAll()==false) { tGameEntityIterator it = mpInit->mpMapHandler->GetGameEntityIterator(); while(it.HasNext()) { iGameEntity *pEntity = it.Next(); pEntity->RemoveCollideScriptWithChildEntity(this); } } //////////////////////////////////////////// // Destroy haptic for(size_t i=0; i< mvHapticShapes.size(); ++i) { if(mvHapticShapes[i]) { mpInit->mpGame->GetHaptic()->GetLowLevel()->DestroyShape(mvHapticShapes[i]); } } ////////////////////////////////////////////// // Destroy all graphics in the entity! if(pWorld && mpInit->mbDestroyGraphics) { for(size_t i=0; i<mvBodies.size(); ++i) { //Make sure that this body is not picked! if(mpInit->mpPlayer->GetPickedBody() == mvBodies[i]) mpInit->mpPlayer->GetPickRay()->mpPickedBody = NULL; if(mpInit->mpPlayer->GetPushBody() == mvBodies[i]) { ePlayerState state = mpInit->mpPlayer->GetState(); if( state == ePlayerState_Move || state == ePlayerState_Grab || state == ePlayerState_Push) { ePlayerState prevState = mpInit->mpPlayer->GetStateData(state)->mPreviuosState; if(prevState == ePlayerState_InteractMode) mpInit->mpPlayer->ChangeState(ePlayerState_InteractMode); else mpInit->mpPlayer->ChangeState(ePlayerState_Normal); } mpInit->mpPlayer->SetPushBody(NULL); } pWorld->GetPhysicsWorld()->DestroyBody(mvBodies[i]); } if(mpMeshEntity) pWorld->DestroyMeshEntity(mpMeshEntity); for(size_t i=0; i<mvLights.size(); ++i) pWorld->DestroyLight(mvLights[i]); for(size_t i=0; i<mvParticleSystems.size(); ++i) if(mvParticleSystems[i]) mvParticleSystems[i]->Kill(); for(size_t i=0; i<mvBillboards.size(); ++i) pWorld->DestroyBillboard(mvBillboards[i]); for(size_t i=0; i<mvBeams.size(); ++i) pWorld->DestroyBeam(mvBeams[i]); for(size_t i=0; i<mvSoundEntities.size(); ++i) { pWorld->DestroySoundEntity(mvSoundEntities[i]); } if(mpCharBody) pWorld->GetPhysicsWorld()->DestroyCharacterBody(mpCharBody); } //Delete callbacks for(int i=0; i< eGameEntityScriptType_LastEnum; ++i) { if( mvCallbackScripts[i]) hplDelete( mvCallbackScripts[i] ); } STLMapDeleteAll(m_mapCollideCallbacks); STLDeleteAll(mvTransMaterials); for(size_t i=0; i<mvPreloadedBreakMeshes.size();++i) { mpInit->mpGame->GetResources()->GetMeshManager()->Destroy(mvPreloadedBreakMeshes[i]); } }
cGameMessageHandler::~cGameMessageHandler(void) { STLDeleteAll(mlstMessages); }
cAnimation::~cAnimation() { STLDeleteAll(mvTracks); }
bool cAStarHandler::GetPath(const cVector3f& avStart, const cVector3f& avGoal,tAINodeList *apNodeList) { ///////////////////////////////////////////////// // check if there is free path from start to goal if(mpContainer->FreePath(avStart,avGoal,3)) { mpGoalNode = NULL; return true; } //////////////////////////////////////////////// //Reset all variables //These should just be cleared and pools used instead. STLDeleteAll(m_setClosedList); STLDeleteAll(m_setOpenList); m_setGoalNodes.clear(); mpGoalNode=NULL; //Set goal position mvGoal = avGoal; float fMaxHeight = mpContainer->GetMaxHeight()*1.5f; //////////////////////////////////////////////// //Find nodes reachable from the start and goal position (use double 2*2 distance) float fMaxDist = mpContainer->GetMaxEdgeDistance()*2; //float fMaxDist = mpContainer->GetMaxEdgeDistance()*mpContainer->GetMaxEdgeDistance()*4; ///////////////////// //Check with Start //Log(" Get Start\n"); cAINodeIterator startNodeIt = mpContainer->GetNodeIterator(avStart,fMaxDist); while(startNodeIt.HasNext()) { cAINode *pAINode = startNodeIt.Next(); //Log("Check node: %s\n",pAINode->GetName().c_str()); float fHeight = fabs(avStart.y - pAINode->GetPosition().y); float fDist = cMath::Vector3Dist(avStart,pAINode->GetPosition()); //float fDist = cMath::Vector3DistSqr(avStart,pAINode->GetPosition()); if(fDist < fMaxDist && fHeight <= fMaxHeight) { //Check if path is clear if(mpContainer->FreePath(avStart,pAINode->GetPosition(),-1, eAIFreePathFlag_SkipDynamic)) { AddOpenNode(pAINode,NULL,fDist); } } } //Log(" Found start\n"); //////////////////////////////// //Check with Goal //Log(" Get Goal\n"); cAINodeIterator goalNodeIt = mpContainer->GetNodeIterator(avGoal,fMaxDist); while(goalNodeIt.HasNext()) { cAINode *pAINode = goalNodeIt.Next(); //Log("Check node: %s\n",pAINode->GetName().c_str()); float fHeight = fabs(avGoal.y - pAINode->GetPosition().y); float fDist = cMath::Vector3Dist(avGoal,pAINode->GetPosition()); //fDist = cMath::Vector3DistSqr(avGoal,pAINode->GetPosition()); if(fDist < fMaxDist && fHeight <= fMaxHeight) { //Check if path is clear if(mpContainer->FreePath(avGoal,pAINode->GetPosition(),3)) { m_setGoalNodes.insert(pAINode); } } } //Log(" Found goal\n"); /*for(int i=0; i<mpContainer->GetNodeNum(); ++i) { cAINode *pAINode = mpContainer->GetNode(i); //////////////////////////////// //Check with Start float fHeight = fabs(avStart.y - pAINode->GetPosition().y); float fDist = cMath::Vector3Dist(avStart,pAINode->GetPosition()); //float fDist = cMath::Vector3DistSqr(avStart,pAINode->GetPosition()); if(fDist < fMaxDist && fHeight <= fMaxHeight) { //Check if path is clear if(mpContainer->FreePath(avStart,pAINode->GetPosition(),-1)) { AddOpenNode(pAINode,NULL,fDist); } } //////////////////////////////// //Check with Goal fHeight = fabs(avGoal.y - pAINode->GetPosition().y); fDist = cMath::Vector3Dist(avGoal,pAINode->GetPosition()); //fDist = cMath::Vector3DistSqr(avGoal,pAINode->GetPosition()); if(fDist < fMaxDist && fHeight <= fMaxHeight) { //Check if path is clear if(mpContainer->FreePath(avGoal,pAINode->GetPosition(),3)) { m_setGoalNodes.insert(pAINode); } } }*/ //////////////////////////////////////////////// //Iterate the algorithm IterateAlgorithm(); //////////////////////////////////////////////// //Check if goal was found, if so build path. if(mpGoalNode) { if(apNodeList) { cAStarNode *pParentNode = mpGoalNode; while(pParentNode != NULL) { apNodeList->push_back(pParentNode->mpAINode); pParentNode = pParentNode->mpParent; } } return true; } else { return false; } }
cAnimationTrack::~cAnimationTrack() { STLDeleteAll(mvKeyFrames); }