fix(editor): stop destructive M2 rebuild on every NPC click, fix Clear All

Root cause of GPU crashes (VK_ERROR_DEVICE_LOST): every NPC placement
triggered a full clear+reload of ALL M2 models. After several cycles
the GPU state corrupted, causing vertex explosions and device lost.

Fixes:
- NPC placement now only updates cheap marker geometry (no M2 reload)
- Full M2 rebuild only happens when object COUNT changes (not every click)
- clearAllObjects() properly resets viewport, placer, spawner, markers,
  and history in one call with vkDeviceWaitIdle fence
- New Terrain uses clearAllObjects() for consistent reset
- Clear All menu item calls clearAllObjects()
- M2 vertex validation: rejects models with NaN/infinite/extreme
  vertex positions before GPU upload (prevents vertex explosions)
- NPC marker building extracted to updateNpcMarkers() method
  (can be called independently without M2 rebuild)
This commit is contained in:
Kelsi 2026-05-05 07:07:33 -07:00
parent 1c58911da0
commit c60ddcfed4
5 changed files with 103 additions and 73 deletions

View file

@ -103,12 +103,7 @@ void EditorUI::renderMenuBar(EditorApp& app) {
ImGui::EndMenu();
}
if (ImGui::MenuItem("Clear All Objects/NPCs", nullptr, false, app.hasTerrainLoaded())) {
app.getObjectPlacer().clearAll();
app.getNpcSpawner().clearSelection();
app.getNpcSpawner().getSpawns().clear();
app.getTerrainEditor().history().clear();
app.markObjectsDirty();
app.showToast("All objects and NPCs cleared");
app.clearAllObjects();
}
ImGui::Separator();
if (ImGui::MenuItem("Quick Save", "Ctrl+S", false, app.hasTerrainLoaded()))