retarget to .net standard 2.0
parent
c29b61992f
commit
d60a5f4311
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>5.0.1</Version>
|
<Version>5.0.1</Version>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Description>.NET Core High Performance Collision Detection</Description>
|
<Description>.NET Core High Performance Collision Detection</Description>
|
||||||
<PackageId>MoonTools.Core.Bonk</PackageId>
|
<PackageId>MoonTools.Core.Bonk</PackageId>
|
||||||
<RootNamespace>MoonTools.Core.Bonk</RootNamespace>
|
<RootNamespace>MoonTools.Core.Bonk</RootNamespace>
|
||||||
|
@ -19,8 +19,9 @@
|
||||||
<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.0.0" />
|
<PackageReference Include="MoonTools.Core.Structs" Version="2.1.0"/>
|
||||||
<PackageReference Include="morelinq" Version="3.2.0" />
|
|
||||||
<PackageReference Include="System.Collections.Immutable" Version="1.6.0"/>
|
<PackageReference Include="System.Collections.Immutable" Version="1.6.0"/>
|
||||||
|
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0"/>
|
||||||
|
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using MoonTools.Core.Structs;
|
using MoonTools.Core.Structs;
|
||||||
using MoreLinq;
|
|
||||||
|
|
||||||
namespace MoonTools.Core.Bonk
|
namespace MoonTools.Core.Bonk
|
||||||
{
|
{
|
||||||
|
@ -33,7 +32,19 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction, Transform2D transform)
|
public Vector2 Support(Vector2 direction, Transform2D transform)
|
||||||
{
|
{
|
||||||
return Vertices.Select(vertex => Vector2.Transform(vertex, transform.TransformMatrix)).MaxBy(transformed => Vector2.Dot(transformed, direction)).First();
|
var maxDotProduct = float.NegativeInfinity;
|
||||||
|
var maxVertex = vertices[0].ToVector2();
|
||||||
|
foreach (var vertex in Vertices)
|
||||||
|
{
|
||||||
|
var transformed = Vector2.Transform(vertex, transform.TransformMatrix);
|
||||||
|
var dot = Vector2.Dot(transformed, direction);
|
||||||
|
if (dot > maxDotProduct)
|
||||||
|
{
|
||||||
|
maxVertex = transformed;
|
||||||
|
maxDotProduct = dot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AABB AABB(Transform2D Transform2D)
|
public AABB AABB(Transform2D Transform2D)
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using MoonTools.Core.Structs;
|
using MoonTools.Core.Structs;
|
||||||
using MoreLinq;
|
|
||||||
|
|
||||||
namespace MoonTools.Core.Bonk
|
namespace MoonTools.Core.Bonk
|
||||||
{
|
{
|
||||||
|
@ -38,7 +37,19 @@ namespace MoonTools.Core.Bonk
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction, Transform2D transform)
|
public Vector2 Support(Vector2 direction, Transform2D transform)
|
||||||
{
|
{
|
||||||
return Vertices.Select(vertex => Vector2.Transform(vertex, transform.TransformMatrix)).MaxBy(transformed => Vector2.Dot(transformed, direction)).First();
|
var maxDotProduct = float.NegativeInfinity;
|
||||||
|
var maxVertex = new Vector2(MinX, MinY);
|
||||||
|
foreach (var vertex in Vertices)
|
||||||
|
{
|
||||||
|
var transformed = Vector2.Transform(vertex, transform.TransformMatrix);
|
||||||
|
var dot = Vector2.Dot(transformed, direction);
|
||||||
|
if (dot > maxDotProduct)
|
||||||
|
{
|
||||||
|
maxVertex = transformed;
|
||||||
|
maxDotProduct = dot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AABB AABB(Transform2D Transform2D)
|
public AABB AABB(Transform2D Transform2D)
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using MoonTools.Core.Structs;
|
using MoonTools.Core.Structs;
|
||||||
using MoreLinq;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MoonTools.Core.Bonk
|
namespace MoonTools.Core.Bonk
|
||||||
|
@ -62,14 +61,21 @@ namespace MoonTools.Core.Bonk
|
||||||
return Bonk.AABB.FromTransformedVertices(Vertices, transform);
|
return Bonk.AABB.FromTransformedVertices(Vertices, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction)
|
|
||||||
{
|
|
||||||
return Vertices.MaxBy(vertex => Vector2.Dot(vertex, direction)).First();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 Support(Vector2 direction, Transform2D transform)
|
public Vector2 Support(Vector2 direction, Transform2D transform)
|
||||||
{
|
{
|
||||||
return Vector2.Transform(Support(direction), transform.TransformMatrix);
|
var maxDotProduct = float.NegativeInfinity;
|
||||||
|
var maxVertex = a;
|
||||||
|
foreach (var vertex in Vertices)
|
||||||
|
{
|
||||||
|
var transformed = Vector2.Transform(vertex, transform.TransformMatrix);
|
||||||
|
var dot = Vector2.Dot(transformed, direction);
|
||||||
|
if (dot > maxDotProduct)
|
||||||
|
{
|
||||||
|
maxVertex = transformed;
|
||||||
|
maxDotProduct = dot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxVertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
|
|
Loading…
Reference in New Issue