mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-30 23:40:29 +01:00
perf(scenery): runs of model instances read straight from the text by a reader made for them, shared between threads; anything the reader doesn't cover left to the parser; model and skin located once for a run of instances; lookup of nodes by uuid filled on load only for a scenery opened for editing
This commit is contained in:
@@ -291,12 +291,9 @@ TAnimModel::is_keyword( std::string const &Token ) const {
|
||||
|| Token == "notransition";
|
||||
}
|
||||
|
||||
bool TAnimModel::Load(cParser *parser, bool ter)
|
||||
{ // rozpoznanie wpisu modelu i ustawienie świateł
|
||||
std::string name = parser->getToken<std::string>();
|
||||
std::string texture = parser->getToken<std::string>(false);
|
||||
replace_slashes( name );
|
||||
replace_slashes( texture );
|
||||
// assigns the model and the replacable skin to the instance, and binds light and variant submodels of the model
|
||||
void TAnimModel::assign_model( std::string &name, std::string const &texture, bool const ter )
|
||||
{
|
||||
if (!Init( name, texture ))
|
||||
{
|
||||
if (name != "notload")
|
||||
@@ -329,6 +326,15 @@ bool TAnimModel::Load(cParser *parser, bool ter)
|
||||
for (int i = 0; i < iMaxNumLights; ++i)
|
||||
if (LightsOn[i] || LightsOff[i]) // Ra: zlikwidowałem wymóg istnienia obu
|
||||
iNumLights = i + 1;
|
||||
}
|
||||
|
||||
bool TAnimModel::Load(cParser *parser, bool ter)
|
||||
{ // rozpoznanie wpisu modelu i ustawienie świateł
|
||||
std::string name = parser->getToken<std::string>();
|
||||
std::string texture = parser->getToken<std::string>(false);
|
||||
replace_slashes( name );
|
||||
replace_slashes( texture );
|
||||
assign_model( name, texture, ter );
|
||||
|
||||
std::string token;
|
||||
do {
|
||||
@@ -400,6 +406,46 @@ bool TAnimModel::Load(cParser *parser, bool ter)
|
||||
return true;
|
||||
}
|
||||
|
||||
// sets up the instance from the values of a definition which was already taken apart, the way Load() does it from the text
|
||||
void TAnimModel::Load( std::string const &Name, std::string const &Texture, TAnimModel const *Twin, glm::vec3 const *Angles, glm::vec3 const *Scale, bool const Transition )
|
||||
{
|
||||
if( Twin != nullptr
|
||||
&& Twin->pModel != nullptr
|
||||
&& ( Twin->m_materialdata.replacable_skins[ 1 ] != null_handle || Texture == "none" ) ) {
|
||||
// the same model with the same skin was located for the twin already.
|
||||
// NOTE: a model or a skin which couldn't be located is searched for and reported for each instance, like it always was
|
||||
m_skintoken = Twin->m_skintoken;
|
||||
m_materialdata = Twin->m_materialdata;
|
||||
pModel = Twin->pModel;
|
||||
LightsOn = Twin->LightsOn;
|
||||
LightsOff = Twin->LightsOff;
|
||||
sm_winter_variant = Twin->sm_winter_variant;
|
||||
sm_spring_variant = Twin->sm_spring_variant;
|
||||
sm_summer_variant = Twin->sm_summer_variant;
|
||||
sm_autumn_variant = Twin->sm_autumn_variant;
|
||||
iNumLights = Twin->iNumLights;
|
||||
}
|
||||
else {
|
||||
auto name { Name };
|
||||
assign_model( name, Texture, false );
|
||||
}
|
||||
// the optional blocks, each with the effect it has in Load()
|
||||
if( Angles != nullptr ) {
|
||||
vAngle = *Angles;
|
||||
}
|
||||
if( Scale != nullptr
|
||||
&& Scale->x > 0.0f && Scale->y > 0.0f && Scale->z > 0.0f ) {
|
||||
m_scale.x *= Scale->x;
|
||||
m_scale.y *= Scale->y;
|
||||
m_scale.z *= Scale->z;
|
||||
}
|
||||
if( false == Transition ) {
|
||||
m_transition = false;
|
||||
}
|
||||
|
||||
update_instanceable_flag();
|
||||
}
|
||||
|
||||
namespace {
|
||||
// returns true if this animation type mutates per-instance state on the shared
|
||||
// TSubModel tree, which would make batched rendering unsafe. Most animations
|
||||
|
||||
@@ -118,6 +118,11 @@ public:
|
||||
static void AnimUpdate( double dt );
|
||||
bool Init(std::string const &asName, std::string const &asReplacableTexture);
|
||||
bool Load(cParser *parser, bool ter = false);
|
||||
// sets up the instance from the values of a definition which was already taken apart, the way Load(cParser *) does it
|
||||
// from the text. Name, Texture: as that method gets them ready, lower case model name and forward slashes in both.
|
||||
// Twin: instance set up for the same model and texture, to take them after instead of locating them again; can be nullptr.
|
||||
// Angles, Scale: content of the optional blocks of the definition, nullptr for a block which isn't there
|
||||
void Load( std::string const &Name, std::string const &Texture, TAnimModel const *Twin, glm::vec3 const *Angles, glm::vec3 const *Scale, bool const Transition );
|
||||
std::shared_ptr<TAnimContainer> AddContainer(std::string const &Name);
|
||||
std::shared_ptr<TAnimContainer> GetContainer(std::string const &Name = "");
|
||||
void LightSet( int const n, float const v );
|
||||
@@ -226,6 +231,8 @@ public:
|
||||
bool m_instanceable { false };
|
||||
// helper: evaluates current state and updates m_instanceable accordingly.
|
||||
void update_instanceable_flag();
|
||||
// helper: assigns the model and the replacable skin to the instance, and binds light and variant submodels of the model
|
||||
void assign_model( std::string &name, std::string const &texture, bool const ter );
|
||||
|
||||
// diagnostic counters (process-wide). Updated inside update_instanceable_flag()
|
||||
// so the renderer can surface load-time classification stats in the debug overlay.
|
||||
|
||||
Reference in New Issue
Block a user