mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 15:59:18 +02:00
EU7 scenery format and models streaming
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "simulation/simulationtime.h"
|
||||
#include "simulation/simulationenvironment.h"
|
||||
|
||||
#include "scene/eu7/eu7_loader.h"
|
||||
#include "utilities/Globals.h"
|
||||
#include "world/Event.h"
|
||||
#include "world/MemCell.h"
|
||||
@@ -72,6 +73,16 @@ state_manager::export_as_text( std::string const &Scenariofile ) const {
|
||||
return m_serializer.export_as_text( Scenariofile );
|
||||
}
|
||||
|
||||
bool
|
||||
state_manager::load_eu7_module( std::string const &path ) {
|
||||
return scene::eu7::load_module( path, m_serializer );
|
||||
}
|
||||
|
||||
void
|
||||
state_manager::drain_deferred_eu7_trainsets( double const max_ms ) {
|
||||
m_serializer.drain_deferred_eu7_trainsets( max_ms );
|
||||
}
|
||||
|
||||
void
|
||||
state_manager::init_scripting_interface() {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
@@ -58,6 +58,11 @@ public:
|
||||
// stores class data in specified file, in legacy (text) format
|
||||
void
|
||||
export_as_text( std::string const &Scenariofile ) const;
|
||||
// laduje pelny modul EU7B (wszystkie chunki)
|
||||
bool
|
||||
load_eu7_module( std::string const &Path );
|
||||
void
|
||||
drain_deferred_eu7_trainsets( double MaxMs = 12.0 );
|
||||
|
||||
private:
|
||||
// members
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,11 +9,21 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "utilities/parser.h"
|
||||
#include "scene/eu7/eu7_types.h"
|
||||
#include "scene/scene.h"
|
||||
|
||||
class TModel3d;
|
||||
|
||||
namespace simulation {
|
||||
|
||||
struct eu7_pack_apply_session {
|
||||
std::unordered_map<std::string, TModel3d *> *mesh_cache { nullptr };
|
||||
std::unordered_map<std::string, scene::node_data> *nodedata_cache { nullptr };
|
||||
};
|
||||
|
||||
struct deserializer_state {
|
||||
std::string scenariofile;
|
||||
cParser input;
|
||||
@@ -45,8 +55,89 @@ public:
|
||||
TAnimModel * create_model(std::string const &src, std::string const &name, const glm::dvec3 &position);
|
||||
// create new eventlauncher from node stirng
|
||||
TEventLauncher * create_eventlauncher(std::string const &src, std::string const &name, const glm::dvec3 &position);
|
||||
// parsuje wyemitowany tekst modulu EU7B przez istniejacy dispatch tokenow
|
||||
void
|
||||
deserialize_module_text(
|
||||
std::string const &Text,
|
||||
std::string const &SourceName,
|
||||
scene::scratch_data &Scratchpad );
|
||||
// Fallback SCM/INC gdy brak child .eu7 — normalny parser z include.
|
||||
void
|
||||
deserialize_include_file(
|
||||
std::string const &IncludeReference,
|
||||
std::string const &CurrentRelativeFile,
|
||||
std::vector<std::string> const &Parameters,
|
||||
scene::scratch_data &Scratchpad );
|
||||
// Bezposrednio z Eu7Scene — bez emit/tokenow.
|
||||
void
|
||||
apply_eu7_scene(
|
||||
scene::eu7::Eu7Scene const &Scene,
|
||||
scene::scratch_data &Scratchpad );
|
||||
// Tylko MODL z Eu7Scene — bez TRAK/EVNT/…
|
||||
void
|
||||
apply_eu7_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad );
|
||||
// MODL z chunku PACK (v7) — location/angles juz w world-space.
|
||||
void
|
||||
apply_eu7_pack_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad );
|
||||
void
|
||||
apply_eu7_pack_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad,
|
||||
std::size_t Offset,
|
||||
std::size_t Count,
|
||||
eu7_pack_apply_session const *Session = nullptr );
|
||||
// Wskaznik do bufora zdekodowanego przez worker — bez kopiowania wektora.
|
||||
void
|
||||
apply_eu7_pack_models(
|
||||
scene::eu7::Eu7Model const *Models,
|
||||
std::size_t Count,
|
||||
scene::scratch_data &Scratchpad,
|
||||
eu7_pack_apply_session const *Session = nullptr );
|
||||
// Chunk insert: Models + Offset w buforze workera (pending_apply_offset).
|
||||
void
|
||||
apply_eu7_pack_models(
|
||||
scene::eu7::Eu7Model const *Models,
|
||||
std::size_t Offset,
|
||||
std::size_t Count,
|
||||
scene::scratch_data &Scratchpad,
|
||||
eu7_pack_apply_session const *Session = nullptr );
|
||||
// Odlozone sklady AI — ladowane w tle po wejsciu w gre.
|
||||
void
|
||||
drain_deferred_eu7_trainsets( double MaxMs = 12.0 );
|
||||
|
||||
private:
|
||||
struct eu7_transform_state;
|
||||
void
|
||||
insert_eu7_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad,
|
||||
eu7_transform_state &State );
|
||||
void
|
||||
insert_eu7_pack_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad );
|
||||
void
|
||||
insert_eu7_pack_models(
|
||||
std::vector<scene::eu7::Eu7Model> const &Models,
|
||||
scene::scratch_data &Scratchpad,
|
||||
std::size_t Offset,
|
||||
std::size_t Count,
|
||||
eu7_pack_apply_session const *Session = nullptr );
|
||||
void
|
||||
insert_eu7_pack_models(
|
||||
scene::eu7::Eu7Model const *Models,
|
||||
std::size_t Count,
|
||||
scene::scratch_data &Scratchpad,
|
||||
eu7_pack_apply_session const *Session = nullptr );
|
||||
void
|
||||
deserialize_parser_tokens(
|
||||
cParser &Input,
|
||||
scene::scratch_data &Scratchpad,
|
||||
std::string const &SourceName );
|
||||
// methods
|
||||
// restores class data from provided stream
|
||||
void deserialize_area( cParser &Input, scene::scratch_data &Scratchpad );
|
||||
@@ -88,6 +179,10 @@ private:
|
||||
// transforms provided location by specifed rotation and offset
|
||||
glm::dvec3 transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad );
|
||||
void export_nodes_to_stream( std::ostream &, bool Dirty ) const;
|
||||
void populate_deserialize_functionmap(
|
||||
std::unordered_map<std::string, deserializer_state::deserializefunctionbind> &Functionmap,
|
||||
cParser &Input,
|
||||
scene::scratch_data &Scratchpad );
|
||||
};
|
||||
|
||||
} // simulation
|
||||
|
||||
Reference in New Issue
Block a user