Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Scenes/WarScene/WarScene.cpp

Diff revisions: vs.
  @@ -51,7 +51,8 @@
51 51 const vec3<F32>& eyePos = cam.getEye();
52 52 const vec3<F32>& euler = cam.getEuler();
53 53 //const vec3<F32>& lampPos = _lampLightNode->getComponent<PhysicsComponent>()->getPosition();
54 - _GUI->modifyText("fpsDisplay", "FPS: %3.0f. FrameTime: %3.1f", ApplicationTimer::getInstance().getFps(), ApplicationTimer::getInstance().getFrameTime());
54 + _GUI->modifyText("fpsDisplay", "FPS: %3.0f. FrameTime: %3.1f",
55 + ApplicationTimer::getInstance().getFps(), ApplicationTimer::getInstance().getFrameTime());
55 56 _GUI->modifyText("RenderBinCount", "Number of items in Render Bin: %d", GFX_RENDER_BIN_SIZE);
56 57 _GUI->modifyText("camPosition", "Position [ X: %5.2f | Y: %5.2f | Z: %5.2f ] [Pitch: %5.2f | Yaw: %5.2f]",
57 58 eyePos.x, eyePos.y, eyePos.z, euler.pitch, euler.yaw);
  @@ -134,12 +135,12 @@
134 135 previousMesh = true;
135 136 AI::AIManager::getInstance().destroyNavMesh(_army[0][0]->getAgentRadiusCategory());
136 137 }
137 - navMesh = New AI::Navigation::NavigationMesh();
138 + navMesh = MemoryManager_NEW AI::Navigation::NavigationMesh();
138 139 navMesh->setFileName(GET_ACTIVE_SCENE()->getName());
139 140
140 141 if (!navMesh->load(nullptr)) {
141 142 loadedFromFile = false;
142 - navMesh->build(nullptr, DELEGATE_BIND(navMeshCreationCompleteCallback, _army[0][0]->getAgentRadiusCategory(), navMesh));
143 + navMesh->build(nullptr,DELEGATE_BIND(navMeshCreationCompleteCallback,_army[0][0]->getAgentRadiusCategory(),navMesh));
143 144 } else {
144 145 AI::AIManager::getInstance().addNavMesh(_army[0][0]->getAgentRadiusCategory(), navMesh);
145 146 # ifdef _DEBUG
  @@ -171,7 +172,11 @@
171 172 }
172 173 }
173 174 } else {
174 - _infoBox->setMessage(stringAlg::toBase("Can't reload the navigation mesh this soon.\n Please wait \\[ " + Util::toString(getUsToSec<U64>(diffTime)) + " ] seconds more!"));
175 + stringImpl info("Can't reload the navigation mesh this soon.\n Please wait \\[ ");
176 + info.append(Util::toString(getUsToSec<U64>(diffTime)).c_str());
177 + info.append(" ] seconds more!");
178 +
179 + _infoBox->setMessage(info);
175 180 _infoBox->setMessageType(GUIMessageBox::MESSAGE_WARNING);
176 181 _infoBox->show();
177 182 }
  @@ -284,30 +289,38 @@
284 289 assert(currentNode);
285 290 currentNode->setSelectable(true);
286 291 currentNode->usageContext(baseNode->usageContext());
287 - currentNode->getComponent<PhysicsComponent>()->physicsGroup(baseNode->getComponent<PhysicsComponent>()->physicsGroup());
288 - currentNode->getComponent<NavigationComponent>()->navigationContext(baseNode->getComponent<NavigationComponent>()->navigationContext());
289 - currentNode->getComponent<NavigationComponent>()->navigationDetailOverride(baseNode->getComponent<NavigationComponent>()->navMeshDetailOverride());
292 + PhysicsComponent* pComp = currentNode->getComponent<PhysicsComponent>();
293 + NavigationComponent* nComp = currentNode->getComponent<NavigationComponent>();
294 + pComp->physicsGroup(baseNode->getComponent<PhysicsComponent>()->physicsGroup());
295 + nComp->navigationContext(baseNode->getComponent<NavigationComponent>()->navigationContext());
296 + nComp->navigationDetailOverride(baseNode->getComponent<NavigationComponent>()->navMeshDetailOverride());
290 297
291 - currentNode->getComponent<PhysicsComponent>()->setScale(baseNode->getComponent<PhysicsComponent>()->getScale());
292 - currentNode->getComponent<PhysicsComponent>()->setPosition(vec3<F32>(currentPos.first, -0.01f, currentPos.second));
298 + pComp->setScale(baseNode->getComponent<PhysicsComponent>()->getScale());
299 + pComp->setPosition(vec3<F32>(currentPos.first, -0.01f, currentPos.second));
293 300 }
294 301 SceneGraphNode* baseFlagNode = cylinder[1];
295 302 _flag[0] = _sceneGraph->getRoot()->addNode(cylinderMeshNW, "Team1Flag");
296 303 _flag[0]->setSelectable(false);
297 304 _flag[0]->usageContext(baseFlagNode->usageContext());
298 - _flag[0]->getComponent<PhysicsComponent>()->physicsGroup(baseFlagNode->getComponent<PhysicsComponent>()->physicsGroup());
299 - _flag[0]->getComponent<NavigationComponent>()->navigationContext(NavigationComponent::NODE_IGNORE);
300 - _flag[0]->getComponent<PhysicsComponent>()->setScale(baseFlagNode->getComponent<PhysicsComponent>()->getScale() * vec3<F32>(0.05f, 1.1f, 0.05f));
301 - _flag[0]->getComponent<PhysicsComponent>()->setPosition(vec3<F32>(25.0f, 0.1f, -206.0f));
305 + PhysicsComponent* flagPComp = _flag[0]->getComponent<PhysicsComponent>();
306 + NavigationComponent* flagNComp = _flag[0]->getComponent<NavigationComponent>();
307 + flagPComp->physicsGroup(baseFlagNode->getComponent<PhysicsComponent>()->physicsGroup());
308 + flagNComp->navigationContext(NavigationComponent::NODE_IGNORE);
309 + flagPComp->setScale(baseFlagNode->getComponent<PhysicsComponent>()->getScale() * vec3<F32>(0.05f, 1.1f, 0.05f));
310 + flagPComp->setPosition(vec3<F32>(25.0f, 0.1f, -206.0f));
302 311
303 312
304 313 _flag[1] = _sceneGraph->getRoot()->addNode(cylinderMeshNW, "Team2Flag");
305 314 _flag[1]->setSelectable(false);
306 315 _flag[1]->usageContext(baseFlagNode->usageContext());
307 - _flag[1]->getComponent<PhysicsComponent>()->physicsGroup(baseFlagNode->getComponent<PhysicsComponent>()->physicsGroup());
308 - _flag[1]->getComponent<NavigationComponent>()->navigationContext(NavigationComponent::NODE_IGNORE);
309 - _flag[1]->getComponent<PhysicsComponent>()->setScale(baseFlagNode->getComponent<PhysicsComponent>()->getScale() * vec3<F32>(0.05f, 1.1f, 0.05f));
310 - _flag[1]->getComponent<PhysicsComponent>()->setPosition(vec3<F32>(25.0f, 0.1f, 206.0f));
316 +
317 + flagPComp = _flag[1]->getComponent<PhysicsComponent>();
318 + flagNComp = _flag[1]->getComponent<NavigationComponent>();
319 +
320 + flagPComp->physicsGroup(baseFlagNode->getComponent<PhysicsComponent>()->physicsGroup());
321 + flagNComp->navigationContext(NavigationComponent::NODE_IGNORE);
322 + flagPComp->setScale(baseFlagNode->getComponent<PhysicsComponent>()->getScale() * vec3<F32>(0.05f, 1.1f, 0.05f));
323 + flagPComp->setPosition(vec3<F32>(25.0f, 0.1f, 206.0f));
311 324
312 325 AI::WarSceneAISceneImpl::registerFlags(_flag[0], _flag[1]);
313 326
  @@ -324,7 +337,7 @@
324 337 light->setCastShadows(false);
325 338 light->setRange(2.0f);
326 339 light->setDiffuseColor(vec3<F32>(1.0f, 0.5f, 0.0f));
327 - _lampTransform = New SceneTransform();
340 + _lampTransform = MemoryManager_NEW SceneTransform();
328 341 // Add it to Bob's body
329 342 _lampTransformNode = _bobNodeBody->addNode(_lampTransform, "lampTransform");
330 343 _lampLightNode = addLight(light, _lampTransformNode);
  @@ -361,7 +374,7 @@
361 374
362 375 // Create 2 AI teams
363 376 for (U8 i = 0; i < 2; ++i) {
364 - _faction[i] = New AI::AITeam(i);
377 + _faction[i] = MemoryManager_NEW AI::AITeam(i);
365 378 }
366 379 // Make the teams fight each other
367 380 _faction[0]->addEnemyTeam(_faction[1]->getTeamID());
  @@ -454,7 +467,9 @@
454 467 currentNode->setSelectable(true);
455 468 I8 side = k == 0 ? -1 : 1;
456 469
457 - currentNode->getComponent<PhysicsComponent>()->setPosition(vec3<F32>(-125 + 25*(i%5), -0.01f, 200 * side + 25*zFactor*side));
470 + currentNode->getComponent<PhysicsComponent>()->setPosition(vec3<F32>(-125 + 25 * (i % 5),
471 + -0.01f,
472 + 200 * side + 25 * zFactor * side));
458 473 if (side == 1) {
459 474 currentNode->getComponent<PhysicsComponent>()->rotateY(180);
460 475 currentNode->getComponent<PhysicsComponent>()->translateX(100);
  @@ -462,11 +477,13 @@
462 477
463 478 currentNode->getComponent<PhysicsComponent>()->translateX(25 * side);
464 479
465 - aiSoldier = New AI::AIEntity(currentNode->getComponent<PhysicsComponent>()->getPosition(), currentNode->getName());
480 + aiSoldier = MemoryManager_NEW AI::AIEntity(currentNode->getComponent<PhysicsComponent>()->getPosition(),
481 + currentNode->getName());
466 482 aiSoldier->addSensor(AI::VISUAL_SENSOR);
467 - k == 0 ? currentNode->getComponent<RenderingComponent>()->renderBoundingBox(true) : currentNode->getComponent<RenderingComponent>()->renderSkeleton(true);
483 + k == 0 ? currentNode->getComponent<RenderingComponent>()->renderBoundingBox(true) :
484 + currentNode->getComponent<RenderingComponent>()->renderSkeleton(true);
468 485
469 - AI::WarSceneAISceneImpl* brain = New AI::WarSceneAISceneImpl();
486 + AI::WarSceneAISceneImpl* brain = MemoryManager_NEW AI::WarSceneAISceneImpl();
470 487
471 488 //GOAP
472 489 brain->worldState().setVariable(AI::GOAPFact(AI::AtHomeFlagLoc), AI::GOAPValue(true));
  @@ -489,7 +506,7 @@
489 506 brain->registerGoal(retrieveFlag);
490 507
491 508 aiSoldier->addAISceneImpl(brain);
492 - soldier = New NPC(currentNode, aiSoldier);
509 + soldier = MemoryManager_NEW NPC(currentNode, aiSoldier);
493 510 soldier->setMovementSpeed(speed * 2);
494 511 _armyNPCs[k].push_back(soldier);
495 512 _army[k].push_back(aiSoldier);
  @@ -512,11 +529,11 @@
512 529 _sceneGraph->getRoot()->deleteNode( soldierNode3 );
513 530
514 531 for (U8 i = 0; i < 2; ++i) {
515 - _orders[i].push_back(New AI::WarSceneOrder(AI::WarSceneOrder::ORDER_FIND_ENEMY_FLAG));
516 - _orders[i].push_back(New AI::WarSceneOrder(AI::WarSceneOrder::ORDER_CAPTURE_ENEMY_FLAG));
517 - _orders[i].push_back(New AI::WarSceneOrder(AI::WarSceneOrder::ORDER_RETURN_ENEMY_FLAG));
518 - _orders[i].push_back(New AI::WarSceneOrder(AI::WarSceneOrder::ORDER_PROTECT_FLAG_CARRIER));
519 - _orders[i].push_back(New AI::WarSceneOrder(AI::WarSceneOrder::ORDER_RETRIEVE_FLAG));
532 + _orders[i].push_back(MemoryManager_NEW AI::WarSceneOrder(AI::WarSceneOrder::ORDER_FIND_ENEMY_FLAG));
533 + _orders[i].push_back(MemoryManager_NEW AI::WarSceneOrder(AI::WarSceneOrder::ORDER_CAPTURE_ENEMY_FLAG));
534 + _orders[i].push_back(MemoryManager_NEW AI::WarSceneOrder(AI::WarSceneOrder::ORDER_RETURN_ENEMY_FLAG));
535 + _orders[i].push_back(MemoryManager_NEW AI::WarSceneOrder(AI::WarSceneOrder::ORDER_PROTECT_FLAG_CARRIER));
536 + _orders[i].push_back(MemoryManager_NEW AI::WarSceneOrder(AI::WarSceneOrder::ORDER_RETRIEVE_FLAG));
520 537 }
521 538
522 539 return state;
  @@ -528,23 +545,14 @@
528 545 while (AI::AIManager::getInstance().updating()) {
529 546 }
530 547 for (U8 i = 0; i < 2; ++i) {
531 - for(U8 j = 0; j < _armyNPCs[i].size(); ++j){
532 - MemoryManager::SAFE_DELETE( _armyNPCs[i][j] );
548 + for (Divide::AI::AIEntity* entity : _army[i]) {
549 + AI::AIManager::getInstance().unregisterEntity(entity);
533 550 }
534 - _armyNPCs[i].clear();
535 551
536 - for(U8 j = 0; j < _army[i].size(); ++j) {
537 - AI::AIManager::getInstance().unregisterEntity(_army[i][j]);
538 - MemoryManager::SAFE_DELETE( _army[i][j] );
539 - }
540 - _army[i].clear();
541 -
542 - MemoryManager::SAFE_DELETE( _faction[i] );
543 -
544 - for(AI::WarSceneOrder*& order : _orders[i]) {
545 - MemoryManager::SAFE_DELETE( order );
546 - }
547 - _orders[i].clear();
552 + MemoryManager::DELETE_VECTOR(_armyNPCs[i]);
553 + MemoryManager::DELETE_VECTOR(_army[i]);
554 + MemoryManager::DELETE_VECTOR(_orders[i]);
555 + MemoryManager::DELETE( _faction[i] );
548 556 }
549 557
550 558 return Scene::deinitializeAI(continueOnErrors);
  @@ -588,13 +596,13 @@
588 596 0.0f, 0.0f, 0.0f);
589 597 _infoBox = _GUI->addMsgBox("infoBox", "Info", "Blabla");
590 598 //Add a first person camera
591 - Camera* cam = New FirstPersonCamera();
599 + Camera* cam = MemoryManager_NEW FirstPersonCamera();
592 600 cam->fromCamera(renderState().getCameraConst());
593 601 cam->setMoveSpeedFactor(10.0f);
594 602 cam->setTurnSpeedFactor(10.0f);
595 603 renderState().getCameraMgr().addNewCamera("fpsCamera", cam);
596 604 //Add a third person camera
597 - cam = New ThirdPersonCamera();
605 + cam = MemoryManager_NEW ThirdPersonCamera();
598 606 cam->fromCamera(renderState().getCameraConst());
599 607 cam->setMoveSpeedFactor(0.02f);
600 608 cam->setTurnSpeedFactor(0.01f);