diff --git a/Bonk/AABB.cs b/Bonk/AABB.cs
index 5a9473d..1fccacf 100644
--- a/Bonk/AABB.cs
+++ b/Bonk/AABB.cs
@@ -49,14 +49,13 @@ namespace MoonTools.Core.Bonk
Max = max;
}
- private static Matrix4x4 AbsoluteMatrix(Matrix4x4 matrix)
+ private static Matrix3x2 AbsoluteMatrix(Matrix3x2 matrix)
{
- return new Matrix4x4
+ return new Matrix3x2
(
- Math.Abs(matrix.M11), Math.Abs(matrix.M12), Math.Abs(matrix.M13), Math.Abs(matrix.M14),
- Math.Abs(matrix.M21), Math.Abs(matrix.M22), Math.Abs(matrix.M23), Math.Abs(matrix.M24),
- Math.Abs(matrix.M31), Math.Abs(matrix.M32), Math.Abs(matrix.M33), Math.Abs(matrix.M34),
- Math.Abs(matrix.M41), Math.Abs(matrix.M42), Math.Abs(matrix.M43), Math.Abs(matrix.M44)
+ Math.Abs(matrix.M11), Math.Abs(matrix.M12),
+ Math.Abs(matrix.M21), Math.Abs(matrix.M22),
+ Math.Abs(matrix.M31), Math.Abs(matrix.M32)
);
}
diff --git a/Bonk/Bonk.csproj b/Bonk/Bonk.csproj
index 256fad3..7fbe0b2 100644
--- a/Bonk/Bonk.csproj
+++ b/Bonk/Bonk.csproj
@@ -20,8 +20,8 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
diff --git a/Bonk/BroadPhase/SpatialHash.cs b/Bonk/BroadPhase/SpatialHash.cs
index 0bf178e..72dc32c 100644
--- a/Bonk/BroadPhase/SpatialHash.cs
+++ b/Bonk/BroadPhase/SpatialHash.cs
@@ -59,13 +59,13 @@ namespace MoonTools.Core.Bonk
///
public IEnumerable<(T, IShape2D, Transform2D)> Retrieve(T id, IShape2D shape, Transform2D transform2D)
{
- AABB box = shape.TransformedAABB(transform2D);
+ var box = shape.TransformedAABB(transform2D);
var minHash = Hash(box.Min);
var maxHash = Hash(box.Max);
- for (int i = minHash.Item1; i <= maxHash.Item1; i++)
+ for (var i = minHash.Item1; i <= maxHash.Item1; i++)
{
- for (int j = minHash.Item2; j <= maxHash.Item2; j++)
+ for (var j = minHash.Item2; j <= maxHash.Item2; j++)
{
var key = MakeLong(i, j);
if (hashDictionary.ContainsKey(key))
diff --git a/Bonk/NarrowPhase/SimplexVertexBuffer.cs b/Bonk/NarrowPhase/SimplexVertexBuffer.cs
index 799e42a..ce2dd2f 100644
--- a/Bonk/NarrowPhase/SimplexVertexBuffer.cs
+++ b/Bonk/NarrowPhase/SimplexVertexBuffer.cs
@@ -1,47 +1,50 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
-internal unsafe struct SimplexVertexBuffer
+namespace MoonTools.Core.Bonk
{
- private const int Size = 35;
-
- public int Length { get; private set; }
-
- public SimplexVertexBuffer(IEnumerable positions)
+ internal unsafe struct SimplexVertexBuffer
{
- var i = 0;
- foreach (var position in positions)
- {
- if (i == Size) { break; }
- var vertex = position.ToVector2();
- _simplexXBuffer[i] = vertex.X;
- _simplexYBuffer[i] = vertex.Y;
- i++;
- }
- Length = i;
- }
+ private const int Size = 35;
- public Vector2 this[int key]
- {
- get => new Vector2(_simplexXBuffer[key], _simplexYBuffer[key]);
- private set
- {
- _simplexXBuffer[key] = value.X;
- _simplexYBuffer[key] = value.Y;
- }
- }
+ public int Length { get; private set; }
- public void Insert(int index, Vector2 value)
- {
- for (var i = Length; i > index; i--)
+ public SimplexVertexBuffer(IEnumerable positions)
{
- this[i] = this[i - 1];
+ var i = 0;
+ foreach (var position in positions)
+ {
+ if (i == Size) { break; }
+ var vertex = position.ToVector2();
+ _simplexXBuffer[i] = vertex.X;
+ _simplexYBuffer[i] = vertex.Y;
+ i++;
+ }
+ Length = i;
}
- this[index] = value;
- Length++;
- }
- private fixed float _simplexXBuffer[Size];
- private fixed float _simplexYBuffer[Size];
+ public Vector2 this[int key]
+ {
+ get => new Vector2(_simplexXBuffer[key], _simplexYBuffer[key]);
+ private set
+ {
+ _simplexXBuffer[key] = value.X;
+ _simplexYBuffer[key] = value.Y;
+ }
+ }
+
+ public void Insert(int index, Vector2 value)
+ {
+ for (var i = Length; i > index; i--)
+ {
+ this[i] = this[i - 1];
+ }
+ this[index] = value;
+ Length++;
+ }
+
+ private fixed float _simplexXBuffer[Size];
+ private fixed float _simplexYBuffer[Size];
+ }
}
diff --git a/Bonk/Shapes/Rectangle.cs b/Bonk/Shapes/Rectangle.cs
index cd0da32..fc6db8e 100644
--- a/Bonk/Shapes/Rectangle.cs
+++ b/Bonk/Shapes/Rectangle.cs
@@ -79,8 +79,8 @@ namespace MoonTools.Core.Bonk
public Vector2 Support(Vector2 direction, Transform2D transform)
{
- Matrix4x4 inverseTransform;
- Matrix4x4.Invert(transform.TransformMatrix, out inverseTransform);
+ Matrix3x2 inverseTransform;
+ Matrix3x2.Invert(transform.TransformMatrix, out inverseTransform);
var inverseDirection = Vector2.TransformNormal(direction, inverseTransform);
return Vector2.Transform(Support(inverseDirection), transform.TransformMatrix);
}
diff --git a/Test/Test.csproj b/Test/Test.csproj
index 31e8e2e..591c80a 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -4,12 +4,12 @@
false
-
-
-
-
+
+
+
+
-
+
\ No newline at end of file