revert generification + add null validation
							parent
							
								
									7ff7018d1d
								
							
						
					
					
						commit
						5306d2cc3e
					
				|  | @ -31,8 +31,10 @@ namespace MoonTools.Core.Bonk | ||||||
|         /// <param name="id">A unique ID for the shape-transform pair.</param> |         /// <param name="id">A unique ID for the shape-transform pair.</param> | ||||||
|         /// <param name="shape"></param> |         /// <param name="shape"></param> | ||||||
|         /// <param name="transform2D"></param> |         /// <param name="transform2D"></param> | ||||||
|         public void Insert<TShape2D>(T id, TShape2D shape, Transform2D transform2D) where TShape2D : struct, IShape2D |         public void Insert(T id, IShape2D shape, Transform2D transform2D) | ||||||
|         { |         { | ||||||
|  |             if (shape == null) { throw new ArgumentNullException(nameof(shape)); } | ||||||
|  | 
 | ||||||
|             var box = shape.AABB(transform2D); |             var box = shape.AABB(transform2D); | ||||||
|             var minHash = Hash(box.MinX, box.MinY); |             var minHash = Hash(box.MinX, box.MinY); | ||||||
|             var maxHash = Hash(box.MaxX, box.MaxY); |             var maxHash = Hash(box.MaxX, box.MaxY); | ||||||
|  | @ -60,9 +62,11 @@ namespace MoonTools.Core.Bonk | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Retrieves all the potential collisions of a shape-transform pair. Excludes any shape-transforms with the given ID. |         /// Retrieves all the potential collisions of a shape-transform pair. Excludes any shape-transforms with the given ID. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public IEnumerable<(T, IShape2D, Transform2D)> Retrieve<TShape2D>(T id, TShape2D shape, Transform2D transform2D) where TShape2D : struct, IShape2D |         public IEnumerable<(T, IShape2D, Transform2D)> Retrieve(T id, IShape2D shape, Transform2D transform2D) | ||||||
|         { |         { | ||||||
|             var box = shape.AABB(transform2D); |             if (shape == null) { throw new ArgumentNullException(paramName: nameof(shape)); } | ||||||
|  | 
 | ||||||
|  |             AABB box = shape.AABB(transform2D); | ||||||
|             var minHash = Hash(box.MinX, box.MinY); |             var minHash = Hash(box.MinX, box.MinY); | ||||||
|             var maxHash = Hash(box.MaxX, box.MaxY); |             var maxHash = Hash(box.MaxX, box.MaxY); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -24,8 +24,11 @@ namespace MoonTools.Core.Bonk | ||||||
|         /// Returns a minimum separating vector in the direction from A to B. |         /// Returns a minimum separating vector in the direction from A to B. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="simplex">A simplex returned by the GJK algorithm.</param> |         /// <param name="simplex">A simplex returned by the GJK algorithm.</param> | ||||||
|         public static Vector2 Intersect<TShapeA, TShapeB>(TShapeA shapeA, Transform2D Transform2DA, TShapeB shapeB, Transform2D Transform2DB, Simplex2D simplex) where TShapeA : struct, IShape2D where TShapeB : struct, IShape2D |         public static Vector2 Intersect(IShape2D shapeA, Transform2D Transform2DA, IShape2D shapeB, Transform2D Transform2DB, Simplex2D simplex) | ||||||
|         { |         { | ||||||
|  |             if (shapeA == null) { throw new ArgumentNullException(nameof(shapeA)); } | ||||||
|  |             if (shapeB == null) { throw new ArgumentNullException(nameof(shapeB)); } | ||||||
|  | 
 | ||||||
|             var simplexVertices = simplex.Vertices.Select(vertex => vertex.ToVector2()).ToImmutableArray(); |             var simplexVertices = simplex.Vertices.Select(vertex => vertex.ToVector2()).ToImmutableArray(); | ||||||
| 
 | 
 | ||||||
|             var e0 = (simplexVertices[1].X - simplexVertices[0].X) * (simplexVertices[1].Y + simplexVertices[0].Y); |             var e0 = (simplexVertices[1].X - simplexVertices[0].X) * (simplexVertices[1].Y + simplexVertices[0].Y); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue