change namespace

3D
Evan Hemsley 2020-02-20 18:07:59 -08:00
parent 9cbb1fdf31
commit d0b72d1749
23 changed files with 73 additions and 70 deletions

View File

@ -26,7 +26,7 @@ jobs:
- checkout
- attach_workspace:
at: .
- run: dotnet nuget push ./Bonk/bin/Release/MoonTools.Core.Bonk.*.nupkg -k $API_KEY -s https://api.nuget.org/v3/index.json
- run: dotnet nuget push ./Bonk/bin/Release/MoonTools.Bonk.*.nupkg -k $API_KEY -s https://api.nuget.org/v3/index.json
workflows:
version: 2

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// Axis-aligned bounding box.

View File

@ -3,16 +3,16 @@
<Version>6.0.0</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>.NET Core High Performance Collision Detection</Description>
<PackageId>MoonTools.Core.Bonk</PackageId>
<RootNamespace>MoonTools.Core.Bonk</RootNamespace>
<PackageId>MoonTools.Bonk</PackageId>
<RootNamespace>MoonTools.Bonk</RootNamespace>
<Company>Moonside Games</Company>
<Authors>Evan Hemsley</Authors>
<Copyright>Evan Hemsley 2019</Copyright>
<Product>MoonTools.Core.Bonk</Product>
<Product>MoonTools.Bonk</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyName>MoonTools.Core.Bonk</AssemblyName>
<AssemblyName>MoonTools.Bonk</AssemblyName>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/MoonsideGames/MoonTools.Core.Bonk</PackageProjectUrl>
<PackageProjectUrl>https://gitea.moonside.games/MoonsideGames/MoonTools.Bonk</PackageProjectUrl>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
@ -20,9 +20,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MoonTools.Core.Structs" Version="3.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.0"/>
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0"/>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0"/>
<PackageReference Include="MoonTools.Structs" Version="3.0.1"/>
</ItemGroup>
</Project>

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// Used to quickly check if two shapes are potentially overlapping.

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public interface IShape2D : IEquatable<IShape2D>
{

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A Minkowski difference between two shapes.
@ -56,4 +56,4 @@ namespace MoonTools.Core.Bonk
return !(a == b);
}
}
}
}

View File

@ -1,6 +1,6 @@
using System.Numerics;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
internal struct Edge
{

View File

@ -1,7 +1,7 @@
using MoonTools.Core.Structs;
using MoonTools.Structs;
using System.Numerics;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public static class NarrowPhase
{

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
internal unsafe struct SimplexVertexBuffer
{

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A Circle is a shape defined by a radius.

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A line is a shape defined by exactly two points in space.

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public struct Point : IShape2D, IEquatable<Point>
{

View File

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A Shape defined by an arbitrary collection of vertices.

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A rectangle is a shape defined by a minimum and maximum X value and a minimum and maximum Y value.

View File

@ -1,6 +1,6 @@
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
internal static class RectanglePolygonComparison
{

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
using System;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A simplex is a shape with up to n - 2 vertices in the nth dimension.

View File

@ -1,6 +1,6 @@
using System.Numerics;
namespace MoonTools.Core.Bonk.Extensions
namespace MoonTools.Bonk.Extensions
{
internal static class Vector2Extensions
{
@ -15,4 +15,4 @@ namespace MoonTools.Core.Bonk.Extensions
return a.Cross(b) > 0 ? Vector2.Normalize(new Vector2(ab.Y, ab.X)) : Vector2.Normalize(new Vector2(ab.Y, -ab.X));
}
}
}
}

View File

@ -1,7 +1,7 @@
# MoonTools.Core.Bonk
# MoonTools.Bonk
[![NuGet Badge](https://buildstats.info/nuget/MoonTools.Core.Bonk)](https://www.nuget.org/packages/MoonTools.Core.Bonk/)
[![CircleCI](https://circleci.com/gh/MoonsideGames/MoonTools.Core.Bonk.svg?style=svg)](https://circleci.com/gh/MoonsideGames/MoonTools.Core.Bonk)
[![NuGet Badge](https://buildstats.info/nuget/MoonTools.Bonk)](https://www.nuget.org/packages/MoonTools.Bonk/)
[![CircleCI](https://circleci.com/gh/MoonsideGames/MoonTools.Bonk.svg?style=svg)](https://circleci.com/gh/MoonsideGames/MoonTools.Bonk)
Bonk is a fast and modular collision detection system for .NET that is part of the MoonTools suite. It can be used with any .NET-based game engine.

View File

@ -1,6 +1,6 @@
using NUnit.Framework;
using FluentAssertions;
using MoonTools.Core.Bonk;
using MoonTools.Bonk;
using System.Numerics;
namespace Tests

View File

@ -3,8 +3,8 @@ using FluentAssertions;
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Core.Bonk;
using MoonTools.Structs;
using MoonTools.Bonk;
namespace Tests
{
@ -13,9 +13,9 @@ namespace Tests
[Test]
public void RectangleOverlap()
{
var squareA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var squareA = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformA = Transform2D.DefaultTransform;
var squareB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var squareB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1.5f, 0));
var (result, simplex) = NarrowPhase.FindCollisionSimplex(squareA, transformA, squareB, transformB);
@ -27,7 +27,7 @@ namespace Tests
intersection.X.Should().Be(1f);
intersection.Y.Should().Be(0);
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit past
var movedTransform = new Transform2D(transformA.Position - (intersection * 2)); // move past
NarrowPhase.TestCollision(squareA, movedTransform, squareB, transformB).Should().BeFalse();
}
@ -52,7 +52,7 @@ namespace Tests
intersection.X.Should().BeApproximately(ix, 0.01f);
intersection.Y.Should().BeApproximately(iy, 0.01f);
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit past
var movedTransform = new Transform2D(transformA.Position - (intersection * 2)); // move past
NarrowPhase.TestCollision(circleA, movedTransform, circleB, transformB).Should().BeFalse();
}
@ -62,7 +62,7 @@ namespace Tests
{
var line = new Line(new Position2D(-4, -4), new Position2D(4, 4));
var transformA = Transform2D.DefaultTransform;
var square = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var square = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = Transform2D.DefaultTransform;
var (result, simplex) = NarrowPhase.FindCollisionSimplex(line, transformA, square, transformB);
@ -71,7 +71,10 @@ namespace Tests
var intersection = NarrowPhase.Intersect(line, transformA, square, transformB, simplex);
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit past
intersection.X.Should().Be(1);
intersection.Y.Should().Be(-1);
var movedTransform = new Transform2D(transformA.Position - (intersection * 2)); // move past
NarrowPhase.TestCollision(line, movedTransform, square, transformB).Should().BeFalse();
}

View File

@ -1,8 +1,8 @@
using NUnit.Framework;
using FluentAssertions;
using MoonTools.Core.Bonk;
using MoonTools.Core.Structs;
using MoonTools.Bonk;
using MoonTools.Structs;
using System.Numerics;
using System.Collections.Immutable;

View File

@ -1,6 +1,6 @@
using NUnit.Framework;
using MoonTools.Core.Bonk;
using MoonTools.Core.Structs;
using MoonTools.Bonk;
using MoonTools.Structs;
using System.Numerics;
using FluentAssertions;
using System.Collections.Immutable;
@ -354,10 +354,10 @@ namespace Tests
[Test]
public void RectanglesNotOverlapping()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-6, -6, 6, 6);
var rectangleA = new MoonTools.Bonk.Rectangle(-6, -6, 6, 6);
var transformA = new Transform2D(new Position2D(39, 249));
var rectangleB = new MoonTools.Core.Bonk.Rectangle(0, 0, 16, 16);
var rectangleB = new MoonTools.Bonk.Rectangle(0, 0, 16, 16);
var transformB = new Transform2D(new Position2D(16, 240));
NarrowPhase.TestCollision(rectangleA, transformA, rectangleB, transformB).Should().BeFalse();
@ -366,10 +366,10 @@ namespace Tests
[Test]
public void RotatedRectanglesOverlapping()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 2, 2);
var rectangleA = new MoonTools.Bonk.Rectangle(-1, -1, 2, 2);
var transformA = new Transform2D(new Vector2(-1, 0), -90f);
var rectangleB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1, 0));
NarrowPhase.TestCollision(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();
@ -378,10 +378,10 @@ namespace Tests
[Test]
public void RectanglesTouchingGJK2D()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleA = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformA = new Transform2D(new Position2D(-1, 0));
var rectangleB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1, 0));
NarrowPhase.TestCollision(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();
@ -390,10 +390,10 @@ namespace Tests
[Test]
public void RectanglesOverlappingGJK2D()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleA = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformA = new Transform2D(new Position2D(0, 0));
var rectangleB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1, 0));
NarrowPhase.TestCollision(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();
@ -402,10 +402,10 @@ namespace Tests
[Test]
public void RectanglesTouchingOverlap()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleA = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformA = new Transform2D(new Position2D(-1, 0));
var rectangleB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1, 0));
NarrowPhase.TestRectangleOverlap(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();
@ -414,10 +414,10 @@ namespace Tests
[Test]
public void RectanglesOverlappingOverlap()
{
var rectangleA = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleA = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformA = new Transform2D(new Position2D(0, 0));
var rectangleB = new MoonTools.Core.Bonk.Rectangle(-1, -1, 1, 1);
var rectangleB = new MoonTools.Bonk.Rectangle(-1, -1, 1, 1);
var transformB = new Transform2D(new Vector2(1, 0));
NarrowPhase.TestRectangleOverlap(rectangleA, transformA, rectangleB, transformB).Should().BeTrue();

View File

@ -1,7 +1,7 @@
using FluentAssertions;
using NUnit.Framework;
using MoonTools.Core.Structs;
using MoonTools.Core.Bonk;
using MoonTools.Structs;
using MoonTools.Bonk;
using System.Numerics;
namespace Tests