Skip to content

Commit ec2100d

Browse files
authored
[src] Add buttons in SofaContext to control SOFA scene loading and graph mapping to UE5 objects (#22)
* Add button to load sofa scene, it should not be called during parameter setting * Qdd option to separate SOFA scene loading and mapping into UE5
1 parent 1655f5b commit ec2100d

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

Source/SofaUE5/Private/SofaContext.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,12 @@ void ASofaContext::createSofaContext()
287287
}
288288

289289

290-
if (!filePath.FilePath.IsEmpty())
290+
if (!filePath.FilePath.IsEmpty()) {
291291
loadSofaScene();
292+
293+
if (m_status != -1)
294+
this->reconnectNodeGraph();
295+
}
292296
}
293297

294298

@@ -313,14 +317,23 @@ void ASofaContext::loadSofaScene()
313317
UE_LOG(SUnreal_log, Log, TEXT("## ASofaContext::loadSofaScene: Scene loading with success: %s"), *my_filePath);
314318
}
315319

316-
FPlatformProcess::Sleep(0.01f);
320+
//FPlatformProcess::Sleep(0.01f);
317321

318322
// Pass default scene parameter
319323
// this->setDT(Dt);
320324
// this->setGravity(Gravity);
321325

322326
// Start parsing scene loaded in SOFA
323327
// Create the actor of the scene:
328+
329+
//if (m_isMsgHandlerActivated == true)
330+
// catchSofaMessages();
331+
332+
//m_status++;
333+
}
334+
335+
void ASofaContext::mapSofaScene()
336+
{
324337
if (m_status == -1) {
325338
this->loadNodeGraph();
326339
}
@@ -329,9 +342,6 @@ void ASofaContext::loadSofaScene()
329342
this->reconnectNodeGraph();
330343

331344
}
332-
//if (m_isMsgHandlerActivated == true)
333-
// catchSofaMessages();
334-
335345
m_status++;
336346
}
337347

Source/SofaUE5/Public/SofaContext.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class SOFAUE5_API ASofaContext : public AActor
5252

5353
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
5454

55+
UFUNCTION(CallInEditor, Category = "Sofa")
56+
void loadSofaScene();
57+
58+
UFUNCTION(CallInEditor, Category = "Sofa")
59+
void mapSofaScene();
60+
5561
#if WITH_EDITOR
5662
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
5763
#endif
@@ -83,7 +89,7 @@ class SOFAUE5_API ASofaContext : public AActor
8389
void catchSofaMessages();
8490

8591
void createSofaContext();
86-
void loadSofaScene();
92+
8793

8894
void loadDefaultPlugin();
8995

0 commit comments

Comments
 (0)