Added code to test EditorCameraArm.
This commit is contained in:
parent
922d5b0996
commit
efed33ce94
|
@ -7,13 +7,15 @@
|
|||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
#include <math.h>
|
||||
|
||||
#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 });
|
||||
}
|
||||
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;
|
||||
|
||||
if (editorCameraArm.pitch > pitchClamp)
|
||||
editorCameraArm.pitch = pitchClamp;
|
||||
if (editorCameraArm.pitch < -pitchClamp)
|
||||
editorCameraArm.pitch = -pitchClamp;
|
||||
|
||||
editorCameraArm.armLength += SHInputManager::GetMouseWheelVerticalDelta() * dt;
|
||||
editorCameraArm.armLength -= SHInputManager::GetMouseWheelVerticalDelta() * dt;
|
||||
|
||||
if (editorCameraArm.armLength < 1.0f)
|
||||
editorCameraArm.armLength = 1.0f;
|
||||
|
@ -281,11 +286,13 @@ namespace SHADE
|
|||
|
||||
for (auto& pivot : pivotDense)
|
||||
{
|
||||
if(SHSceneManager::CheckNodeAndComponentsActive<SHCameraArmComponent>(pivot.GetEID()))
|
||||
system->UpdatePivotArmComponent(pivot);
|
||||
}
|
||||
|
||||
for (auto& cam : dense)
|
||||
{
|
||||
if (SHSceneManager::CheckNodeAndComponentsActive<SHCameraComponent>(cam.GetEID()))
|
||||
system->UpdateCameraComponent(cam);
|
||||
}
|
||||
for (auto& handle : system->directorHandleList)
|
||||
|
|
Loading…
Reference in New Issue