just released Bonk, an open source collision detection library for MonoGame Core. this is the tool we are using for collision detection on Samurai Gunn 2

- extremely modular design
- implements line, circle, rectangle, and convex polygons
- spatial hash for broad phase
- GJK for narrow phase
- EPA for separating vector
- 0 heap allocations (no garbage collection)

licensed under LGPL 3

i am going on vacation tomorrow so i dont have time to release docs for this but i will do so right when i get back. in the meantime there is a link to the source.

but essentially the way it is structured is that for each collision check you have a separate Shape and Transform (position, rotation, scale) that modifies the Shape vertices. that way you can easily use collision shapes in conjunction with a transform without needing to constantly update the Shape itself.

another choice i made was to use integer positions for Transforms. the way this works is that Position2D stores carryover. when positions are added, the carryovers are added too. this way no information is lost but you still have the convenience of actual pixel-perfect collision so you dont get discrepancies in 2D rendering.

@dankwraith yay! i'm glad you picked it! congrats on the release :)

@dankwraith I might actually unironically be interested in this, thanks!

@hirojin the power of structs. also technically the spatial hash uses a Dictionary but you will never remove a spatial hash during gameplay so GC is negligible. narrow phase detection and separating vector calculation have absolutely no heap allocations at all

@dankwraith C# has become a very different language since i left (gave up) school

@dankwraith you know what i don't get about programming languages anymore?

why people say Lisp is unreadable, but this is somehow okay

@dankwraith (the easiest way i have found so far to avoid these, is to write Erlang 🤷‍♀️)

Sign in to participate in the conversation is one server in the network