range_libc
range_libc copied to clipboard
CDDTCast does not always honor max range
When using CDDTCast, the max_range parameter is not always honored. The behavior seems to be limited to two scenarios.
Let's say max_range is set to 30.0:
- An obstacle lies along the ray being cast at a true range of 50.0.
CDDTCast::calc_range()will return 50.0 (incorrect, 30.0 expected). - No obstacle lies along the ray being cast (the map is open).
CDDTCast::calc_range()will return 30.0 (correct).
It's not immediately obvious where the bug itself is because the algorithm is so complex and has lots of return statements. I'm not sure what a proper fix is but a workaround would be to clamp the max range returned by CDDTCast::calc_range().
The other raycasting methods Bresenham (BL), Ray Marching (RM), and Giant Lookup Table (GLT) are not affected.