MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / ReadRotation

Function ReadRotation

Source/URLab/Public/Bridge/OpHelpers.h:85–105  ·  view source on GitHub ↗

Read a rotation from the request: `rotation_quat` (xyzw) preferred, * fall back to `rotation_euler` (degrees). Returns true if either * field was present + well-formed. Out stays at FQuat::Identity if * neither is set. */

Source from the content-addressed store, hash-verified

83 * field was present + well-formed. Out stays at FQuat::Identity if
84 * neither is set. */
85inline bool ReadRotation(const TSharedPtr<FJsonObject>& Req, FQuat& OutQ)
86{
87 OutQ = FQuat::Identity;
88 const TArray<TSharedPtr<FJsonValue>>* Q = nullptr;
89 if (Req->TryGetArrayField(TEXT("rotation_quat"), Q) && Q && Q->Num() == 4)
90 {
91 OutQ = FQuat(
92 (*Q)[0]->AsNumber(),
93 (*Q)[1]->AsNumber(),
94 (*Q)[2]->AsNumber(),
95 (*Q)[3]->AsNumber());
96 return true;
97 }
98 FVector Euler;
99 if (ReadVec3(Req, TEXT("rotation_euler"), Euler, FVector::ZeroVector))
100 {
101 OutQ = FRotator(Euler.Y, Euler.Z, Euler.X).Quaternion();
102 return true;
103 }
104 return false;
105}
106} // namespace URLabOpHelpers

Callers 6

HandleSpawnActorFunction · 0.85
HandleSpawnGridFunction · 0.85
HandleSetActorTransformFunction · 0.85
HandleDrawBoxFunction · 0.85
HandleDrawAxesFunction · 0.85
HandleViewportSetCameraFunction · 0.85

Calls 1

ReadVec3Function · 0.85

Tested by

no test coverage detected