How can I cope with the issue of lag when loading Datasmith information at runtime?
Once I use the load file node within the DatasmithRuntime
plugin to load the scene, there can be a lag. Then I put the logic within the background thread with C++ and examined it once more, and there’s nonetheless lag.
After troubleshooting, I believe the loading logic is certainly carried out within the background thread, however the building of the mesh and collision physique and the replace of the scene are nonetheless carried out in the principle thread.
Does anybody know the right way to cope with this lag downside? Can the impact of loading and displaying on the similar time be achieved?
void ABlueprintTest::StatrAsyncEvent(ADatasmithRuntimeActor* DatasmithRuntimeActor, const FString& FileName)
{
AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [DatasmithRuntimeActor, FileName]()
{
bool bSuccess = LoadFile(DatasmithRuntimeActor, FileName);
AsyncTask(ENamedThreads::GameThread, [bSuccess]()
{
if (bSuccess)
{
UKismetSystemLibrary::PrintString(nullptr, TEXT("File loaded efficiently!"));
}
else
{
UKismetSystemLibrary::PrintString(nullptr, TEXT("Filed to load file!"));
}
});
});
}
Once I use Load File and Load File from Explorer within the DatasmithRuntime
plugin within the blueprint node, loading a scene of about 100 MB at all times causes program lag. Then, in C++, I put the Load File technique within the plugin to run within the background thread, but it surely nonetheless causes program lag throughout testing. I hope that when loading the .udasmoth file, it won’t block the principle thread or show whereas loading.
When this system runs to the perform of loading information, it will likely be unable to function for a time period, after which the mannequin can proceed to function after it’s displayed within the scene. The method of loading information doesn’t appear to trigger this system to be unable to function, however the building and presentation of a lot of grids appear to have an influence.
The primary picture is the interface the place this system is caught, ready for a couple of seconds earlier than it will likely be restored, and the mannequin will show that it has returned to regular.