feat(editor): in-editor "Snap All Spawns to Ground" menu

Adds EditorApp::snapAllSpawnsToGround() and a menu item under
Generate, mirroring the --snap-zone-to-ground CLI for users who
want the action without context-switching to a terminal.

Walks every NPC + object, casts a downward ray from baseZ+500y,
and writes the hit Z into spawn.position.z. Patrol waypoints on
each NPC are snapped too. Marks the project dirty + auto-save
pending so the change persists without a manual Ctrl+S.

Existing per-selection "Snap Ground" button on the right panel is
unchanged; this is the bulk version for "I just edited terrain
under a populated area."
This commit is contained in:
Kelsi 2026-05-07 14:12:39 -07:00
parent f589fa20ce
commit f870a516dd
3 changed files with 50 additions and 0 deletions

View file

@ -395,6 +395,14 @@ void EditorUI::renderMenuBar(EditorApp& app) {
"Same seed → same population (reproducible)");
ImGui::EndMenu();
}
if (ImGui::MenuItem("Snap All Spawns to Ground", nullptr, false,
app.hasTerrainLoaded())) {
app.snapAllSpawnsToGround();
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip(
"Re-snap every creature + object's Z to actual terrain height.\n"
"Run after terrain edits to fix floating/buried spawns.");
if (ImGui::MenuItem("Clear All Objects/NPCs", nullptr, false, app.hasTerrainLoaded())) {
if (app.getObjectPlacer().objectCount() > 0 || app.getNpcSpawner().spawnCount() > 0)
app.clearAllObjects();