mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): center on terrain (Home key), navigation improvements
- "Center on Terrain" (Home key or View menu): resets camera to center of loaded tile at 300 units altitude with 45-degree downward pitch. Essential for recovering when camera gets lost in empty space. - Toast confirmation on center action
This commit is contained in:
parent
2b0a81fd9a
commit
434fdf6c7f
3 changed files with 12 additions and 0 deletions
|
|
@ -206,6 +206,7 @@ void EditorApp::processEvents() {
|
|||
auto sc = event.key.keysym.scancode;
|
||||
if (sc == SDL_SCANCODE_F3) setWireframe(!isWireframe());
|
||||
if (sc == SDL_SCANCODE_F5) saveBookmark("");
|
||||
if (sc == SDL_SCANCODE_HOME) centerOnTerrain();
|
||||
// Number keys switch modes (when not typing in ImGui)
|
||||
if (!io.WantCaptureKeyboard) {
|
||||
if (sc == SDL_SCANCODE_1) setMode(EditorMode::Sculpt);
|
||||
|
|
@ -788,6 +789,15 @@ void EditorApp::flyToSelected() {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorApp::centerOnTerrain() {
|
||||
if (!terrain_.isLoaded()) return;
|
||||
float centerX = (32.0f - loadedTileY_) * 533.33333f - 8.0f * 533.33333f / 16.0f;
|
||||
float centerY = (32.0f - loadedTileX_) * 533.33333f - 8.0f * 533.33333f / 16.0f;
|
||||
camera_.setPosition(glm::vec3(centerX, centerY, terrain_.chunks[0].position[2] + 300.0f));
|
||||
camera_.setYawPitch(0.0f, -45.0f);
|
||||
showToast("Camera centered on terrain");
|
||||
}
|
||||
|
||||
void EditorApp::snapSelectedToGround() {
|
||||
auto* sel = objectPlacer_.getSelected();
|
||||
if (!sel || !terrain_.isLoaded()) return;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public:
|
|||
void setSkyPreset(int preset); // 0=day, 1=dusk, 2=night
|
||||
void snapSelectedToGround();
|
||||
void flyToSelected();
|
||||
void centerOnTerrain();
|
||||
|
||||
// Multi-tile support
|
||||
void addAdjacentTile(int offsetX, int offsetY);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ void EditorUI::renderMenuBar(EditorApp& app) {
|
|||
bool wf = app.isWireframe();
|
||||
if (ImGui::MenuItem("Wireframe", "F3", &wf)) app.setWireframe(wf);
|
||||
if (ImGui::MenuItem("Reset Camera")) app.resetCamera();
|
||||
if (ImGui::MenuItem("Center on Terrain", "Home")) app.centerOnTerrain();
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Sky / Lighting")) {
|
||||
if (ImGui::MenuItem("Day")) app.setSkyPreset(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue