vrld / HC

General purpose collision detection library for the use with LÖVE.
http://hc.readthedocs.org/
404 stars 48 forks source link

Added raycast function #70

Closed rzvxa closed 10 months ago

xiejiangzhi commented 10 months ago

This code is terrible, why are you querying a box? instead of cells that go straight through it? You can learn about Bresenham's line algorithm and modify it a little to get all the grids that the line passes through.

rzvxa commented 10 months ago

Hello, Thanks for spending the time and reading through the code. I'm aware that this implementation isn't the best approach to the raycasting. I wanted to implement it with what is available in the library to get it out as fast as possible. Since it is a new feature and doesn't break any already established code there was no reason to keep it in the dev branch. We can always improve the performance of the raycasting without changing the interface by changing its query function.

Feel free to create a PR for it.