Skip to content

Commit cd92983

Browse files
authored
[src] Restore getting and setting gravity and dt. Add prefab of DemoBox (#33)
* [src] Restore getting and setter for gravity and dt * Add sort of prefab of demoBox
1 parent 3848272 commit cd92983

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

Content/Instances/DemoBox.umap

8.64 KB
Binary file not shown.

Source/SofaUE5/Private/SofaContext.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,43 @@ void ASofaContext::EndPlay(const EEndPlayReason::Type EndPlayReason)
168168

169169
void ASofaContext::setDT(float value)
170170
{
171-
//if (m_sofaAPI)
172-
// m_sofaAPI->setTimeStep(value);
171+
UE_LOG(SUnreal_log, Warning, TEXT("## ASofaContext::setDT: %f"), value);
172+
if (m_sofaAPI)
173+
m_sofaAPI->setTimeStep(value);
174+
}
175+
176+
void ASofaContext::getDT()
177+
{
178+
if (m_sofaAPI)
179+
{
180+
double dt = m_sofaAPI->getTimeStep();
181+
UE_LOG(SUnreal_log, Warning, TEXT("## ASofaContext::getDT: %f"), dt);
182+
Dt = float(dt);
183+
}
173184
}
174185

175186
void ASofaContext::setGravity(FVector value)
176187
{
177-
//if (m_sofaAPI)
178-
//{
179-
// UE_LOG(SUnreal_log, Warning, TEXT("## ASofaContext::setGravity: %f, %f, %f"), value.X, value.Y, value.Z);
180-
// double* grav = new double[3];
181-
// grav[0] = value.X;
182-
// grav[1] = value.Y;
183-
// grav[2] = value.Z;
184-
// m_sofaAPI->setGravity(grav);
185-
//}
188+
if (m_sofaAPI)
189+
{
190+
UE_LOG(SUnreal_log, Warning, TEXT("## ASofaContext::setGravity: %f, %f, %f"), value.X, value.Y, value.Z);
191+
double grav[3] = { value.X, value.Y, value.Z };
192+
m_sofaAPI->setGravity(grav);
193+
}
186194
}
187195

196+
void ASofaContext::getGravity()
197+
{
198+
if (m_sofaAPI)
199+
{
200+
double grav[3] = { 0.0, 0.0, 0.0 };
201+
m_sofaAPI->getGravity(grav);
202+
UE_LOG(SUnreal_log, Warning, TEXT("## ASofaContext::getGravity: %f, %f, %f"), grav[0], grav[1], grav[2]);
203+
Gravity.X = float(grav[0]);
204+
Gravity.Y = float(grav[1]);
205+
Gravity.Z = float(grav[2]);
206+
}
207+
}
188208

189209

190210

@@ -332,8 +352,8 @@ void ASofaContext::loadSofaScene()
332352

333353

334354
// Pass default scene parameter
335-
// this->setDT(Dt);
336-
// this->setGravity(Gravity);
355+
this->getGravity();
356+
this->getDT();
337357

338358
if (m_isMsgHandlerActivated == true)
339359
catchSofaMessages();

Source/SofaUE5/Public/SofaContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ class SOFAUE5_API ASofaContext : public AActor
5555
// Called every frame
5656
virtual void Tick( float DeltaSeconds ) override;
5757

58+
/// Set SOFA dt to the given input value @param value
5859
void setDT(float value);
60+
/// Retrieve float dt value from SOFA
61+
void getDT();
5962

63+
/// Set SOFA gravity to the input @param value
6064
void setGravity(FVector value);
65+
/// Retrieve gravity vector3 value from SOFA
66+
void getGravity();
6167

6268
public:
6369
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sofa")

0 commit comments

Comments
 (0)