update Transform2D and switch matrix4x4 to matrix3x2
parent
d553c2e213
commit
bf7a97af20
11
Bonk/AABB.cs
11
Bonk/AABB.cs
|
@ -49,14 +49,13 @@ namespace MoonTools.Core.Bonk
|
||||||
Max = max;
|
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.M11), Math.Abs(matrix.M12),
|
||||||
Math.Abs(matrix.M21), Math.Abs(matrix.M22), Math.Abs(matrix.M23), Math.Abs(matrix.M24),
|
Math.Abs(matrix.M21), Math.Abs(matrix.M22),
|
||||||
Math.Abs(matrix.M31), Math.Abs(matrix.M32), Math.Abs(matrix.M33), Math.Abs(matrix.M34),
|
Math.Abs(matrix.M31), Math.Abs(matrix.M32)
|
||||||
Math.Abs(matrix.M41), Math.Abs(matrix.M42), Math.Abs(matrix.M43), Math.Abs(matrix.M44)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MoonTools.Core.Structs" Version="2.1.0" />
|
<PackageReference Include="MoonTools.Core.Structs" Version="3.0.0" />
|
||||||
<PackageReference Include="System.Collections.Immutable" Version="1.6.0" />
|
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
|
||||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
||||||
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
|
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -59,13 +59,13 @@ namespace MoonTools.Core.Bonk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<(T, IShape2D, Transform2D)> Retrieve(T id, IShape2D shape, Transform2D transform2D)
|
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 minHash = Hash(box.Min);
|
||||||
var maxHash = Hash(box.Max);
|
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);
|
var key = MakeLong(i, j);
|
||||||
if (hashDictionary.ContainsKey(key))
|
if (hashDictionary.ContainsKey(key))
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using MoonTools.Core.Structs;
|
using MoonTools.Core.Structs;
|
||||||
|
|
||||||
|
namespace MoonTools.Core.Bonk
|
||||||
|
{
|
||||||
internal unsafe struct SimplexVertexBuffer
|
internal unsafe struct SimplexVertexBuffer
|
||||||
{
|
{
|
||||||
private const int Size = 35;
|
private const int Size = 35;
|
||||||
|
@ -45,3 +47,4 @@ internal unsafe struct SimplexVertexBuffer
|
||||||
private fixed float _simplexXBuffer[Size];
|
private fixed float _simplexXBuffer[Size];
|
||||||
private fixed float _simplexYBuffer[Size];
|
private fixed float _simplexYBuffer[Size];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -79,8 +79,8 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction, Transform2D transform)
|
public Vector2 Support(Vector2 direction, Transform2D transform)
|
||||||
{
|
{
|
||||||
Matrix4x4 inverseTransform;
|
Matrix3x2 inverseTransform;
|
||||||
Matrix4x4.Invert(transform.TransformMatrix, out inverseTransform);
|
Matrix3x2.Invert(transform.TransformMatrix, out inverseTransform);
|
||||||
var inverseDirection = Vector2.TransformNormal(direction, inverseTransform);
|
var inverseDirection = Vector2.TransformNormal(direction, inverseTransform);
|
||||||
return Vector2.Transform(Support(inverseDirection), transform.TransformMatrix);
|
return Vector2.Transform(Support(inverseDirection), transform.TransformMatrix);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="nunit" Version="3.11.0"/>
|
<PackageReference Include="nunit" Version="3.12.0" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0"/>
|
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||||
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
<PackageReference Include="FluentAssertions" Version="5.9.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue