From b49cb344ac638c4bebe1eb9d4052a01b6d3899bd Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 01:30:27 -0700 Subject: [PATCH] feat(editor): NPC context menu adds Snap to Ground and Face Camera Right-click context menu on a selected NPC now mirrors the object menu: Snap to Ground drops it to terrain elevation, Face Camera rotates the NPC to face the current camera position. Also annotates Duplicate with the Ctrl+D shortcut hint. --- tools/editor/editor_ui.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_ui.cpp b/tools/editor/editor_ui.cpp index ab2b551e..7e5f679a 100644 --- a/tools/editor/editor_ui.cpp +++ b/tools/editor/editor_ui.cpp @@ -2300,12 +2300,21 @@ void EditorUI::renderContextMenu(EditorApp& app) { if (npcSel) { if (ImGui::MenuItem("Fly To")) app.flyToSelected(); - if (ImGui::MenuItem("Duplicate")) { + if (ImGui::MenuItem("Snap to Ground")) + app.snapSelectedToGround(); + if (ImGui::MenuItem("Duplicate", "Ctrl+D")) { CreatureSpawn copy = *npcSel; copy.position += glm::vec3(10, 10, 0); app.getNpcSpawner().placeCreature(copy); app.markObjectsDirty(); } + if (ImGui::MenuItem("Face Camera")) { + glm::vec3 cam = app.getEditorCamera().getCamera().getPosition(); + glm::vec3 to = cam - npcSel->position; + npcSel->orientation = glm::degrees(std::atan2(to.y, to.x)); + if (npcSel->orientation < 0.0f) npcSel->orientation += 360.0f; + app.markObjectsDirty(); + } } ImGui::Separator();