summaryrefslogtreecommitdiff
path: root/src/modules/ray/ray_object_plane.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-08-08 09:42:30 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-08-15 16:46:40 -0700
commitadb76b79d39a185be4659193baff0cb1fe043506 (patch)
treefdc51e2d986e7ef6bd22d0897bdbca10ed51f550 /src/modules/ray/ray_object_plane.h
parent760112de102f36ba5aaf16d9e949d0bfa3623175 (diff)
ray: misc computational fixups
ray:object intersection coordinates were incorrectly being computed relative to the ray origin using a subtraction instead of addition, a silly mistake with surprisingly acceptable results. Those results were a result of other minor complementary mistakes compensating to produce reasonable looking results. In the course of experimenting with an acceleration data structure it became very apparent that 3d space traversal vectors were not behaving as intended, leading to review and correction of this code.
Diffstat (limited to 'src/modules/ray/ray_object_plane.h')
-rw-r--r--src/modules/ray/ray_object_plane.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/modules/ray/ray_object_plane.h b/src/modules/ray/ray_object_plane.h
index 490238c..0d3a51b 100644
--- a/src/modules/ray/ray_object_plane.h
+++ b/src/modules/ray/ray_object_plane.h
@@ -29,14 +29,14 @@ static inline int ray_object_plane_intersects_ray(ray_object_plane_t *plane, uns
{
float d = ray_3f_dot(&plane->normal, &ray->direction);
- if (d >= 0.00001f) {
+ if (d < 0.0f) {
float distance = plane->_prepared.primary_dot_plus;
if (depth)
distance = (ray_3f_dot(&plane->normal, &ray->origin) + plane->distance);
- distance /= d;
- if (distance > 0) {
+ distance /= -d;
+ if (distance > 0.0f) {
*res_distance = distance;
return 1;
© All Rights Reserved