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

Method Setup

Source/URLab/Private/MuJoCo/Components/Bodies/MjBody.cpp:154–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153 SetWorldLocationAndRotation(CorrectedPos, MuJoCoWorldQuat);
154}
155
156void UMjBody::ExportTo(mjsBody* Element, mjsDefault* Default)
157{
158 if (!Element)
159 return;
160
161 // --- CODEGEN_EXPORT_START ---
162 if (bOverride_SleepPolicy)
163 {
164 Element->sleep = static_cast<mjtSleepPolicy>(static_cast<uint8>(SleepPolicy));
165 }
166 if (bOverride_childclass)
167 MjSetString(Element->childclass, childclass);
168 if (bOverride_mocap)
169 Element->mocap = mocap ? 1 : 0;
170 if (bOverride_gravcomp)
171 Element->gravcomp = gravcomp;
172 // --- CODEGEN_EXPORT_END ---
173}
174
175void UMjBody::Setup(USceneComponent* Parent, mjsBody* ParentBody, FMujocoSpecWrapper* Wrapper)
176{
177 FTransform TargetTransform;
178
179 bool bIsAttachingToWorld = (ParentBody && mjs_getId(ParentBody->element) == 0);
180
181 if (bIsAttachingToWorld)
182 {
183 TargetTransform = GetComponentTransform();
184 }
185 else
186 {
187 TargetTransform = GetRelativeTransform();
188 }
189
190 FString NameToRegister = MjName.IsEmpty() ? GetName() : MjName;
191 mjsBody* BodyToAttachTo = Wrapper->CreateBody(
192 NameToRegister,
193 ParentBody,
194 TargetTransform);
195 if (BodyToAttachTo)
196 {
197 m_SpecElement = BodyToAttachTo->element;
198 // All per-attr writes (gravcomp / mocap / sleep / childclass) are
199 // codegen-owned inside ExportTo's CODEGEN_EXPORT block.
200 ExportTo(BodyToAttachTo, nullptr);
201 }
202
203 m_Root = Parent;
204
205 TArray<USceneComponent*> DirectChildren = GetAttachChildren();
206
207 for (USceneComponent* CurrentComponent : DirectChildren)
208 {
209 if (UMjBody* MjBodyComp = Cast<UMjBody>(CurrentComponent))
210 {
211 UE_LOG(LogURLab, Verbose, TEXT("LEVEL N: Detected MjsBody: %s. Creating external articulated body."),

Callers

nothing calls this directly

Calls 4

IsEmptyMethod · 0.80
CreateBodyMethod · 0.80
PrepareMeshForMuJoCoMethod · 0.80
RegisterToSpecMethod · 0.45

Tested by

no test coverage detected