fix some references
continuous-integration/drone/push Build is failing Details

main
Evan Hemsley 2020-07-18 03:28:28 -07:00
parent 9176c395f4
commit 03afbe4442
5 changed files with 14 additions and 15 deletions

View File

@ -4,7 +4,7 @@ title: "Bonk"
# Bonk
[Bonk](https://github.com/MoonsideGames/MoonTools.Core.Bonk) is a fast and modular collision detection system for MonoGame that is part of the MoonTools suite.
[Bonk](https://gitea.moonside.games/MoonsideGames/MoonTools.Bonk) is a fast and modular collision detection system for MonoGame that is part of the MoonTools suite.
Bonk **is** designed to help you figure out if two shapes are overlapping and by how much.
@ -12,6 +12,6 @@ Bonk **is not** a physics simulator and it will not help you execute collision r
Bonk is designed for performance and memory efficiency. Defining shapes and performing collision tests require no heap allocations and thus put no pressure on the garbage collector. If you reuse spatial hashes, Bonk will never cause garbage collection.
Bonk is available as a [NuGet package](https://www.nuget.org/packages/MoonTools.Core.Bonk/) and can also be included in your project [from source](https://github.com/MoonsideGames/MoonTools.Core.Bonk).
Bonk is available as a [NuGet package](https://www.nuget.org/packages/MoonTools.Bonk/) and can also be included in your project [from source](https://gitea.moonside.games/MoonsideGames/MoonTools.Bonk).
Bonk is licensed under the [LGPL-3](https://www.gnu.org/licenses/lgpl-3.0.en.html) license. In summary: feel free to include it in your closed-source game and modify it internally at will, but if you make changes that you intend to redistribute, you **must** freely publish your changes.

View File

@ -33,7 +33,7 @@ Given an ID, a shape, and corresponding transform, inserts into the spatial hash
```cs
var hash = new SpatialHash<int>(16);
var circle = new MoonTools.Core.Bonk.Circle(8);
var circle = new MoonTools.Bonk.Circle(8);
var circleTransform = new Transform2D(new Vector2(16, 16));
var rect = new Rectangle(-2, -2, 2, 2);
@ -54,7 +54,7 @@ Given an ID, a shape, and corresponding transform, retrieves a set of potential
```cs
var hash = new SpatialHash<int>(16);
var circle = new MoonTools.Core.Bonk.Circle(8);
var circle = new MoonTools.Bonk.Circle(8);
var circleTransform = new Transform2D(new Vector2(16, 16));
var rect = new Rectangle(-2, -2, 2, 2);
@ -74,4 +74,4 @@ If a potential colliding shape-transform has the same ID as the one passed into
##### **public void Clear()**
Empties the spatial hash. Useful when the spatial hash contains dynamic data that needs to be updated.
Empties the spatial hash. Useful when the spatial hash contains dynamic data that needs to be updated.

View File

@ -14,14 +14,14 @@ var hash = new SpatialHash<Guid>(32);
This spatial hash will use C# **GUID**s as its ID type and a cell width of 32.
There is an art to choosing a cell width. If your cell width is too small relative to the objects in your game, then your objects will occupy many cells, and the hash check will have to check all of those cells for potential collisions. If your cell width is too large, then many objects will be contained in each cell. You are looking for a sweet spot. My rule of thumb is picking a cell width that is roughly twice the size of the most common objects in your game.
There is an art to choosing a cell width. If your cell width is too small relative to the objects in your game, then your objects will occupy many cells, and the hash check will have to check all of those cells for potential collisions. If your cell width is too large, then many objects will be contained in each cell. You are looking for a sweet spot. My rule of thumb is picking a cell width that is roughly twice the size of the most common objects in your game.
To insert an object into the hash, use the **Insert** method and give an ID, an IShape2D, and a Transform2D.
```cs
var hash = new SpatialHash<int>(16);
var circle = new MoonTools.Core.Bonk.Circle(8);
var circle = new MoonTools.Bonk.Circle(8);
var circleTransform = new Transform2D(new Vector2(16, 16));
var rect = new Rectangle(-2, -2, 2, 2);
@ -47,4 +47,4 @@ hash.Clear();
// Re-insert objects here
```
That's it! This is everything you need to use a spatial hash for broad-phase collision.
That's it! This is everything you need to use a spatial hash for broad-phase collision.

View File

@ -8,21 +8,21 @@ The simplest way of using Bonk is by including it in your C# project as a NuGet
To include the latest version of Bonk in your project using the .NET CLI, use the following command:
```sh
dotnet add package MoonTools.Core.Bonk
dotnet add package MoonTools.Bonk
```
If you are using the NuGet Package Manager, you may do:
```sh
PM> Install-Package MoonTools.Core.Bonk
PM> Install-Package MoonTools.Bonk
```
Once you have done this, you may access Bonk functionality by including
```cs
using MoonTools.Core.Bonk;
using MoonTools.Bonk;
```
in any C# file.
Of course, you are free to include the source code directly in your project as well, but this is less convenient.
Of course, you are free to include the source code directly in your project as well, but this is less convenient.

View File

@ -4,11 +4,10 @@ date: 2019-09-14T23:08:31-07:00
weight: 5
---
Bonk uses the *Transform2D* struct which is taken from the MoonTools.Core.Structs package. By extension it also uses the *Position2D* struct taken from the same package.
Bonk uses the *Transform2D* struct which is taken from the MoonTools.Structs package. By extension it also uses the *Position2D* struct taken from the same package.
A *Transform2D* is basically a way to store information about an object's location, rotation, and scale in 2-dimensional space. Transforms use matrix math to perform all of these operations at once, making them very fast.
For memory performance purposes, shapes are implemented as structs, meaning they are value types. This means that it is much easier to deal with collision using a transform applied to a shape, rather than containing a transform within the shape.
For memory performance purposes, shapes are implemented as structs, meaning they are value types. This means that it is much easier to deal with collision using a transform applied to a shape, rather than containing a transform within the shape.
It is also often the case that you will have a shape attached to a game object that is offset from the object by a certain amount. A *Transform2D* can represent this information as well, since *Tranform2Ds* can be composed together. As you can see, a *Transform2D* provides a generic structure for dealing with many scenarios involving 2D space.