Optimize SceneObjectsFactory::SynchronizeNewPrefabInstances when loading large scenes

This commit is contained in:
Wojtek Figat
2024-08-16 14:49:43 +02:00
parent 330d769bdc
commit c4c25fc21f
3 changed files with 31 additions and 16 deletions

View File

@@ -148,6 +148,10 @@ Asset::LoadResult Prefab::loadAsset()
ObjectsDataCache.Add(objectId, &objData);
ObjectsCount++;
Guid parentID;
if (JsonTools::GetGuidIfValid(parentID, objData, "ParentID"))
ObjectsHierarchyCache[parentID].Add(objectId);
Guid prefabId = JsonTools::GetGuid(objData, "PrefabID");
if (prefabId.IsValid() && !NestedPrefabs.Contains(prefabId))
{
@@ -186,6 +190,8 @@ void Prefab::unload(bool isReloading)
NestedPrefabs.Resize(0);
ObjectsDataCache.Clear();
ObjectsDataCache.SetCapacity(0);
ObjectsHierarchyCache.Clear();
ObjectsHierarchyCache.SetCapacity(0);
ObjectsCache.Clear();
ObjectsCache.SetCapacity(0);
if (_defaultInstance)