Reworked editor camera

This commit is contained in:
antopilo
2023-03-07 17:26:13 -05:00
parent 10baf5271a
commit 6cbad0e13b
20 changed files with 126 additions and 114 deletions

View File

@@ -0,0 +1,30 @@
#pragma once
#include "ComponentPanel.h"
#include <src/Scene/Components/RigidbodyComponent.h>
#include <src/Core/FileSystem.h>
class RigidbodyPanel : ComponentPanel {
public:
RigidbodyPanel() {}
void Draw(Nuake::Entity entity) override
{
if (!entity.HasComponent<Nuake::RigidBodyComponent>())
return;
auto& component = entity.GetComponent<Nuake::RigidBodyComponent>();
BeginComponentTable(RIGIDBODY, Nuake::RigidBodyComponent);
{
{
ImGui::Text("Mass");
ImGui::TableNextColumn();
ImGui::DragFloat("##Mass", &component.Mass, 0.1f, 0.1f);
ImGui::TableNextColumn();
ComponentTableReset(component.Mass, 0.0f);
}
}
EndComponentTable();
}
};

View File

@@ -1406,7 +1406,12 @@ namespace Nuake {
if (entityIsSelected && Input::IsKeyPressed(GLFW_KEY_F))
{
editorCam->IsMoving = true;
editorCam->TargetPos = Vector3(0, 0, 0);
editorCam->TargetPos = Selection.Entity.GetComponent<TransformComponent>().GetGlobalPosition();
}
if (entityIsSelected && Input::IsKeyPressed(GLFW_KEY_ESCAPE))
{
Selection = EditorSelection();
}
}

View File

@@ -14,6 +14,7 @@ EditorSelectionPanel::EditorSelectionPanel()
mScriptPanel = ScriptPanel();
mQuakeMapPanel = QuakeMapPanel();
mCameraPanel = CameraPanel();
mRigidbodyPanel = RigidbodyPanel();
}
void EditorSelectionPanel::ResolveFile(Ref<Nuake::File> file)
@@ -96,6 +97,8 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
mMeshPanel.Draw(entity);
mQuakeMapPanel.Draw(entity);
mCameraPanel.Draw(entity);
mRigidbodyPanel.Draw(entity);
/*
if (Selection.Entity.HasComponent<MeshComponent>())
{

View File

@@ -9,6 +9,7 @@
#include "../ComponentsPanel/MeshPanel.h"
#include "../ComponentsPanel/QuakeMapPanel.h"
#include "../ComponentsPanel/CameraPanel.h"
#include "../ComponentsPanel/RigidbodyPanel.h"
#include "../Actions/EditorSelection.h"
#include <src/Resource/Project.h>
@@ -21,6 +22,7 @@ private:
MeshPanel mMeshPanel;
QuakeMapPanel mQuakeMapPanel;
CameraPanel mCameraPanel;
RigidbodyPanel mRigidbodyPanel;
Ref<Nuake::File> currentFile;
Ref<Nuake::Resource> selectedResource;