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

View File

@ -1,28 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Version>6.0.0</Version> <Version>8.0.1</Version>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Description>.NET Core High Performance Collision Detection</Description> <Description>.NET Standard High Performance Collision Detection</Description>
<PackageId>MoonTools.Core.Bonk</PackageId> <PackageId>MoonTools.Bonk</PackageId>
<RootNamespace>MoonTools.Core.Bonk</RootNamespace> <RootNamespace>MoonTools.Bonk</RootNamespace>
<Company>Moonside Games</Company> <Company>Moonside Games</Company>
<Authors>Evan Hemsley</Authors> <Authors>Evan Hemsley</Authors>
<Copyright>Evan Hemsley 2019</Copyright> <Copyright>Evan Hemsley 2019</Copyright>
<Product>MoonTools.Core.Bonk</Product> <Product>MoonTools.Bonk</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyName>MoonTools.Core.Bonk</AssemblyName> <AssemblyName>MoonTools.Bonk</AssemblyName>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression> <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> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.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="3.0.0" /> <PackageReference Include="System.Collections.Immutable" Version="1.7.1" />
<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" />
<PackageReference Include="MoonTools.Structs" Version="3.0.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,12 @@
using System; using System;
using System.Numerics; 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 struct Point : IShape2D, IEquatable<Point>
{ {
public AABB AABB { get; } public AABB AABB { get; }

View File

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

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Numerics; using System.Numerics;
using MoonTools.Core.Structs; using MoonTools.Structs;
namespace MoonTools.Core.Bonk namespace MoonTools.Bonk
{ {
/// <summary> /// <summary>
/// A rectangle is a shape defined by a width and height. The origin is the center of the rectangle. /// 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.Collections.Generic;
using System.Numerics; using System.Numerics;
using MoonTools.Core.Structs; using MoonTools.Structs;
using System; using System;
namespace MoonTools.Core.Bonk namespace MoonTools.Bonk
{ {
/// <summary> /// <summary>
/// A simplex is a shape with up to n - 2 vertices in the nth dimension. /// 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;
using System.Numerics; using System.Numerics;
namespace MoonTools.Core.Bonk namespace MoonTools.Bonk
{ {
public struct SweepResult<T> where T : IEquatable<T> 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 bool Hit { get; }
public Vector2 Motion { get; } public Vector2 Motion { get; }

View File

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

View File

@ -1,6 +1,6 @@
using System.Numerics; using System.Numerics;
namespace MoonTools.Core.Bonk.Extensions namespace MoonTools.Bonk.Extensions
{ {
internal static class Vector2Extensions internal static class Vector2Extensions
{ {

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/) [![NuGet Badge](https://buildstats.info/nuget/MoonTools.Bonk)](https://www.nuget.org/packages/MoonTools.Bonk/)
[![CircleCI](https://circleci.com/gh/MoonsideGames/MoonTools.Core.Bonk.svg?style=svg)](https://circleci.com/gh/MoonsideGames/MoonTools.Core.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. 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 NUnit.Framework;
using FluentAssertions; using FluentAssertions;
using MoonTools.Core.Bonk; using MoonTools.Bonk;
using System.Numerics; using System.Numerics;
namespace Tests namespace Tests

View File

@ -3,8 +3,8 @@ using FluentAssertions;
using System; using System;
using System.Numerics; using System.Numerics;
using MoonTools.Core.Structs; using MoonTools.Structs;
using MoonTools.Core.Bonk; using MoonTools.Bonk;
namespace Tests namespace Tests
{ {
@ -27,7 +27,7 @@ namespace Tests
intersection.X.Should().Be(1f); intersection.X.Should().Be(1f);
intersection.Y.Should().Be(0); 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(); NarrowPhase.TestCollision(squareA, movedTransform, squareB, transformB).Should().BeFalse();
} }
@ -52,7 +52,7 @@ namespace Tests
intersection.X.Should().BeApproximately(ix, 0.01f); intersection.X.Should().BeApproximately(ix, 0.01f);
intersection.Y.Should().BeApproximately(iy, 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(); NarrowPhase.TestCollision(circleA, movedTransform, circleB, transformB).Should().BeFalse();
} }
@ -71,7 +71,10 @@ namespace Tests
var intersection = NarrowPhase.Intersect(line, transformA, square, transformB, simplex); 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(); NarrowPhase.TestCollision(line, movedTransform, square, transformB).Should().BeFalse();
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>