diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 62750d16..8f886926 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -7,13 +7,15 @@ #include "ECS_Base/Managers/SHComponentManager.h" #include "Math/Transform/SHTransformComponent.h" #include - +#include "Scene/SHSceneManager.h" namespace SHADE { void SHCameraSystem::UpdateEditorCamera(double dt) noexcept { + + auto& camera = editorCamera; SHVec3 view, right, UP; GetCameraAxis(camera, view, right, UP); @@ -60,17 +62,15 @@ namespace SHADE camera.dirtyView = true; } - - - UpdateCameraComponent(editorCamera); - - if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::LEFT_ALT)) + if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::LEFT_ALT)) { UpdateEditorArm(dt, true, SHVec3{ 0.0f }); } - UpdateEditorArm(dt, false, SHVec3{ 0.0f }); + else + UpdateEditorArm(dt, false, SHVec3{ 0.0f }); + } void SHCameraSystem::UpdateEditorArm(double dt,bool active ,SHVec3 const& targetPos) noexcept @@ -81,16 +81,21 @@ namespace SHADE return; } - + editorCamera.SetPosition(targetPos); double mouseX, mouseY; SHInputManager::GetMouseVelocity(&mouseX, &mouseY); editorCameraArm.pitch -= mouseY * dt * editorCamera.turnSpeed.x; editorCameraArm.yaw -= mouseX * dt * editorCamera.turnSpeed.y; - + constexpr float pitchClamp = 85.0f; - editorCameraArm.armLength += SHInputManager::GetMouseWheelVerticalDelta() * dt; + if (editorCameraArm.pitch > pitchClamp) + editorCameraArm.pitch = pitchClamp; + if (editorCameraArm.pitch < -pitchClamp) + editorCameraArm.pitch = -pitchClamp; + + editorCameraArm.armLength -= SHInputManager::GetMouseWheelVerticalDelta() * dt; if (editorCameraArm.armLength < 1.0f) editorCameraArm.armLength = 1.0f; @@ -281,12 +286,14 @@ namespace SHADE for (auto& pivot : pivotDense) { - system->UpdatePivotArmComponent(pivot); + if(SHSceneManager::CheckNodeAndComponentsActive(pivot.GetEID())) + system->UpdatePivotArmComponent(pivot); } for (auto& cam : dense) { - system->UpdateCameraComponent(cam); + if (SHSceneManager::CheckNodeAndComponentsActive(cam.GetEID())) + system->UpdateCameraComponent(cam); } for (auto& handle : system->directorHandleList) {