summaryrefslogtreecommitdiff
path: root/src/modules/ray
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/ray')
-rw-r--r--src/modules/ray/ray_object_plane.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/modules/ray/ray_object_plane.h b/src/modules/ray/ray_object_plane.h
index 0be28f4..5fcc619 100644
--- a/src/modules/ray/ray_object_plane.h
+++ b/src/modules/ray/ray_object_plane.h
@@ -13,11 +13,15 @@ typedef struct ray_object_plane_t {
ray_surface_t surface;
ray_3f_t normal;
float distance;
+ struct {
+ float primary_dot_plus;
+ } _prepared;
} ray_object_plane_t;
static void ray_object_plane_prepare(ray_object_plane_t *plane, ray_camera_t *camera)
{
+ plane->_prepared.primary_dot_plus = (ray_3f_dot(&plane->normal, &camera->position) + plane->distance);
}
@@ -26,8 +30,12 @@ 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) {
- float distance = (ray_3f_dot(&plane->normal, &ray->origin) + plane->distance) / d;
+ float distance = plane->_prepared.primary_dot_plus;
+ if (depth != 1)
+ distance = (ray_3f_dot(&plane->normal, &ray->origin) + plane->distance);
+
+ distance /= d;
if (distance > 0) {
*res_distance = distance;
© All Rights Reserved