Load additive

closes #9
This commit is contained in:
max 2023-07-29 16:06:03 +02:00
parent 12fd64f015
commit 73ac3485aa
2 changed files with 47 additions and 0 deletions

View File

@ -235,6 +235,35 @@ public void LoadPartitions(ulong[] ids)
}
}
public void LoadPartitionsAdditive(ulong[] ids)
{
using (new ProfilerUtility.ProfilerScope($"{nameof(LoadPartitions)}"))
{
SortedSet<ulong> partitionIds = new SortedSet<ulong>();
// Additive partitions to load.
for (int i = 0; i < ids.Length; i++)
{
SortedSet<ulong> connections = ScenePartitionUtils.FindDeeplyLinkedObjects(Data.ScenePartitions, ids[i]);
foreach (ulong c in connections)
{
partitionIds.Add(c);
}
}
// Partitions already loaded.
if (Data.HasLoadedPartitions)
{
foreach (KeyValuePair<ulong, ScenePartition> item in Data.LoadedScenePartitions)
{
partitionIds.Add(item.Key);
}
}
LoadScenePartitions(partitionIds);
}
}
private SortedSet<ulong> GetAlwaysLoadIds()
{
SortedSet<ulong> partitionIds = new SortedSet<ulong>();
@ -336,6 +365,14 @@ public void LoadCell(int gridId)
}
}
public void LoadCellAdditive(int gridId)
{
if (Data.SceneGrid.Grid.TryGetValue(gridId, out GridList ids))
{
LoadPartitionsAdditive(ids.list.ToArray());
}
}
public void ClearCache()
{
data = null;

View File

@ -66,6 +66,7 @@ private static void HandleDuringSceneGui(SceneView sceneView)
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent($"Load {gridId}"), false, Load, gridId);
menu.AddItem(new GUIContent($"LoadAdditive {gridId}"), false, LoadAdditive, gridId);
menu.ShowAsContext();
Event.current.Use();
@ -95,5 +96,14 @@ private static void Load(object gridId)
scenePartitionSO.LoadCell(cellId);
}
private static void LoadAdditive(object gridId)
{
if (scenePartitionSO == null) return;
if (gridId == null) return;
if (gridId is not int cellId) return;
scenePartitionSO.LoadCellAdditive(cellId);
}
}
}