mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-21 20:29:59 +01:00
Fix distance overflow
This commit is contained in:
parent
c813602947
commit
256221c6a2
1 changed files with 11 additions and 5 deletions
16
raycastlib.h
16
raycastlib.h
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
author: Miloslav "drummyfish" Ciz
|
author: Miloslav "drummyfish" Ciz
|
||||||
license: CC0 1.0
|
license: CC0 1.0
|
||||||
version: 0.90
|
version: 0.901
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -855,8 +855,11 @@ void RCL_castRayMultiHit(RCL_Ray ray, RCL_ArrayFunction arrayFunc,
|
||||||
divided by leg B (length along the same axis). */
|
divided by leg B (length along the same axis). */
|
||||||
|
|
||||||
h.distance =
|
h.distance =
|
||||||
((h.position.x - ray.start.x) * RCL_UNITS_PER_SQUARE * rayDirXRecip)
|
(((h.position.x - ray.start.x) / 4) *
|
||||||
/ RECIP_SCALE;
|
RCL_UNITS_PER_SQUARE * rayDirXRecip)
|
||||||
|
/ (RECIP_SCALE / 4);
|
||||||
|
|
||||||
|
// ^ / 4 is here to prevent overflow
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -877,8 +880,11 @@ void RCL_castRayMultiHit(RCL_Ray ray, RCL_ArrayFunction arrayFunc,
|
||||||
|
|
||||||
#if RCL_RECTILINEAR
|
#if RCL_RECTILINEAR
|
||||||
h.distance =
|
h.distance =
|
||||||
((h.position.y - ray.start.y) * RCL_UNITS_PER_SQUARE * rayDirYRecip)
|
(((h.position.y - ray.start.y) / 4) *
|
||||||
/ RECIP_SCALE;
|
RCL_UNITS_PER_SQUARE * rayDirYRecip)
|
||||||
|
/ (RECIP_SCALE / 4);
|
||||||
|
|
||||||
|
// ^ / 4 is here to prevent overflow
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue