From f8354b997021abf9a67868c62a23b8260af88b64 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Sun, 1 Dec 2019 22:43:33 -0800 Subject: [PATCH] updates documentation for 4.0.0 --- content/_index.md | 4 ++-- content/api/IShape2D.md | 4 ++-- content/shapes/point.md | 11 +++++++++++ content/shapes/polygon.md | 27 ++++++++++++++++++++------- 4 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 content/shapes/point.md diff --git a/content/_index.md b/content/_index.md index baba24f..74fd952 100644 --- a/content/_index.md +++ b/content/_index.md @@ -10,8 +10,8 @@ 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 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 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. \ No newline at end of file +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. diff --git a/content/api/IShape2D.md b/content/api/IShape2D.md index 513a8fe..85f9cef 100644 --- a/content/api/IShape2D.md +++ b/content/api/IShape2D.md @@ -6,7 +6,7 @@ weight: 5 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 @@ -43,4 +43,4 @@ public AABB AABB(Transform2D Transform2D) Transform2D.Position.Y + Radius ); } -``` \ No newline at end of file +``` diff --git a/content/shapes/point.md b/content/shapes/point.md new file mode 100644 index 0000000..8db6d30 --- /dev/null +++ b/content/shapes/point.md @@ -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); +``` diff --git a/content/shapes/polygon.md b/content/shapes/polygon.md index fc295e3..4961d3e 100644 --- a/content/shapes/polygon.md +++ b/content/shapes/polygon.md @@ -7,15 +7,28 @@ weight: 40 To define a polygon, pass a variable number of **Position2D** structs representing the points of the polygon. ```cs - var polygon = new Polygon( - new Position2D(-2, 0), - new Position2D(0, 2), - new Position2D(2, 0), - ); +var polygon = new Polygon( + new Position2D(-2, 0), + new Position2D(0, 2), + new Position2D(2, 0), +); ``` 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. \ No newline at end of file +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! +```