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.

Show thread

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.

Show thread

@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 a community for goth nerds, aka people who are interested in the intersections of math, art, programming, philosophy, and related topics. this does not include your techbro ass. we also enjoy a healthy amount of shitposting. if you are a techno-materialist, technocrat, or some flavor of capitalist, don't even bother applying. if you are interested in an account please fill out an application, detailing why you are interested in joining, what you have to bring to the community, and your prior, if any, accounts on the fediverse.