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

Method StartReplay

Source/URLab/Private/Replay/MjReplayManager.cpp:350–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350void AMjReplayManager::StartReplay()
351{
352 if (bIsRecording)
353 StopRecording();
354
355 TArray<FMjReplayFrame>& Frames = GetActiveFrames();
356 if (Frames.Num() == 0)
357 {
358 UE_LOG(LogURLabReplay, Warning, TEXT("ReplayManager: No frames in session '%s' to replay!"), *ActiveSessionName);
359 return;
360 }
361
362 if (!Manager)
363 Manager = AAMjManager::GetManager();
364 if (!Manager)
365 return;
366
367 bIsReplaying = true;
368 PlaybackTime = 0.0f;
369 PhysicsPlaybackTime.store(0.0, std::memory_order_relaxed);
370 bFirstReplayFrame = true;
371
372 // Rebuild bindings (initial MuJoCo positions will be captured on first replay frame
373 // after the reset completes on the physics thread)
374 RebuildArticulationBindings();
375
376 // Reset simulation so initial positions are clean (from the model's qpos0)
377 Manager->ResetSimulation();
378
379 // Auto-unpause so replay starts immediately
380 if (Manager->PhysicsEngine && Manager->PhysicsEngine->bIsPaused)
381 {
382 Manager->PhysicsEngine->SetPaused(false);
383 }
384
385 Manager->PhysicsEngine->SetCustomStepHandler([this](mjModel* m, mjData* d) {
386 this->OnReplayStep(m, d);
387 });
388
389 UE_LOG(LogURLabReplay, Log, TEXT("ReplayManager: Started Replay of '%s' (%d frames)"),
390 *ActiveSessionName, Frames.Num());
391}
392
393void AMjReplayManager::StopReplay()
394{

Callers 2

HandleReplayMethod · 0.45
OnReplayClickedMethod · 0.45

Calls 4

OnReplayStepMethod · 0.95
SetCustomStepHandlerMethod · 0.80
ResetSimulationMethod · 0.45
SetPausedMethod · 0.45

Tested by

no test coverage detected