made it easier to rip this code out of heresyrl, do add coord.[ch] though