Compare commits

...

13 Commits

Author SHA1 Message Date
cosmonaut c7fa0932d6 update drone
continuous-integration/drone/push Build is passing Details
2021-01-04 23:41:19 -08:00
cosmonaut e57bae4c44 bump immutable collections
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-12-21 14:30:40 -08:00
cosmonaut 094cf4b3d2 specify x64
continuous-integration/drone/push Build is passing Details
2020-11-22 16:54:28 -08:00
Evan Hemsley e6bab0de5e some minor cleanups
continuous-integration/drone/push Build is passing Details
2020-07-18 13:19:36 -07:00
Evan Hemsley b152755481 8.0.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-02-21 00:21:54 -08:00
Evan Hemsley 401f827b69 integrate namespace changes
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is failing Details
2020-02-21 00:03:47 -08:00
Evan Hemsley bcc0d0abc2 Merge remote-tracking branch 'github/multishape' 2020-02-21 00:01:02 -08:00
Evan Hemsley 137f0a90b5 add droneCI badge
continuous-integration/drone/push Build is passing Details
2020-02-20 18:39:41 -08:00
Evan Hemsley 29ce203452 7.0.1
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-02-20 18:32:10 -08:00
Evan Hemsley fa42ae77be forgot reference to core
continuous-integration/drone/push Build is passing Details
2020-02-20 18:30:00 -08:00
Evan Hemsley a46dd831d3 7.0.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-02-20 18:14:49 -08:00
Evan Hemsley 777af13171 change to droneCI
continuous-integration/drone/push Build is passing Details
2020-02-20 18:13:29 -08:00
Evan Hemsley d0b72d1749 change namespace 2020-02-20 18:07:59 -08:00
29 changed files with 101 additions and 115 deletions

View File

@ -1,46 +0,0 @@
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*)?$/

24
.drone.yml Normal file
View File

@ -0,0 +1,24 @@
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.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// Axis-aligned bounding box.
@ -26,11 +26,13 @@ namespace MoonTools.Core.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,28 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>6.0.0</Version>
<Version>8.0.1</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>.NET Core High Performance Collision Detection</Description>
<PackageId>MoonTools.Core.Bonk</PackageId>
<RootNamespace>MoonTools.Core.Bonk</RootNamespace>
<Description>.NET Standard High Performance Collision Detection</Description>
<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>
<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="MoonTools.Core.Structs" Version="3.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<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,7 +1,6 @@
using System;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public interface IHasAABB2D
{

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 : IHasAABB2D, 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.

View File

@ -1,9 +1,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
{
public struct MultiShape : IHasAABB2D
{

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
{
@ -60,7 +60,7 @@ namespace MoonTools.Core.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.Core.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.Core.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.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,9 +1,12 @@
using System;
using System.Numerics;
using MoonTools.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.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.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
/// <summary>
/// A Shape defined by an arbitrary collection of vertices.
@ -59,7 +59,7 @@ namespace MoonTools.Core.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.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.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.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,11 +1,11 @@
using System;
using System.Numerics;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public struct SweepResult<T> where T : IEquatable<T>
{
public static SweepResult<T> False = new SweepResult<T>();
public readonly 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.Core.Structs;
using MoonTools.Structs;
namespace MoonTools.Core.Bonk
namespace MoonTools.Bonk
{
public static class SweepTest
{
@ -100,7 +100,7 @@ namespace MoonTools.Core.Bonk
nearestTransform = shapeTransform;
}
}
}
if (nearestRectangle.HasValue)

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/)
[![Build Status](https://gitea.drone.moonside.games/api/badges/MoonsideGames/MoonTools.Bonk/status.svg)](https://gitea.drone.moonside.games/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
{
@ -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();
}
@ -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;

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;
using System.Collections.Immutable;

View File

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

View File

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