updates documentation for 4.0.0
parent
2891709536
commit
f8354b9970
|
@ -10,7 +10,7 @@ Bonk **is** designed to help you figure out if two shapes are overlapping and by
|
||||||
|
|
||||||
Bonk **is not** a physics simulator and it will not help you execute collision responses.
|
Bonk **is not** a physics simulator and it will not help you execute collision responses.
|
||||||
|
|
||||||
Bonk is designed for performance and memory efficiency. Defining most shapes and performing collision tests require no heap allocations and thus put no pressure on the garbage collector. If you reuse spatial hashes and avoid using arbitrary polygons, Bonk will never cause garbage collection.
|
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/).
|
Bonk is available as a [NuGet package](https://www.nuget.org/packages/MoonTools.Core.Bonk/).
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ weight: 5
|
||||||
|
|
||||||
An *IShape2D* is an interface that, when implemented, allows for spatial hashing and the computation of Minkowski Differences.
|
An *IShape2D* is an interface that, when implemented, allows for spatial hashing and the computation of Minkowski Differences.
|
||||||
|
|
||||||
Your *IShape2D* types should be structs for memory efficiency purposes.
|
Your *IShape2D* implementations should be structs for memory efficiency purposes.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
title: "Point"
|
||||||
|
date: 2019-12-01T22:41:00-08:00
|
||||||
|
weight: 6
|
||||||
|
---
|
||||||
|
|
||||||
|
To define a Point, pass either a **Position2D** struct or two integers.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
var point = new Point(1, 2);
|
||||||
|
```
|
|
@ -7,15 +7,28 @@ weight: 40
|
||||||
To define a polygon, pass a variable number of **Position2D** structs representing the points of the polygon.
|
To define a polygon, pass a variable number of **Position2D** structs representing the points of the polygon.
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
var polygon = new Polygon(
|
var polygon = new Polygon(
|
||||||
new Position2D(-2, 0),
|
new Position2D(-2, 0),
|
||||||
new Position2D(0, 2),
|
new Position2D(0, 2),
|
||||||
new Position2D(2, 0),
|
new Position2D(2, 0),
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
This polygon, for example, is a triangle.
|
This polygon, for example, is a triangle.
|
||||||
|
|
||||||
Be careful not to define a concave Polygon, as this will cause the results of collision detection to be incorrect.
|
Be careful not to define a concave Polygon, as this will cause the results of collision detection to be incorrect. Support for concave polygons is planned for a future release.
|
||||||
|
|
||||||
Also note that because Polygon stores its vertices in an array, instantiating Polygons will cause GC pressure. It is best to use another kind of `IShape2D` if possible.
|
Polygons are considered equal if they define the same vertices, regardless of order. They can even be equivalent to Rectangles:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
var a = new Polygon(
|
||||||
|
new Position2D(1, 1),
|
||||||
|
new Position2D(1, -1),
|
||||||
|
new Position2D(-1, -1),
|
||||||
|
new Position2D(-1, 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
var b = new Rectangle(-1, -1, 1, 1);
|
||||||
|
|
||||||
|
a == b; // true!
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue