diff --git a/DynObj.cpp b/DynObj.cpp index ecd017cc..5d43a1bb 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -32,6 +32,8 @@ http://mozilla.org/MPL/2.0/. #include "uitranscripts.h" #include "messaging.h" #include "Driver.h" +#include +#include // Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny #define vWorldFront Math3D::vector3(0, 0, 1) @@ -5214,7 +5216,20 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co */ asModel = asBaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/... - mdModel = TModelsManager::GetModel(asModel, true); + + // Load model asynchronously + std::future ModelLoadingThread = std::async(std::launch::async, + TModelsManager::GetModel, // Function + asModel, // std::string const& + true, // bool dynamic + true, // bool Logerrors + 0 // int uid + ); + //mdModel = TModelsManager::GetModel(asModel, true); + + std::future LowpolyLoaderThread; + bool promiseLowpolyModel = false; + if (ReplacableSkin != "none") { m_materialdata.assign( ReplacableSkin ); } @@ -5279,7 +5294,16 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co erase_leading_slashes( asModel ); asModel = asBaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/... - mdLowPolyInt = TModelsManager::GetModel(asModel, true); + + LowpolyLoaderThread = std::async(std::launch::async, + TModelsManager::GetModel, // Function + asModel, // std::string const& + true, // bool dynamic + true, // bool Logerrors + 0 // int uid + ); + promiseLowpolyModel = true; + //mdLowPolyInt = TModelsManager::GetModel(asModel, true); } else if(token == "coupleradapter:") { @@ -5832,6 +5856,11 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co } while( ( token != "" ) && ( token != "endmodels" ) ); + + // Wait for models + if (promiseLowpolyModel) + mdLowPolyInt = LowpolyLoaderThread.get(); + mdModel = ModelLoadingThread.get(); if( false == MoverParameters->LoadAttributes.empty() ) { // Ra: tu wczytywanie modelu ładunku jest w porządku