[Bf-blender-cvs] [40f79cf] master: Cycles / Hair: Avoid duplicate calculations and remove redundant if branch, instead add the condition to the one above.

Thomas Dinges noreply at git.blender.org
Thu Dec 26 21:53:00 CET 2013


Commit: 40f79cf6e7b4d90380641ea704ab29ca0a4231cd
Author: Thomas Dinges
Date:   Thu Dec 26 21:52:23 2013 +0100
https://developer.blender.org/rB40f79cf6e7b4d90380641ea704ab29ca0a4231cd

Cycles / Hair: Avoid duplicate calculations and remove redundant if branch, instead add the condition to the one above.

===================================================================

M	intern/cycles/kernel/kernel_bvh.h

===================================================================

diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h
index 6c5bac5..c1595f6 100644
--- a/intern/cycles/kernel/kernel_bvh.h
+++ b/intern/cycles/kernel/kernel_bvh.h
@@ -406,17 +406,12 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
 						coverage = (min(d1 / mw_extension, 1.0f) + min(-d0 / mw_extension, 1.0f)) * 0.5f;
 				}
 				
-				if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon) {
-					tree++;
-					level = tree & -tree;
-					continue;
-				}
-				/* compare z distances */
-				if (isect->t < p_curr.z) {
+				if (p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) {
 					tree++;
 					level = tree & -tree;
 					continue;
 				}
+
 				t = p_curr.z;
 			}
 			else {
@@ -453,7 +448,6 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
 				float rootd = sqrtf(td);
 				float correction = ((-tb - rootd)/(2*cyla));
 				t = tcentre + correction;
-				float w = (zcentre + (tg.z * correction))/l;
 
 				float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
 				if (dot(tg, dp_st)< 0)
@@ -462,11 +456,9 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
 				if (dot(tg, dp_en) < 0)
 					dp_en *= -1;
 
-
 				if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) {
 					correction = ((-tb + rootd)/(2*cyla));
 					t = tcentre + correction;
-					w = (zcentre + (tg.z * correction))/l;
 				}			
 
 				if (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) {
@@ -475,6 +467,7 @@ ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersect
 					continue;
 				}
 
+				float w = (zcentre + (tg.z * correction))/l;
 				w = clamp((float)w, 0.0f, 1.0f);
 				/* compute u on the curve segment */
 				u = i_st * (1 - w) + i_en * w;




More information about the Bf-blender-cvs mailing list