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

Method ApplyQuickConvert

Source/URLabEditor/Private/URLabEditor.cpp:255–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255void FURLabEditorModule::ApplyQuickConvert(TArray<TWeakObjectPtr<AActor>> Actors, bool bStatic, bool bComplex)
256{
257 FScopedTransaction Transaction(FText::FromString("MuJoCo Quick Convert"));
258
259 int32 Applied = 0;
260 for (const TWeakObjectPtr<AActor>& WeakActor : Actors)
261 {
262 AActor* Actor = WeakActor.Get();
263 if (!Actor)
264 continue;
265
266 // Skip if already has a QuickConvert component
267 if (Actor->FindComponentByClass<UMjQuickConvertComponent>())
268 {
269 UE_LOG(LogURLabEditor, Warning, TEXT("Actor '%s' already has MjQuickConvertComponent, skipping."), *Actor->GetName());
270 continue;
271 }
272
273 Actor->Modify();
274
275 // Set mobility to Movable (required for MuJoCo transform sync)
276 if (USceneComponent* Root = Actor->GetRootComponent())
277 {
278 Root->SetMobility(EComponentMobility::Movable);
279 }
280
281 // Create and configure the component
282 UMjQuickConvertComponent* Comp = NewObject<UMjQuickConvertComponent>(Actor, NAME_None, RF_Transactional);
283 Comp->Static = bStatic;
284 Comp->ComplexMeshRequired = bComplex;
285
286 Actor->AddInstanceComponent(Comp);
287 Comp->RegisterComponent();
288
289 Actor->GetPackage()->MarkPackageDirty();
290 Applied++;
291 }
292
293 UE_LOG(LogURLabEditor, Log, TEXT("MuJoCo Quick Convert applied to %d actor(s) [Static=%d, Complex=%d]"),
294 Applied, bStatic, bComplex);
295}
296
297void FURLabEditorModule::OnObjectModified(UObject* Object)
298{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected