generated from max/template-unity-project
long ids but not long enough!
- Object and prefab file id loading - Generate grid update - Switched uint to long but should probably be ulong!
This commit is contained in:
@ -14,16 +14,16 @@ namespace VertexColor.ScenePartition.Editor
|
||||
|
||||
public SceneGridDictionary Grid => grid;
|
||||
|
||||
public void Insert(uint id, Vector3 point)
|
||||
public void Insert(long scenePartitionId, Vector3 point)
|
||||
{
|
||||
int gridId = CalculateGridPosition(point, cellSize);
|
||||
if (grid.TryGetValue(gridId, out List<uint> ids))
|
||||
if (grid.TryGetValue(gridId, out List<long> ids))
|
||||
{
|
||||
ids.Add(id);
|
||||
ids.Add(scenePartitionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.Add(gridId, new List<uint> { id });
|
||||
grid.Add(gridId, new List<long> { scenePartitionId });
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,5 +49,20 @@ namespace VertexColor.ScenePartition.Editor
|
||||
|
||||
return (x, y);
|
||||
}
|
||||
|
||||
public static long LongPairToLong(long x, long y)
|
||||
{
|
||||
// Combine x and y components into a single long
|
||||
return (x << 32) | (uint)y;
|
||||
}
|
||||
|
||||
public static (long, long) LongToLongPair(long value)
|
||||
{
|
||||
// Extract x and y components from the combined long
|
||||
long x = value >> 32;
|
||||
long y = (uint)value;
|
||||
|
||||
return (x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ namespace VertexColor.ScenePartition
|
||||
[System.Serializable]
|
||||
public class ScenePartition
|
||||
{
|
||||
public uint id = 0;
|
||||
public long id = 0;
|
||||
//public long classId = 0;
|
||||
public string filePath = null;
|
||||
//public string[] data = null;
|
||||
public UintSortedSet references = new UintSortedSet();
|
||||
public LongSortedSet references = new LongSortedSet();
|
||||
|
||||
public ScenePartition(string filePath)
|
||||
{
|
||||
@ -44,9 +45,19 @@ namespace VertexColor.ScenePartition
|
||||
Match match = Regex.Match(data[0], pattern);
|
||||
|
||||
if (!match.Success) return;
|
||||
if (!uint.TryParse(match.Groups[1].Value, out id)) return;
|
||||
if (!long.TryParse(match.Groups[1].Value, out id)) return;
|
||||
}
|
||||
|
||||
//{ // Get class id.
|
||||
// string pattern = @"!u!(\d+)";
|
||||
|
||||
// // Find all matches using regex
|
||||
// Match match = Regex.Match(data[0], pattern);
|
||||
|
||||
// if (!match.Success) return;
|
||||
// if (!long.TryParse(match.Groups[1].Value, out classId)) return;
|
||||
//}
|
||||
|
||||
{ // Get references.
|
||||
string pattern = @"fileID:\s(\d+)";
|
||||
|
||||
@ -57,7 +68,7 @@ namespace VertexColor.ScenePartition
|
||||
|
||||
if (!match.Success) continue;
|
||||
|
||||
if (uint.TryParse(match.Groups[1].Value, out uint fileNumber))
|
||||
if (long.TryParse(match.Groups[1].Value, out long fileNumber))
|
||||
{
|
||||
if (fileNumber == 0) continue; // 0 == nothing.
|
||||
|
||||
|
@ -3,11 +3,11 @@ using System.Collections.Generic;
|
||||
namespace VertexColor.ScenePartition
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ScenePartitionSortedList : SerializableSortedList<uint, ScenePartition> { }
|
||||
public class ScenePartitionSortedList : SerializableSortedList<long, ScenePartition> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class UintSortedSet : SerializableSortedSet<uint> { }
|
||||
public class LongSortedSet : SerializableSortedSet<long> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class SceneGridDictionary : SerializableDictionary<int, List<uint>> { }
|
||||
public class SceneGridDictionary : SerializableDictionary<int, List<long>> { }
|
||||
}
|
Reference in New Issue
Block a user