From c30b1f9b2f5d231e98194db526560eb4e010edff Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 15 Jan 2024 18:20:58 -0500 Subject: major refactor so cameras are entities and have a rigid body instance --- editor/editor.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'editor') diff --git a/editor/editor.cpp b/editor/editor.cpp index a081fb0..6ce8f76 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -681,9 +681,15 @@ void RecordImGuiCameras() { return; } if (ImGui::Button("Create")) { - auto &cam = PkeCamera_Register(); - cam.pos = ActiveCamera->pos; - cam.rot = ActiveCamera->rot; + InstPos instPos{}; + btVector3 pos; + btQuaternion quat; + GlmToBullet(ActiveCamera->pos, pos); + GlmToBullet(ActiveCamera->rot, quat); + instPos.mass = 1.f; + instPos.posRot.setOrigin(pos); + instPos.posRot.setRotation(quat); + auto &cam = PkeCamera_Register(instPos); cam.target = ActiveCamera->target; cam.type = ActiveCamera->type; cam.orientation = ActiveCamera->orientation; @@ -719,11 +725,15 @@ void RecordImGuiCameras() { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::BeginDisabled(selectedCamera == cam.handle); - if (ImGui::Button("Select")) { - selectedCamera = cam.handle; + if (ImGui::Button("Show")) { + selectedCamera = cam.camHandle; ActiveCamera = const_cast(&cam); ActiveCamera->stale = PKE_CAMERA_STALE_ALL; } + ImGui::SameLine(); + if (ImGui::Button("Select")) { + selectedEntity = cam.phys.inst; + } ImGui::EndDisabled(); ImGui::TableSetColumnIndex(1); ImGui::Text("0x%016lX", cam.handle.hash); -- cgit v1.2.3