Compare commits

..

No commits in common. "master" and "multishape" have entirely different histories.

29 changed files with 115 additions and 101 deletions

46
.circleci/config.yml Normal file
View File

@ -0,0 +1,46 @@
version: 2.1
defaults: &defaults
working_directory: ~/repo
docker:
- image: mcr.microsoft.com/dotnet/core/sdk:3.0
environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
jobs:
test:
<<: *defaults
steps:
- checkout
- run: dotnet restore
- run: dotnet build -c Release
- run: dotnet test -c Release
- persist_to_workspace:
root: .
paths: ./Bonk/bin
deploy:
<<: *defaults
steps:
- 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
workflows:
version: 2
test_and_deploy:
jobs:
- test:
filters:
tags:
only: /.*/
- deploy:
requires:
- test
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+(-preview\d*)?$/

View File

@ -1,24 +0,0 @@
kind: pipeline
type: docker
name: default
workspace:
path: /build
steps:
- name: test
image: mcr.microsoft.com/dotnet/core/sdk:3.1
commands:
- dotnet build -c Release
- dotnet test -c Release
- name: deploy
image: mcr.microsoft.com/dotnet/core/sdk:3.1
environment:
API_KEY:
from_secret: API_KEY
commands:
- dotnet nuget push /build/Bonk/bin/Release/MoonTools.Bonk.*.nupkg -s https://api.nuget.org/v3/index.json -k $API_KEY
when:
ref:
- refs/tags/*.*.*

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// Axis-aligned bounding box.
@ -26,13 +26,11 @@ namespace MoonTools.Bonk
public float Right { get { return Max.X; } }
public float Left { get { return Min.X; } }
/// <summary>
/// The top of the AABB. Assumes a downward-aligned Y axis, so this value will be smaller than Bottom.
/// </summary>
/// <value></value>
public float Top { get { return Min.Y; } }
/// <summary>
/// The bottom of the AABB. Assumes a downward-aligned Y axis, so this value will be larger than Top.
/// </summary>

View File

@ -1,29 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>8.0.1</Version>
<Version>6.0.0</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>.NET Standard High Performance Collision Detection</Description>
<PackageId>MoonTools.Bonk</PackageId>
<RootNamespace>MoonTools.Bonk</RootNamespace>
<Description>.NET Core High Performance Collision Detection</Description>
<PackageId>MoonTools.Core.Bonk</PackageId>
<RootNamespace>MoonTools.Core.Bonk</RootNamespace>
<Company>Moonside Games</Company>
<Authors>Evan Hemsley</Authors>
<Copyright>Evan Hemsley 2019</Copyright>
<Product>MoonTools.Bonk</Product>
<Product>MoonTools.Core.Bonk</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyName>MoonTools.Bonk</AssemblyName>
<AssemblyName>MoonTools.Core.Bonk</AssemblyName>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageProjectUrl>https://gitea.moonside.games/MoonsideGames/MoonTools.Bonk</PackageProjectUrl>
<PackageProjectUrl>https://github.com/MoonsideGames/MoonTools.Core.Bonk</PackageProjectUrl>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<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="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.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// Used to quickly check if two shapes are potentially overlapping.

View File

@ -1,6 +1,7 @@
using MoonTools.Structs;
using System;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
public interface IHasAABB2D
{

View File

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

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// A Minkowski difference between two shapes.

View File

@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
public struct MultiShape : IHasAABB2D
{

View File

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

View File

@ -1,7 +1,7 @@
using MoonTools.Structs;
using MoonTools.Core.Structs;
using System.Numerics;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
public static class NarrowPhase
{
@ -60,7 +60,7 @@ namespace MoonTools.Bonk
}
/// <summary>
/// Tests if a multishape-transform and shape-transform pair are overlapping.
/// Tests if a multishape-transform and shape-transform pair are overlapping.
/// Note that this must perform pairwise comparison so the worst-case performance of this method will vary inversely with the amount of shapes in the multishape.
/// </summary>
/// <param name="multiShape"></param>
@ -78,7 +78,7 @@ namespace MoonTools.Bonk
}
/// <summary>
/// Tests if a multishape-transform and shape-transform pair are overlapping.
/// Tests if a multishape-transform and shape-transform pair are overlapping.
/// Note that this must perform pairwise comparison so the worst-case performance of this method will vary inversely with the amount of shapes in the multishape.
/// </summary>
/// <param name="multiShape"></param>
@ -96,7 +96,7 @@ namespace MoonTools.Bonk
}
/// <summary>
/// Tests if two multishape-transform pairs are overlapping.
/// Tests if two multishape-transform pairs are overlapping.
/// Note that this must perform pairwise comparison so the worst-case performance of this method will vary inversely with the amount of shapes in the multishapes.
/// </summary>
/// <param name="multiShapeA"></param>

View File

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

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.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.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// A line is a shape defined by exactly two points in space.

View File

@ -1,12 +1,9 @@
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// A Point is "that which has not part". All points by themselves are identical.
/// </summary>
public struct Point : IShape2D, IEquatable<Point>
{
public AABB AABB { get; }

View File

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// A Shape defined by an arbitrary collection of vertices.
@ -59,7 +59,7 @@ namespace MoonTools.Bonk
public bool Equals(IShape2D other)
{
return other is Polygon otherPolygon && Equals(otherPolygon);
return (other is Polygon otherPolygon && Equals(otherPolygon));
}
public bool Equals(Polygon other)

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
/// <summary>
/// A rectangle is a shape defined by a width and height. The origin is the center of the rectangle.

View File

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

View File

@ -1,11 +1,11 @@
using System;
using System.Numerics;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
public struct SweepResult<T> where T : IEquatable<T>
{
public readonly static SweepResult<T> False = new SweepResult<T>();
public static SweepResult<T> False = new SweepResult<T>();
public bool Hit { get; }
public Vector2 Motion { get; }

View File

@ -1,8 +1,8 @@
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Core.Structs;
namespace MoonTools.Bonk
namespace MoonTools.Core.Bonk
{
public static class SweepTest
{
@ -100,7 +100,7 @@ namespace MoonTools.Bonk
nearestTransform = shapeTransform;
}
}
}
if (nearestRectangle.HasValue)

View File

@ -1,6 +1,6 @@
using System.Numerics;
namespace MoonTools.Bonk.Extensions
namespace MoonTools.Core.Bonk.Extensions
{
internal static class Vector2Extensions
{
@ -15,4 +15,4 @@ namespace MoonTools.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.Bonk
# MoonTools.Core.Bonk
[![NuGet Badge](https://buildstats.info/nuget/MoonTools.Bonk)](https://www.nuget.org/packages/MoonTools.Bonk/)
[![Build Status](https://gitea.drone.moonside.games/api/badges/MoonsideGames/MoonTools.Bonk/status.svg)](https://gitea.drone.moonside.games/MoonsideGames/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)
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.Bonk;
using MoonTools.Core.Bonk;
using System.Numerics;
namespace Tests

View File

@ -3,8 +3,8 @@ using FluentAssertions;
using System;
using System.Numerics;
using MoonTools.Structs;
using MoonTools.Bonk;
using MoonTools.Core.Structs;
using MoonTools.Core.Bonk;
namespace Tests
{
@ -27,7 +27,7 @@ namespace Tests
intersection.X.Should().Be(1f);
intersection.Y.Should().Be(0);
var movedTransform = new Transform2D(transformA.Position - (intersection * 2)); // move past
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit 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 * 2)); // move past
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit past
NarrowPhase.TestCollision(circleA, movedTransform, circleB, transformB).Should().BeFalse();
}
@ -71,10 +71,7 @@ namespace Tests
var intersection = NarrowPhase.Intersect(line, transformA, square, transformB, simplex);
intersection.X.Should().Be(1);
intersection.Y.Should().Be(-1);
var movedTransform = new Transform2D(transformA.Position - (intersection * 2)); // move past
var movedTransform = new Transform2D(transformA.Position - (intersection * 1.01f)); // move a tiny bit past
NarrowPhase.TestCollision(line, movedTransform, square, transformB).Should().BeFalse();
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
@ -12,4 +12,4 @@
<ItemGroup>
<ProjectReference Include="..\Bonk\Bonk.csproj" />
</ItemGroup>
</Project>
</Project>