generated from max/template-unity-project
ulong and grid list wrapper test
- wrapped lists in serialized dicts do work, maybe wrap anything. - note: maybe convert long fields to string fields to support ulong?
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VertexColor.ScenePartition
|
||||
@ -14,16 +13,18 @@ namespace VertexColor.ScenePartition
|
||||
|
||||
public SceneGridDictionary Grid => grid;
|
||||
|
||||
public void Insert(long scenePartitionId, Vector3 point)
|
||||
public void Insert(ulong scenePartitionId, Vector3 point)
|
||||
{
|
||||
int gridId = CalculateGridPosition(point, cellSize);
|
||||
if (grid.TryGetValue(gridId, out List<long> ids))
|
||||
if (grid.TryGetValue(gridId, out GridList ids))
|
||||
{
|
||||
ids.Add(scenePartitionId);
|
||||
ids.list.Add(scenePartitionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.Add(gridId, new List<long> { scenePartitionId });
|
||||
var l = new GridList();
|
||||
l.list.Add(scenePartitionId);
|
||||
grid.Add(gridId, l);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,5 +65,20 @@ namespace VertexColor.ScenePartition
|
||||
|
||||
return (x, y);
|
||||
}
|
||||
|
||||
public static ulong ULongPairToULong(ulong x, ulong y)
|
||||
{
|
||||
// Combine x and y components into a single ulong
|
||||
return (x << 32) | (uint)y;
|
||||
}
|
||||
|
||||
public static (ulong, ulong) ULongToULongPair(ulong value)
|
||||
{
|
||||
// Extract x and y components from the combined ulong
|
||||
ulong x = value >> 32;
|
||||
ulong y = (uint)value;
|
||||
|
||||
return (x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user