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

Function SnapshotSceneSync

Source/URLabEditor/Private/MjLevelOps.cpp:1167–1240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1165}
1166
1167bool SnapshotSceneSync(
1168 TArray<TSharedPtr<FJsonValue>>& OutActors,
1169 bool& bOutInPie,
1170 FString& OutLevelPath,
1171 FString& OutError)
1172{
1173 OutActors.Reset();
1174 OutError.Empty();
1175 if (!GEditor)
1176 {
1177 OutError = TEXT("GEditor null");
1178 return false;
1179 }
1180 UWorld* PieWorld = GEditor->PlayWorld;
1181 UWorld* World = PieWorld ? PieWorld : GEditor->GetEditorWorldContext().World();
1182 if (!World)
1183 {
1184 OutError = TEXT("no world available");
1185 return false;
1186 }
1187 bOutInPie = (World == GEditor->PlayWorld);
1188 OutLevelPath = World->GetOutermost()->GetName();
1189
1190 for (TActorIterator<AActor> It(World); It; ++It)
1191 {
1192 AActor* A = *It;
1193 if (!ShouldListActor(A))
1194 continue;
1195 TSharedPtr<FJsonObject> Row = BuildActorRow(A);
1196
1197 // URLab-specific metadata: only present for AMjArticulation actors.
1198 if (AMjArticulation* Mj = Cast<AMjArticulation>(A))
1199 {
1200 TSharedPtr<FJsonObject> Urlab = MakeShared<FJsonObject>();
1201 Urlab->SetStringField(TEXT("mj_class"), TEXT("articulation"));
1202
1203 TArray<UMjJoint*> Joints;
1204 Mj->GetComponents<UMjJoint>(Joints);
1205 TArray<TSharedPtr<FJsonValue>> JointNames;
1206 for (UMjJoint* J : Joints)
1207 if (J && !J->bIsDefault)
1208 JointNames.Add(MakeShared<FJsonValueString>(J->GetMjName()));
1209 Urlab->SetArrayField(TEXT("joints"), JointNames);
1210
1211 TArray<UMjActuator*> Acts;
1212 Mj->GetComponents<UMjActuator>(Acts);
1213 TArray<TSharedPtr<FJsonValue>> ActNames;
1214 for (UMjActuator* Act : Acts)
1215 if (Act && !Act->bIsDefault)
1216 ActNames.Add(MakeShared<FJsonValueString>(Act->GetMjName()));
1217 Urlab->SetArrayField(TEXT("actuators"), ActNames);
1218
1219 TArray<UMjSensor*> Sensors;
1220 Mj->GetComponents<UMjSensor>(Sensors);
1221 TArray<TSharedPtr<FJsonValue>> SensorNames;
1222 for (UMjSensor* S : Sensors)
1223 if (S && !S->bIsDefault)
1224 SensorNames.Add(MakeShared<FJsonValueString>(S->GetMjName()));

Callers 2

HandleSnapshotSceneFunction · 0.85
RunTestMethod · 0.85

Calls 4

ShouldListActorFunction · 0.85
BuildActorRowFunction · 0.85
ResetMethod · 0.45
GetMjNameMethod · 0.45

Tested by 1

RunTestMethod · 0.68