16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

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 <noreply@anthropic.com>
This commit is contained in:
maj00r
2026-06-22 23:38:28 +02:00
parent 512595234f
commit c10fadbfc9

View File

@@ -172,6 +172,14 @@ state_serializer::deserialize_continue(std::shared_ptr<deserializer_state> 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
}