New Undo/Redo commands + Integration of editor camera arm #198
|
@ -63,14 +63,6 @@ namespace SHADE
|
|||
}
|
||||
|
||||
UpdateCameraComponent(editorCamera);
|
||||
|
||||
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
|
||||
|
|
|
@ -33,14 +33,32 @@ namespace SHADE
|
|||
void SHEditorViewport::Update()
|
||||
{
|
||||
SHEditorWindow::Update();
|
||||
if (shouldUpdateCamera)
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
SHEditor* editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
|
||||
if (!editor->selectedEntities.empty())
|
||||
{
|
||||
if (SHTransformComponent* transform = SHComponentManager::GetComponent_s<SHTransformComponent>(editor->selectedEntities.front()))
|
||||
{
|
||||
targetPos = transform->GetWorldPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPos = {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPos = {};
|
||||
}
|
||||
if (shouldUpdateCamera || shouldUpdateCamArm)
|
||||
{
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
camSystem->UpdateEditorCamera(SHFrameRateController::GetRawDeltaTime());
|
||||
shouldUpdateCamera = false;
|
||||
}
|
||||
camSystem->UpdateEditorArm(SHFrameRateController::GetRawDeltaTime(), shouldUpdateCamArm, targetPos);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
SHEditor* editor = SHSystemManager::GetSystem<SHEditor>();
|
||||
|
||||
if (Begin())
|
||||
{
|
||||
|
@ -64,6 +82,9 @@ namespace SHADE
|
|||
|
||||
shouldUpdateCamera = true;
|
||||
}
|
||||
|
||||
shouldUpdateCamArm = ImGui::IsWindowHovered() && ImGui::IsKeyDown(ImGuiKey_LeftAlt) && ImGui::IsMouseDown(ImGuiMouseButton_Left);
|
||||
|
||||
if (editor->editorState != SHEditor::State::PLAY && ImGui::IsWindowFocused() && !ImGui::IsMouseDown(ImGuiMouseButton_Right))
|
||||
{
|
||||
if (ImGui::IsKeyReleased(ImGuiKey_W))
|
||||
|
|
|
@ -29,5 +29,7 @@ namespace SHADE
|
|||
void DrawMenuBar() noexcept;
|
||||
SHVec2 beginCursorPos;
|
||||
bool shouldUpdateCamera = false;
|
||||
bool shouldUpdateCamArm = false;
|
||||
SHVec3 targetPos;
|
||||
};//class SHEditorViewport
|
||||
}//namespace SHADE
|
||||
|
|
Loading…
Reference in New Issue