Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 1020 vs 1021 for /trunk/Source Code/Scenes/Scene.cpp

Diff revisions: vs.
  @@ -460,6 +460,17 @@
460 460 hashAlg::insert(_flashLight,
461 461 idx,
462 462 flashLight);
463 +
464 + _cameraUpdateMap[idx] =
465 + Camera::addUpdateListener([this, idx](const Camera& cam) {
466 + if (idx < _scenePlayers.size() && idx < _flashLight.size() && _flashLight[idx]) {
467 + if (cam.getGUID() == _scenePlayers[getSceneIndexForPlayer(idx)]->getCamera().getGUID()) {
468 + TransformComponent* tComp = _flashLight[idx]->get<TransformComponent>();
469 + tComp->setPosition(cam.getEye());
470 + tComp->setRotation(cam.getEuler());
471 + }
472 + }
473 + });
463 474
464 475 }
465 476
  @@ -901,7 +912,14 @@
901 912
902 913 input().onPlayerRemove(idx);
903 914 state().onPlayerRemove(idx);
904 -
915 + Camera::removeUpdateListener(_cameraUpdateMap[idx]);
916 + if (_flashLight.size() > idx) {
917 + SceneGraphNode* flashLight = _flashLight[idx];
918 + if (flashLight) {
919 + _sceneGraph->getRoot().removeNode(*flashLight);
920 + _flashLight[idx] = nullptr;
921 + }
922 + }
905 923 _sceneGraph->getRoot().removeNode(*player->getBoundNode());
906 924
907 925 _scenePlayers.erase(std::cbegin(_scenePlayers) + getSceneIndexForPlayer(idx));
  @@ -964,6 +982,7 @@
964 982 bool Scene::mouseMoved(const Input::MouseEvent& arg) {
965 983 // ToDo: Use mapping between device ID an player index -Ionut
966 984 PlayerIndex idx = getPlayerIndexForDevice(arg._deviceIndex);
985 + _hoverUpdateQueue.insert(idx);
967 986
968 987 Camera& cam = _scenePlayers[idx]->getCamera();
969 988 if (cam.moveRelative(arg.relativePos()))
  @@ -1020,16 +1039,10 @@
1020 1039 _sceneGraph->sceneUpdate(deltaTimeUS, *_sceneState);
1021 1040 _aiManager->update(deltaTimeUS);
1022 1041
1023 - for (U8 i = 0; i < to_U8(_scenePlayers.size()); ++i) {
1024 - PlayerIndex idx = _scenePlayers[i]->index();
1042 + for(PlayerIndex idx : _hoverUpdateQueue) {
1025 1043 findHoverTarget(idx);
1026 - if (_flashLight[idx]) {
1027 - TransformComponent* tComp = _flashLight[idx]->get<TransformComponent>();
1028 - const Camera& cam = _scenePlayers[idx]->getCamera();
1029 - tComp->setPosition(cam.getEye());
1030 - tComp->setRotation(cam.getEuler());
1031 - }
1032 1044 }
1045 + _hoverUpdateQueue.clear();
1033 1046 }
1034 1047
1035 1048 void Scene::onLostFocus() {
  @@ -1081,15 +1094,17 @@
1081 1094 }
1082 1095
1083 1096 void Scene::processGUI(const U64 deltaTimeUS) {
1084 - for (U16 i = 0; i < _guiTimersMS.size(); ++i) {
1085 - _guiTimersMS[i] += Time::MicrosecondsToMilliseconds<D64>(deltaTimeUS);
1086 - }
1097 + D64 delta = Time::MicrosecondsToMilliseconds<D64>(deltaTimeUS);
1098 +
1099 + std::transform(std::begin(_guiTimersMS), std::end(_guiTimersMS), std::begin(_guiTimersMS),
1100 + std::bind1st(std::plus<D64>(), delta));
1087 1101 }
1088 1102
1089 1103 void Scene::processTasks(const U64 deltaTimeUS) {
1090 - for (U16 i = 0; i < _taskTimers.size(); ++i) {
1091 - _taskTimers[i] += Time::MicrosecondsToMilliseconds<D64>(deltaTimeUS);
1092 - }
1104 + D64 delta = Time::MicrosecondsToMilliseconds<D64>(deltaTimeUS);
1105 +
1106 + std::transform(std::begin(_taskTimers), std::end(_taskTimers), std::begin(_taskTimers),
1107 + std::bind1st(std::plus<D64>(), delta));
1093 1108 }
1094 1109
1095 1110 void Scene::debugDraw(const Camera& activeCamera, const RenderStagePass& stagePass, GFX::CommandBuffer& bufferInOut) {