@@ -240,7 +240,7 @@ void ASofaContext::createSofaContext()
240240 // TSharedRef<SofaAdvancePhysicsAPI> apiRef(new SofaAdvancePhysicsAPI());
241241 // m_data.m_sofaAPI = apiRef;
242242 m_sofaAPI = new SofaAdvancePhysicsAPI ();
243- UE_LOG (SUnreal_log, Warning, TEXT (" ## ASofaDAGNode::loadComponents TEST 11 " ));
243+ UE_LOG (SUnreal_log, Warning, TEXT (" ## ASofaDAGNode::loadComponents TEST 12 " ));
244244 // TODO restore that
245245 // m_sofaAPI->activateMessageHandler(m_isMsgHandlerActivated);
246246
@@ -278,15 +278,11 @@ void ASofaContext::createSofaContext()
278278 return ;
279279 }
280280
281- // Load default plugins
282- FString pluginPaths = curPath + " Plugins/SofaUE5/Binaries/ThirdParty/SofaUE5Library/Win64" ;
283- const char * pluginPchar = TCHAR_TO_ANSI (*pluginPaths);
284- int resPlug = m_sofaAPI->loadDefaultPlugins (pluginPchar);
285- if (resPlug != 0 ) {
286- UE_LOG (SUnreal_log, Error, TEXT (" ## ASofaContext::createSofaContext: loadDefaultPlugin failed, returns: %d" ), resPlug);
287- }
281+ // Load default plugins at start before loading SOFA scene
282+ loadDefaultPlugin ();
288283
289284
285+ // If file is already set will load directly the file
290286 if (!filePath.FilePath .IsEmpty ()) {
291287 loadSofaScene ();
292288
@@ -317,8 +313,7 @@ void ASofaContext::loadSofaScene()
317313 UE_LOG (SUnreal_log, Log, TEXT (" ## ASofaContext::loadSofaScene: Scene loading with success: %s" ), *my_filePath);
318314 }
319315
320- // FPlatformProcess::Sleep(0.01f);
321-
316+
322317 // Pass default scene parameter
323318 // this->setDT(Dt);
324319 // this->setGravity(Gravity);
@@ -332,28 +327,18 @@ void ASofaContext::loadSofaScene()
332327 // m_status++;
333328}
334329
335- void ASofaContext::mapSofaScene ()
336- {
337- if (m_status == -1 ) {
338- this ->loadNodeGraph ();
339- }
340- else
341- {
342- this ->reconnectNodeGraph ();
343-
344- }
345- m_status++;
346- }
347-
348-
349330void ASofaContext::loadDefaultPlugin ()
350331{
351332 if (m_sofaAPI == nullptr )
352333 return ;
353334
354- // m_sofaAPI->loadPlugin("C:/projects/UnrealEngine/SOFA_test2/Plugins/SofaUE5/Binaries/ThirdParty/SofaUE5Library/Win64/Sofa.Component.dll");
355- // m_sofaAPI->loadPlugin("C:/projects/UnrealEngine/SOFA_test2/Plugins/SofaUE5/Binaries/ThirdParty/SofaUE5Library/Win64/Sofa.GL.Component.dll");
356- // m_sofaAPI->loadPlugin("C:/projects/UnrealEngine/SOFA_test2/Plugins/SofaUE5/Binaries/ThirdParty/SofaUE5Library/Win64/Sofa.GUI.Component.dll");
335+ FString curPath = FPaths::ConvertRelativePathToFull (FPaths::ProjectDir ());
336+ FString pluginPaths = curPath + " Plugins/SofaUE5/Binaries/ThirdParty/SofaUE5Library/Win64" ;
337+ const char * pluginPchar = TCHAR_TO_ANSI (*pluginPaths);
338+ int resPlug = m_sofaAPI->loadDefaultPlugins (pluginPchar);
339+ if (resPlug != 0 ) {
340+ UE_LOG (SUnreal_log, Error, TEXT (" ## ASofaContext::createSofaContext: loadDefaultPlugin failed, returns: %d" ), resPlug);
341+ }
357342
358343 // if (m_isMsgHandlerActivated == true)
359344 // catchSofaMessages();
@@ -398,7 +383,7 @@ void ASofaContext::loadNodeGraph()
398383 FString fs_nodeDisplayName (nodeDisplayName.c_str ());
399384
400385 FActorSpawnParameters SpawnParams;
401- // SpawnParams.Name = MakeUniqueObjectName(World, ASofaDAGNode::StaticClass(), FName(*fs_nodeDisplayName));
386+ SpawnParams.Name = MakeUniqueObjectName (World, ASofaDAGNode::StaticClass (), FName (*fs_nodeDisplayName));
402387 SpawnParams.Owner = this ;
403388
404389 ASofaDAGNode* dagNode = World->SpawnActorDeferred <ASofaDAGNode>(
@@ -411,9 +396,6 @@ void ASofaContext::loadNodeGraph()
411396
412397 if (dagNode != nullptr )
413398 {
414- // FAttachmentTransformRules att = FAttachmentTransformRules(EAttachmentRule::KeepRelative, true);
415- // dagNode->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);
416-
417399 std::string parentNameId = " " ;
418400 int resParentNameId = m_sofaAPI->getDAGNodeParentAPIName_out (nodeUniqID, parentNameId);
419401 if (resParentNameId != 0 )
@@ -446,8 +428,10 @@ void ASofaContext::loadNodeGraph()
446428
447429 const FString& parentName = dagNode->getParentName ();
448430 auto res = parentName.Compare (" None" );
449- if (res == 0 )
431+ if (res == 0 ) {
432+ dagNode->AttachToActor (this , FAttachmentTransformRules::KeepRelativeTransform);
450433 continue ;
434+ }
451435
452436 for (auto & WeakOther : m_dagNodes)
453437 {
@@ -461,6 +445,12 @@ void ASofaContext::loadNodeGraph()
461445 }
462446 }
463447
448+ m_status++;
449+ }
450+
451+
452+ void ASofaContext::loadSofaComponents ()
453+ {
464454 UE_LOG (SUnreal_log, Warning, TEXT (" ## ASofaContext::loadNodeGraph: Load all components | nbr Nodes: %d" ), m_dagNodes.Num ());
465455 // Load Components Graph
466456 for (auto & WeakDagNode : m_dagNodes)
@@ -470,7 +460,6 @@ void ASofaContext::loadNodeGraph()
470460 dagNode->loadComponents (m_sofaAPI);
471461 }
472462 }
473-
474463}
475464
476465
0 commit comments