Merge pull request #408 from SHADE-DP/SP3-4-Editor

Fixed window width for physics settings drop down, fixed editor look at, fixed crash when some fields set to 0
This commit is contained in:
XiaoQiDigipen 2023-03-09 16:00:34 +08:00 committed by GitHub
commit 636bf6ec43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 7 deletions

View File

@ -454,7 +454,8 @@ namespace SHADE
{
if(auto entityTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(eid))
{
editorCam->SetPosition(entityTransform->GetWorldPosition() + SHVec3(0.5f));
SHVec3 scale = entityTransform->GetLocalScale();
editorCam->SetPosition(entityTransform->GetWorldPosition() + scale * 0.5f);
camSystem->CameraLookAt(*editorCam, entityTransform->GetWorldPosition());
camSystem->UpdateEditorCamera(SHFrameRateController::GetRawDeltaTime());
}

View File

@ -273,8 +273,8 @@ namespace SHADE
}
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
{
SHEditorWidgets::DragFloat("Drag", [component] {return component->GetDrag(); }, [component](float const& value) {component->SetDrag(value); }, "Drag");
SHEditorWidgets::DragFloat("Angular Drag", [component] {return component->GetAngularDrag(); }, [component](float const& value) {component->SetAngularDrag(value); }, "Angular Drag");
SHEditorWidgets::DragFloat("Drag", [component] {return component->GetDrag(); }, [component](float const& value) {component->SetDrag(value); }, "Drag", 0.1f, 0.0001f, std::numeric_limits<float>::infinity());
SHEditorWidgets::DragFloat("Angular Drag", [component] {return component->GetAngularDrag(); }, [component](float const& value) {component->SetAngularDrag(value); }, "Angular Drag", 0.1f, 0.0001f, std::numeric_limits<float>::infinity());
SHEditorWidgets::CheckBox("Interpolate", [component] {return component->IsInterpolating(); }, [component](bool const& value) {component->SetInterpolate(value); }, "Interpolate");
@ -377,7 +377,8 @@ namespace SHADE
(
"Radius",
[sphereShape] { return sphereShape->GetRelativeRadius(); },
[sphereShape](float const& value) { sphereShape->SetRelativeRadius(value); }
[sphereShape](float const& value) { sphereShape->SetRelativeRadius(value); }, "Collider Radius", 0.1f,
0.0001f, std::numeric_limits<float>::infinity()
);
}
else if (collisionShape->GetType() == SHCollisionShape::Type::CAPSULE)
@ -388,13 +389,15 @@ namespace SHADE
(
"Radius",
[capsuleShape] { return capsuleShape->GetRelativeRadius(); },
[capsuleShape](float const& value) { capsuleShape->SetRelativeRadius(value); }
[capsuleShape](float const& value) { capsuleShape->SetRelativeRadius(value); }, "Collider Radius", 0.1f,
0.0001f, std::numeric_limits<float>::infinity()
);
SHEditorWidgets::DragFloat
(
"Height",
[capsuleShape] { return capsuleShape->GetRelativeHeight(); },
[capsuleShape](float const& value) { capsuleShape->SetRelativeHeight(value); }
[capsuleShape](float const& value) { capsuleShape->SetRelativeHeight(value); }, "Collider Height", 0.1f,
0.0001f, std::numeric_limits<float>::infinity()
);
}

View File

@ -26,6 +26,8 @@
#include "SHEditorComponentView.h"
#include "AudioSystem/SHAudioListenerComponent.h"
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
#include "Camera/SHCameraSystem.h"
#include "FRC/SHFramerateController.h"
namespace SHADE
{
@ -106,6 +108,7 @@ namespace SHADE
{
if (editor && !editor->selectedEntities.empty())
{
DrawMenuBar();
EntityID const& eid = editor->selectedEntities[0];
SHEntity* entity = SHEntityManager::GetEntityByID(eid);
SHSceneNode* entityNode = SHSceneManager::GetCurrentSceneGraph().GetNode(eid);
@ -114,6 +117,7 @@ namespace SHADE
ImGui::End();
return;
}
ImGui::TextColored(ImGuiColors::green, "EID: %zu", eid);
SHEditorWidgets::CheckBox("##IsActive", [entityNode]()->bool {return entityNode->IsActive(); }, [entityNode](bool const& active) {entityNode->SetActive(active); });
ImGui::SameLine();
@ -222,4 +226,36 @@ namespace SHADE
{
SHEditorWindow::Exit();
}
void SHEditorInspector::DrawMenuBar()
{
if(ImGui::BeginMenuBar())
{
EntityID const& eid = editor->selectedEntities[0];
SHEntity* entity = SHEntityManager::GetEntityByID(eid);
SHSceneNode* entityNode = SHSceneManager::GetCurrentSceneGraph().GetNode(eid);
if (!entity || !entityNode)
{
ImGui::EndMenuBar();
return;
}
if (ImGui::SmallButton("Look At"))
{
editor->selectedEntities.clear();
editor->selectedEntities.push_back(eid);
if (auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>())
{
if (auto editorCam = camSystem->GetEditorCamera())
{
if (auto entityTransform = SHComponentManager::GetComponent_s<SHTransformComponent>(eid))
{
editorCam->SetPosition(entityTransform->GetWorldPosition() + SHVec3(0.5f));
camSystem->CameraLookAt(*editorCam, entityTransform->GetWorldPosition());
camSystem->UpdateEditorCamera(SHFrameRateController::GetRawDeltaTime());
}
}
}
}
ImGui::EndMenuBar();
}
}
}

View File

@ -25,6 +25,6 @@ namespace SHADE
void Exit() override;
private:
void DrawMenuBar();
};
}

View File

@ -358,6 +358,7 @@ namespace SHADE
void SHEditorMenuBar::DrawPhysicsSettings() noexcept
{
ImGui::SetNextWindowSize({400.0f, 0.0f});
if (ImGui::BeginMenu("Physics Settings"))
{
if (auto* physicsSystem = SHSystemManager::GetSystem<SHPhysicsSystem>())

View File

@ -669,6 +669,12 @@ namespace SHADE
SaveScene();
}
}
if(editorState == State::PLAY && ImGui::IsKeyReleased(ImGuiKey_LeftAlt))
{
SHInputManager::SetMouseCentering(!SHInputManager::GetMouseCentering());
SHWindow::SetMouseVisible(!SHWindow::GetMouseVisible());
}
if (ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z))
{
SHCommandManager::RedoCommand();