fix spatial hash remove crash if key does not exist
parent
b81780e258
commit
c04d021237
|
@ -125,7 +125,9 @@ namespace MoonWorks.Collision.Fixed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Remove(T id)
|
public void Remove(T id)
|
||||||
{
|
{
|
||||||
var (shape, transform, collisionGroups) = IDLookup[id];
|
if (IDLookup.TryGetValue(id, out var data))
|
||||||
|
{
|
||||||
|
var (shape, transform, collisionGroups) = data;
|
||||||
|
|
||||||
var box = AABB2D.Transformed(shape.AABB, transform);
|
var box = AABB2D.Transformed(shape.AABB, transform);
|
||||||
var minHash = Hash(box.Min);
|
var minHash = Hash(box.Min);
|
||||||
|
@ -141,6 +143,7 @@ namespace MoonWorks.Collision.Fixed
|
||||||
|
|
||||||
IDLookup.Remove(id);
|
IDLookup.Remove(id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes everything that has been inserted into the SpatialHash.
|
/// Removes everything that has been inserted into the SpatialHash.
|
||||||
|
|
Loading…
Reference in New Issue