mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 20:59:19 +02:00
Move lowpoly and exterior loading to separate async threads
This commit is contained in:
33
DynObj.cpp
33
DynObj.cpp
@@ -32,6 +32,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "uitranscripts.h"
|
#include "uitranscripts.h"
|
||||||
#include "messaging.h"
|
#include "messaging.h"
|
||||||
#include "Driver.h"
|
#include "Driver.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <future>
|
||||||
|
|
||||||
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
||||||
#define vWorldFront Math3D::vector3(0, 0, 1)
|
#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
|
asModel = asBaseDir + asModel; // McZapkie 2002-07-20: dynamics maja swoje modele w dynamics/basedir
|
||||||
Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/...
|
Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/...
|
||||||
mdModel = TModelsManager::GetModel(asModel, true);
|
|
||||||
|
// Load model asynchronously
|
||||||
|
std::future<TModel3d *> 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<TModel3d *> LowpolyLoaderThread;
|
||||||
|
bool promiseLowpolyModel = false;
|
||||||
|
|
||||||
if (ReplacableSkin != "none") {
|
if (ReplacableSkin != "none") {
|
||||||
m_materialdata.assign( ReplacableSkin );
|
m_materialdata.assign( ReplacableSkin );
|
||||||
}
|
}
|
||||||
@@ -5279,7 +5294,16 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
erase_leading_slashes( asModel );
|
erase_leading_slashes( asModel );
|
||||||
asModel = asBaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir
|
asModel = asBaseDir + asModel; // McZapkie-200702 - dynamics maja swoje modele w dynamic/basedir
|
||||||
Global.asCurrentTexturePath = asBaseDir; // biezaca sciezka do tekstur to dynamic/...
|
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:") {
|
else if(token == "coupleradapter:") {
|
||||||
@@ -5833,6 +5857,11 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
} while( ( token != "" )
|
} while( ( token != "" )
|
||||||
&& ( token != "endmodels" ) );
|
&& ( token != "endmodels" ) );
|
||||||
|
|
||||||
|
// Wait for models
|
||||||
|
if (promiseLowpolyModel)
|
||||||
|
mdLowPolyInt = LowpolyLoaderThread.get();
|
||||||
|
mdModel = ModelLoadingThread.get();
|
||||||
|
|
||||||
if( false == MoverParameters->LoadAttributes.empty() ) {
|
if( false == MoverParameters->LoadAttributes.empty() ) {
|
||||||
// Ra: tu wczytywanie modelu ładunku jest w porządku
|
// Ra: tu wczytywanie modelu ładunku jest w porządku
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user