From 272c555f6b893a05f6d6a6439d519036e9379075 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Fri, 12 Aug 2011 20:55:07 -0400 Subject: do not check child nodes of a node at which the distance to the bounding box is further than a triangle the ray/photon has already intersected --- src/intersect.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/intersect.h') diff --git a/src/intersect.h b/src/intersect.h index c400f1c..d2f54ce 100644 --- a/src/intersect.h +++ b/src/intersect.h @@ -60,7 +60,7 @@ __device__ bool intersect_triangle(const float3 &origin, const float3 &direction angle between the ray and the plane normal to determine the brightness. `direction` must be normalized. */ -__device__ int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2, const int base_color=0xFFFFFFFF) +__device__ unsigned int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2, const unsigned int base_color=0xFFFFFFFF) { float scale = dot(normalize(cross(v1-v0,v2-v1)),-direction); @@ -82,7 +82,7 @@ __device__ int get_color(const float3 &direction, const float3 &v0, const float3 direction `direction` and the axis-aligned box defined by the opposite vertices `lower_bound` and `upper_bound`. If the ray intersects the box return True, else return False. */ -__device__ bool intersect_box(const float3 &origin, const float3 &direction, const float3 &lower_bound, const float3 &upper_bound) +__device__ bool intersect_box(const float3 &origin, const float3 &direction, const float3 &lower_bound, const float3 &upper_bound, float& distance_to_box) { float kmin, kmax, kymin, kymax, kzmin, kzmax; @@ -149,6 +149,8 @@ __device__ bool intersect_box(const float3 &origin, const float3 &direction, con if (kmin > kmax) return false; + distance_to_box = kmin; + return true; } -- cgit