From c10fadbfc9414d381edc92f2b91cddaec52295a7 Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 22 Jun 2026 23:38:28 +0200 Subject: [PATCH] Reset transform stack before the visual load pass Defensive fix: when starting the deferred visual pass, clear the origin/scale stacks and rotation before the directives are replayed. A scenery that leaves an unbalanced origin on the stack during the infrastructure pass would otherwise have it applied a second time, shifting every deferred visual node. Balanced sceneries (the common case) are unaffected -- the directives rebuild the same state. Co-Authored-By: Claude Opus 4.8 --- simulation/simulationstateserializer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index 58fdfd44..7e640af9 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -172,6 +172,14 @@ state_serializer::deserialize_continue(std::shared_ptr state if( ( false == state->visualphase ) && ( true == Input.restartReplay( scene::scenery_load_pass::visual ) ) ) { state->visualphase = true; + // rebuild the transform state from scratch for the visual pass: the directives + // (origin/rotate/scale) are replayed in order, so resetting here reproduces the + // single-pass placement exactly. without this, an unbalanced origin left on the + // stack by the infrastructure pass would be applied a second time and shift every + // deferred visual node ("terrain dumped next to the tracks"). + Scratchpad.location.offset = {}; + Scratchpad.location.scale = {}; + Scratchpad.location.rotation = glm::vec3{}; return false; // infrastructure ready -> go to driver; visuals continue there }