Core/Vmaps: Fixed getting map height near large gameobjects like LK platform

This commit is contained in:
hondacrx
2018-03-28 17:41:18 -04:00
parent 7a56a9dfbc
commit c3f8023ef0
2 changed files with 17 additions and 19 deletions
+2 -5
View File
@@ -48,10 +48,7 @@ namespace Game.Collision
{
impl.balance();
}
int size()
{
return impl.size();
}
public void update(uint diff)
{
impl.update(diff);
@@ -161,7 +158,7 @@ namespace Game.Collision
public void update(uint difftime)
{
if (size() == 0)
if (empty())
return;
rebalance_timer.Update((int)difftime);
+15 -14
View File
@@ -37,17 +37,24 @@ namespace Game.Collision
public virtual void insert(T value)
{
Vector3 pos = value.getPosition();
Node node = getGridFor(pos.X, pos.Y);
node.insert(value);
memberTable.TryAdd(value, node);
AxisAlignedBox bounds = value.getBounds();
Cell low = Cell.ComputeCell(bounds.Lo.X, bounds.Lo.Y);
Cell high = Cell.ComputeCell(bounds.Hi.X, bounds.Hi.Y);
for (int x = low.x; x <= high.x; ++x)
{
for (int y = low.y; y <= high.y; ++y)
{
Node node = getGrid(x, y);
node.insert(value);
memberTable.Add(value, node);
}
}
}
public virtual void remove(T value)
{
memberTable[value].remove(value);
// Remove the member
memberTable.TryRemove(value, out Node node);
memberTable.Remove(value);
}
public virtual void balance()
@@ -64,7 +71,7 @@ namespace Game.Collision
}
public bool contains(T value) { return memberTable.ContainsKey(value); }
public int size() { return memberTable.Count; }
public bool empty() { return memberTable.Empty(); }
public struct Cell
{
@@ -92,12 +99,6 @@ namespace Game.Collision
public bool isValid() { return x >= 0 && x < CELL_NUMBER && y >= 0 && y < CELL_NUMBER; }
}
Node getGridFor(float fx, float fy)
{
Cell c = Cell.ComputeCell(fx, fy);
return getGrid(c.x, c.y);
}
Node getGrid(int x, int y)
{
Contract.Assert(x < CELL_NUMBER && y < CELL_NUMBER);
@@ -206,7 +207,7 @@ namespace Game.Collision
node.intersectRay(ray, intersectCallback, ref max_dist);
}
ConcurrentDictionary<T, Node> memberTable = new ConcurrentDictionary<T, Node>();
MultiMap<T, Node> memberTable = new MultiMap<T, Node>();
Node[][] nodes = new Node[CELL_NUMBER][];
}
}