Sabbatical Log: November 5th

This blog series is running about a week behind my actual work, giving me time to clean things up.  The date the actual work was done is in the title, horizontal lines indicate when I stopped writing and started coding.

Starting off today I’ve got a lot of code that almost works, finding collisions on single axes quite reliably. Now I need to get it actually detecting collisions properly.


I’ve now got collision working. My general fix was to use the single axis code to find candidate times for each polygon pair, and then iterate through them finding the earliest time where all axes were colliding (if any).

I did have to introduce a notion of “tolerance” in overlap detection because of error accumulation. I’ve settled on 1/10,000,000 for now, we’ll see how that plays out in practice.

Next up, some performance work on this system. I focused on getting it correct, now I’d like to get it allocation free.

Side note: hand verifying collision test cases is rather painful. However, I’ve now got 45 separate test cases to detect regressions, and that’s going to be very helpful going forward.


After a couple hours work, I’ve removed all allocations and System.Collections(.Generic) reference from the collision detection subsystem. I did this with my pretty standard tricks of custom enumerables, and pre-allocated buffers. I also got some performance improvements by not recalculating things that will never change (like normals) and by treated polygons as translations of a basic “polygon pattern.”

Now I need to actually integrate the collision detection into a proper ASystem, and get some stuff on the screen. I think I’ll start by building a “pen” with some different shapes in it, and see whether all of this work is actually useful.


While working on the collision system, I found I needed to remove a number of hacks. Things like: actually tracking velocity, rendering more than one entity, having a notion of a hitmap, and so on. End result, collision system still isn’t done but now there’s a slooooowly sliding triangle on the screen.

Woooooooo

Continue onto November 6th