MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / CollectPrefabInstances

Method CollectPrefabInstances

Source/Engine/Level/Prefabs/Prefab.Apply.cpp:227–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225};
226
227void PrefabInstanceData::CollectPrefabInstances(PrefabInstancesData& prefabInstancesData, const Guid& prefabId, Actor* defaultInstance, Actor* targetActor)
228{
229 ScopeLock lock(PrefabManager::PrefabsReferencesLocker);
230 if (auto instancesPtr = PrefabManager::PrefabsReferences.TryGet(prefabId))
231 {
232 auto& instances = *instancesPtr;
233 int32 usedCount = 0;
234 for (int32 instanceIndex = 0; instanceIndex < instances.Count(); instanceIndex++)
235 {
236 const auto instance = instances[instanceIndex];
237 if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete))
238 continue;
239 if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance))
240 usedCount++;
241 }
242 prefabInstancesData.Resize(usedCount);
243 int32 dataIndex = 0;
244 for (int32 instanceIndex = 0; instanceIndex < instances.Count(); instanceIndex++)
245 {
246 // Skip default instance because it will be recreated, skip input actor because it needs just to be linked
247 Actor* instance = instances[instanceIndex];
248 if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete))
249 continue;
250 if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance))
251 {
252 auto& data = prefabInstancesData[dataIndex++];
253 data.TargetActor = instance;
254 data.OrderInParent = instance->GetOrderInParent();
255 }
256 }
257 }
258}
259
260void PrefabInstanceData::SerializePrefabInstances(PrefabInstancesData& prefabInstancesData, rapidjson_flax::StringBuffer& tmpBuffer, const Prefab* prefab)
261{

Callers

nothing calls this directly

Calls 6

EnumHasAnyFlagsFunction · 0.85
HasActorInHierarchyMethod · 0.80
TryGetMethod · 0.45
CountMethod · 0.45
ResizeMethod · 0.45
GetOrderInParentMethod · 0.45

Tested by

no test coverage detected