mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03: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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue