Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 992 vs 993 for /trunk/Source Code/Scenes/WarScene/WarScene.cpp

Diff revisions: vs.
  @@ -54,8 +54,8 @@
54 54 _resetUnits = false;
55 55
56 56 addSelectionCallback([&](PlayerIndex idx) {
57 - if (!_currentSelection[idx].expired()) {
58 - _GUI->modifyText(_ID("entityState"), _currentSelection[idx].lock()->getName().c_str());
57 + if (_currentSelection[idx]) {
58 + _GUI->modifyText(_ID("entityState"), _currentSelection[idx]->getName().c_str());
59 59 } else {
60 60 _GUI->modifyText(_ID("entityState"), "");
61 61 }
  @@ -97,8 +97,8 @@
97 97 }
98 98
99 99 if (_guiTimersMS[1] >= Time::SecondsToMilliseconds(1)) {
100 - if (!_currentSelection[0].expired()) {
101 - AI::AIEntity* entity = findAI(_currentSelection[0].lock());
100 + if (_currentSelection[0]) {
101 + AI::AIEntity* entity = findAI(_currentSelection[0]);
102 102 if (entity) {
103 103 _GUI->modifyText(_ID("entityState"), entity->toString().c_str());
104 104 }
  @@ -174,41 +174,41 @@
174 174 -cosf(g_sunAngle.y),
175 175 -sinf(g_sunAngle.x) * sinf(g_sunAngle.y));
176 176
177 - _sun.lock()->get<TransformComponent>()->setPosition(sunVector);
177 + _sun->get<TransformComponent>()->setPosition(sunVector);
178 178 vec4<F32> sunColour = vec4<F32>(1.0f, 1.0f, 0.2f, 1.0f);
179 179
180 - _sun.lock()->getNode<Light>()->setDiffuseColour(sunColour);
180 + _sun->getNode<Light>()->setDiffuseColour(sunColour);
181 181
182 - PushConstants& constants = _currentSky.lock()->get<RenderingComponent>()->pushConstants();
182 + PushConstants& constants = _currentSky->get<RenderingComponent>()->pushConstants();
183 183 constants.set("enable_sun", PushConstantType::BOOL, true);
184 184 constants.set("sun_vector", PushConstantType::VEC3, sunVector);
185 - constants.set("sun_colour", PushConstantType::VEC3, _sun.lock()->getNode<Light>()->getDiffuseColour());
185 + constants.set("sun_colour", PushConstantType::VEC3, _sun->getNode<Light>()->getDiffuseColour());
186 186
187 187 _taskTimers[0] = 0.0;
188 188 }
189 189
190 190 if (_taskTimers[1] >= AnimationTimer1) {
191 - for (SceneGraphNode_wptr npc : _armyNPCs[0]) {
192 - assert(npc.lock());
193 - npc.lock()->get<UnitComponent>()->getUnit<NPC>()->playNextAnimation();
191 + for (SceneGraphNode* npc : _armyNPCs[0]) {
192 + assert(npc);
193 + npc->get<UnitComponent>()->getUnit<NPC>()->playNextAnimation();
194 194 }
195 195 _taskTimers[1] = 0.0;
196 196 }
197 197
198 198 if (_taskTimers[2] >= AnimationTimer2) {
199 - for (SceneGraphNode_wptr npc : _armyNPCs[1]) {
200 - assert(npc.lock());
201 - npc.lock()->get<UnitComponent>()->getUnit<NPC>()->playNextAnimation();
199 + for (SceneGraphNode* npc : _armyNPCs[1]) {
200 + assert(npc);
201 + npc->get<UnitComponent>()->getUnit<NPC>()->playNextAnimation();
202 202 }
203 203 _taskTimers[2] = 0.0;
204 204 }
205 205
206 206 if (!initPosSetLight) {
207 207 for (U8 i = 0; i < 16; ++i) {
208 - initPosLight[i].set(_lightNodes[i].lock()->get<TransformComponent>()->getPosition());
208 + initPosLight[i].set(_lightNodes[i]->get<TransformComponent>()->getPosition());
209 209 }
210 210 for (U8 i = 0; i < 80; ++i) {
211 - initPosLight2[i].set(_lightNodes2[i].first.lock()->get<TransformComponent>()->getPosition());
211 + initPosLight2[i].set(_lightNodes2[i].first->get<TransformComponent>()->getPosition());
212 212 }
213 213 initPosSetLight = true;
214 214 }
  @@ -227,7 +227,7 @@
227 227 for (U8 i = 0; i < 16; ++i) {
228 228 F32 c = i % 2 == 0 ? c1 : c2;
229 229 F32 s = i % 2 == 0 ? s1 : s2;
230 - SceneGraphNode_ptr light = _lightNodes[i].lock();
230 + SceneGraphNode* light = _lightNodes[i];
231 231 TransformComponent* tComp = light->get<TransformComponent>();
232 232 tComp->setPositionX(radius * c + initPosLight[i].x);
233 233 tComp->setPositionZ(radius * s + initPosLight[i].z);
  @@ -235,7 +235,7 @@
235 235 }
236 236
237 237 for (U8 i = 0; i < 80; ++i) {
238 - SceneGraphNode_ptr light = _lightNodes2[i].first.lock();
238 + SceneGraphNode* light = _lightNodes2[i].first;
239 239 TransformComponent* tComp = light->get<TransformComponent>();
240 240 F32 angle = _lightNodes2[i].second ? std::fmod(phiLight + 45.0f, 360.0f) : phiLight;
241 241 vec2<F32> position(rotatePoint(vec2<F32>(0.0f), angle, initPosLight2[i].xz()));
  @@ -244,7 +244,7 @@
244 244 }
245 245
246 246 for (U8 i = 0; i < 40; ++i) {
247 - SceneGraphNode_ptr light = _lightNodes3[i].lock();
247 + SceneGraphNode* light = _lightNodes3[i];
248 248 TransformComponent* tComp = light->get<TransformComponent>();
249 249 tComp->rotateY(phiLight);
250 250 }
  @@ -272,10 +272,10 @@
272 272
273 273 _targetLines->paused(!renderState().isEnabledOption(SceneRenderState::RenderOptions::RENDER_DEBUG_TARGET_LINES));
274 274
275 - SceneGraphNode_ptr particles = _particleEmitter.lock();
275 + SceneGraphNode* particles = _particleEmitter;
276 276 const F32 radius = 20;
277 277
278 - if (particles.get()) {
278 + if (particles) {
279 279 phi += 0.01f;
280 280 if (phi > 360.0f) {
281 281 phi = 0.0f;
  @@ -293,7 +293,7 @@
293 293 tComp->rotateY(phi);*/
294 294 }
295 295
296 - if (!_aiManager->getNavMesh(_armyNPCs[0][0].lock()->get<UnitComponent>()->getUnit<NPC>()->getAIEntity()->getAgentRadiusCategory())) {
296 + if (!_aiManager->getNavMesh(_armyNPCs[0][0]->get<UnitComponent>()->getUnit<NPC>()->getAIEntity()->getAgentRadiusCategory())) {
297 297 return;
298 298 }
299 299
  @@ -304,9 +304,9 @@
304 304 vectorImpl<Line> paths;
305 305 paths.reserve(_armyNPCs[0].size() + _armyNPCs[1].size());
306 306 for (U8 i = 0; i < 2; ++i) {
307 - for (SceneGraphNode_wptr node : _armyNPCs[i]) {
308 - AI::AIEntity* const character = node.lock()->get<UnitComponent>()->getUnit<NPC>()->getAIEntity();
309 - if (!node.lock()->isActive()) {
307 + for (SceneGraphNode* node : _armyNPCs[i]) {
308 + AI::AIEntity* const character = node->get<UnitComponent>()->getUnit<NPC>()->getAIEntity();
309 + if (!node->isActive()) {
310 310 continue;
311 311 }
312 312 tempDestination.set(character->getDestination());
  @@ -347,16 +347,16 @@
347 347 Camera::utilityCamera(Camera::UtilityCamera::DEFAULT)->setEye(vec3<F32>(43.13f, 147.09f, -4.41f));
348 348 Camera::utilityCamera(Camera::UtilityCamera::DEFAULT)->setGlobalRotation(-90.0f /*yaw*/, 59.21f /*pitch*/);
349 349
350 - _sun.lock()->getNode<DirectionalLight>()->csmSplitCount(3); // 3 splits
351 - _sun.lock()->getNode<DirectionalLight>()->csmSplitLogFactor(0.85f);
352 - _sun.lock()->getNode<DirectionalLight>()->csmNearClipOffset(25.0f);
350 + _sun->getNode<DirectionalLight>()->csmSplitCount(3); // 3 splits
351 + _sun->getNode<DirectionalLight>()->csmSplitLogFactor(0.85f);
352 + _sun->getNode<DirectionalLight>()->csmNearClipOffset(25.0f);
353 353 // Add some obstacles
354 - SceneGraphNode_ptr cylinder[5];
355 - cylinder[0] = _sceneGraph->findNode("cylinderC").lock();
356 - cylinder[1] = _sceneGraph->findNode("cylinderNW").lock();
357 - cylinder[2] = _sceneGraph->findNode("cylinderNE").lock();
358 - cylinder[3] = _sceneGraph->findNode("cylinderSW").lock();
359 - cylinder[4] = _sceneGraph->findNode("cylinderSE").lock();
354 + SceneGraphNode* cylinder[5];
355 + cylinder[0] = _sceneGraph->findNode("cylinderC");
356 + cylinder[1] = _sceneGraph->findNode("cylinderNW");
357 + cylinder[2] = _sceneGraph->findNode("cylinderNE");
358 + cylinder[3] = _sceneGraph->findNode("cylinderSW");
359 + cylinder[4] = _sceneGraph->findNode("cylinderSE");
360 360
361 361 for (U8 i = 0; i < 5; ++i) {
362 362 RenderingComponent* const renderable = cylinder[i]->getChild(0).get<RenderingComponent>();
  @@ -375,7 +375,7 @@
375 375
376 376 stringImpl currentName;
377 377 std::shared_ptr<SceneNode> currentMesh;
378 - SceneGraphNode_ptr baseNode;
378 + SceneGraphNode* baseNode;
379 379
380 380 U8 locationFlag = 0;
381 381 std::pair<I32, I32> currentPos;
  @@ -412,7 +412,7 @@
412 412 locationFlag = 3;
413 413 }
414 414
415 - SceneGraphNode_ptr crtNode = _sceneGraph->getRoot().addNode(currentMesh, normalMask, baseNode->get<RigidBodyComponent>()->physicsGroup(), currentName);
415 + SceneGraphNode* crtNode = _sceneGraph->getRoot().addNode(currentMesh, normalMask, baseNode->get<RigidBodyComponent>()->physicsGroup(), currentName);
416 416 crtNode->setSelectable(true);
417 417 crtNode->usageContext(baseNode->usageContext());
418 418 TransformComponent* tComp = crtNode->get<TransformComponent>();
  @@ -437,7 +437,7 @@
437 437 //light->setCastShadows(i == 0 ? true : false);
438 438 light->setCastShadows(false);
439 439 light->setDiffuseColour(DefaultColours::RANDOM());
440 - SceneGraphNode_ptr lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
440 + SceneGraphNode* lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
441 441 lightSGN->get<TransformComponent>()->setPosition(position + vec3<F32>(0.0f, 8.0f, 0.0f));
442 442 _lightNodes2.push_back(std::make_pair(lightSGN, false));
443 443 }
  @@ -450,7 +450,7 @@
450 450 light->setRange(35.0f);
451 451 light->setCastShadows(false);
452 452 light->setDiffuseColour(DefaultColours::RANDOM());
453 - SceneGraphNode_ptr lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
453 + SceneGraphNode* lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
454 454 lightSGN->get<TransformComponent>()->setPosition(position + vec3<F32>(0.0f, 8.0f, 0.0f));
455 455 _lightNodes2.push_back(std::make_pair(lightSGN, true));
456 456 }
  @@ -464,15 +464,15 @@
464 464 //light->setCastShadows(i == 1 ? true : false);
465 465 light->setCastShadows(false);
466 466 light->setDiffuseColour(DefaultColours::RANDOM());
467 - SceneGraphNode_ptr lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
467 + SceneGraphNode* lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
468 468 lightSGN->get<TransformComponent>()->setPosition(position + vec3<F32>(0.0f, 10.0f, 0.0f));
469 469 lightSGN->get<TransformComponent>()->rotateX(-20);
470 470 _lightNodes3.push_back(lightSGN);
471 471 }
472 472 }
473 473
474 - SceneGraphNode_ptr flag;
475 - flag = _sceneGraph->findNode("flag").lock();
474 + SceneGraphNode* flag;
475 + flag = _sceneGraph->findNode("flag");
476 476 RenderingComponent* const renderable = flag->getChild(0).get<RenderingComponent>();
477 477 renderable->getMaterialInstance()->setDoubleSided(true);
478 478 const Material_ptr& mat = flag->getChild(0).getNode()->getMaterialTpl();
  @@ -482,7 +482,7 @@
482 482
483 483 _flag[0] = _sceneGraph->getRoot().addNode(flagNode, normalMask, flag->get<RigidBodyComponent>()->physicsGroup(), "Team1Flag");
484 484
485 - SceneGraphNode_ptr flag0(_flag[0].lock());
485 + SceneGraphNode* flag0(_flag[0]);
486 486 flag0->setSelectable(false);
487 487 flag0->usageContext(flag->usageContext());
488 488 TransformComponent* flagtComp = flag0->get<TransformComponent>();
  @@ -497,7 +497,7 @@
497 497 flagRComp->getMaterialInstance()->setDiffuse(DefaultColours::BLUE);
498 498
499 499 _flag[1] = _sceneGraph->getRoot().addNode(flagNode, normalMask, flag->get<RigidBodyComponent>()->physicsGroup(), "Team2Flag");
500 - SceneGraphNode_ptr flag1(_flag[1].lock());
500 + SceneGraphNode* flag1(_flag[1]);
501 501 flag1->setSelectable(false);
502 502 flag1->usageContext(flag->usageContext());
503 503
  @@ -512,7 +512,7 @@
512 512
513 513 flagRComp->getMaterialInstance()->setDiffuse(DefaultColours::RED);
514 514
515 - SceneGraphNode_ptr firstPersonFlag = _sceneGraph->getRoot().addNode(flagNode, normalMask, PhysicsGroup::GROUP_KINEMATIC, "FirstPersonFlag");
515 + SceneGraphNode* firstPersonFlag = _sceneGraph->getRoot().addNode(flagNode, normalMask, PhysicsGroup::GROUP_KINEMATIC, "FirstPersonFlag");
516 516 firstPersonFlag->lockVisibility(true);
517 517 firstPersonFlag->usageContext(SceneGraphNode::UsageContext::NODE_DYNAMIC);
518 518 flagtComp = firstPersonFlag->get<TransformComponent>();
  @@ -574,7 +574,7 @@
574 574 particleSource->addGenerator(timeGenerator);
575 575
576 576 _particleEmitter = addParticleEmitter("TESTPARTICLES", particles, _sceneGraph->getRoot());
577 - SceneGraphNode_ptr testSGN = _particleEmitter.lock();
577 + SceneGraphNode* testSGN = _particleEmitter;
578 578 std::shared_ptr<ParticleEmitter> test = testSGN->getNode<ParticleEmitter>();
579 579 testSGN->get<TransformComponent>()->translateY(10);
580 580 test->setDrawImpostor(true);
  @@ -604,7 +604,7 @@
604 604 light->setRange(20.0f);
605 605 light->setCastShadows(false);
606 606 light->setDiffuseColour(DefaultColours::RANDOM());
607 - SceneGraphNode_ptr lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
607 + SceneGraphNode* lightSGN = _sceneGraph->getRoot().addNode(light, lightMask, PhysicsGroup::GROUP_IGNORE);
608 608 lightSGN->get<TransformComponent>()->setPosition(vec3<F32>(-215.0f + (115 * row), 15.0f, (-215.0f + (115 * col))));
609 609 _lightNodes.push_back(lightSGN);
610 610 }
  @@ -685,7 +685,7 @@
685 685 }
686 686
687 687 PlayerIndex idx = getPlayerIndexForDevice(param._deviceIndex);
688 - if (!_currentSelection[idx].expired()) {
688 + if (_currentSelection[idx]) {
689 689 if (flyCameraActive) {
690 690 state().playerState(idx).overrideCamera(tpsCamera);
691 691 static_cast<ThirdPersonCamera&>(*tpsCamera).setTarget(_currentSelection[idx]);