mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 22:59:19 +02:00
Add two-pass progressive scenery load (sequential; infra then visuals)
When replaying a binary twin, load in two passes over the same data: the first pass loads infrastructure (tracks/traction/events/memcells/sounds + directives), the second pass loads the visual nodes (3d models, terrain shapes/lines) that the reader skipped via the v6 node-class markers. - cParser: setReplayPass() selects the served node class (propagated to include children); restartReplay() rewinds the twin for the second pass. - state_serializer: first pass uses the infrastructure pass; on completion it restarts the twin for the visual pass. Stateful directives (trainset, event, camera, light, sky, time, ...) are skipped on the visual pass so their side effects do not duplicate; transform/group directives re-run so deferred visual nodes get correct placement. A text/compile load (no twin) stays single-pass. Verified: td.scn replays through both passes with no duplicate vehicles/events and reaches the normal load endpoint. This is the sequential foundation; moving the visual pass into the driver (so play starts after the infrastructure pass) is the next step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
// before cParser is defined.
|
||||
namespace scene {
|
||||
enum class scenery_file_kind : std::uint8_t;
|
||||
enum class scenery_load_pass : std::uint8_t;
|
||||
class scenery_binary_writer;
|
||||
class scenery_binary_reader;
|
||||
}
|
||||
@@ -46,6 +47,13 @@ class cParser //: public std::stringstream
|
||||
// touching scene state, and return the (relative) filenames it includes so a parallel
|
||||
// baker can compile each of those twins on its own thread. requires BakeOnly ctor.
|
||||
std::vector<std::string> bakeFile();
|
||||
// select which class of nodes the replay serves (propagated to include children).
|
||||
// only meaningful in replay (twin) mode; ignored for text parsing.
|
||||
void setReplayPass( scene::scenery_load_pass Pass );
|
||||
// rewind the replay to the start of the twin with a (possibly new) pass, dropping any
|
||||
// open include child. used to run a second pass (visual) over an already-loaded twin.
|
||||
// returns false if this parser isn't replaying a twin (no second pass possible).
|
||||
bool restartReplay( scene::scenery_load_pass Pass );
|
||||
// methods:
|
||||
template <typename Type_>
|
||||
cParser &
|
||||
@@ -180,6 +188,7 @@ class cParser //: public std::stringstream
|
||||
// replay: this file is served from its binary twin instead of text
|
||||
bool m_replay { false };
|
||||
bool m_replayexhausted { false }; // all twin entries consumed (for inline eof())
|
||||
scene::scenery_load_pass m_replaypass {}; // value-init == scenery_load_pass::all
|
||||
std::string m_twinbuf; // whole twin file held in memory; the reader views into it
|
||||
std::unique_ptr<scene::scenery_binary_reader> m_reader; // streams entries from m_twinbuf
|
||||
// compile: this file is being captured into a binary twin alongside the text read
|
||||
|
||||
Reference in New Issue
Block a user