[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59418] trunk/blender/intern/cycles: Code cleanup / Cycles:

Thomas Dinges blender at dingto.org
Fri Aug 23 14:19:35 CEST 2013


Revision: 59418
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59418
Author:   dingto
Date:     2013-08-23 12:19:35 +0000 (Fri, 23 Aug 2013)
Log Message:
-----------
Code cleanup / Cycles:
* Some style tweaks for hair code. 

Modified Paths:
--------------
    trunk/blender/intern/cycles/kernel/kernel_bvh.h
    trunk/blender/intern/cycles/render/curves.cpp

Modified: trunk/blender/intern/cycles/kernel/kernel_bvh.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_bvh.h	2013-08-23 11:46:08 UTC (rev 59417)
+++ trunk/blender/intern/cycles/kernel/kernel_bvh.h	2013-08-23 12:19:35 UTC (rev 59418)
@@ -26,8 +26,8 @@
  */
 
 /* bottom-most stack entry, indicating the end of traversal */
-
 #define ENTRYPOINT_SENTINEL 0x76543210
+
 /* 64 object BVH + 64 mesh BVH + 64 object node splitting */
 #define BVH_STACK_SIZE 192
 #define BVH_NODE_SIZE 4
@@ -215,21 +215,20 @@
 	float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
 {
 	float epsilon = 0.0f;
-	int depth = kernel_data.curve.subdivisions;
+	float r_st, r_en;
 
-	/* curve Intersection check */
-	float3 dir = 1.0f/idir;
-	
+	int depth = kernel_data.curve.subdivisions;
 	int flags = kernel_data.curve.curveflags;
-
 	int prim = kernel_tex_fetch(__prim_index, curveAddr);
-
+	
 	float3 curve_coef[4];
-	float r_st,r_en;
 
-	/*obtain curve parameters*/
+	/* curve Intersection check */
+	float3 dir = 1.0f/idir;
+
+	/* obtain curve parameters */
 	{
-		/*ray transform created - this should be created at beginning of intersection loop*/
+		/* ray transform created - this should be created at beginning of intersection loop */
 		Transform htfm;
 		float d = sqrtf(dir.x * dir.x + dir.z * dir.z);
 		htfm = make_transform(
@@ -271,15 +270,15 @@
 	if((flags & CURVE_KN_RIBBONS) || !(flags & CURVE_KN_BACKFACING))
 		epsilon = 2 * r_curr;
 
-	/*find bounds - this is slow for cubic curves*/
-	float upper,lower;
+	/* find bounds - this is slow for cubic curves */
+	float upper, lower;
 
 	float zextrem[4];
 	curvebounds(&lower, &upper, &zextrem[0], &zextrem[1], &zextrem[2], &zextrem[3], curve_coef[0].z, curve_coef[1].z, curve_coef[2].z, curve_coef[3].z);
 	if(lower - r_curr > isect->t || upper + r_curr < epsilon)
 		return false;
 
-	/*minimum width extension*/
+	/* minimum width extension */
 	float mw_extension = min(difl * fabsf(upper), extmax);
 	float r_ext = mw_extension + r_curr;
 
@@ -293,13 +292,13 @@
 	if(lower > r_ext || upper < -r_ext)
 		return false;
 
-	/*setup recurrent loop*/
+	/* setup recurrent loop */
 	int level = 1 << depth;
 	int tree = 0;
 	float resol = 1.0f / (float)level;
 	bool hit = false;
 
-	/*begin loop*/
+	/* begin loop */
 	while(!(tree >> (depth))) {
 		float i_st = tree * resol;
 		float i_en = i_st + (level * resol);
@@ -347,7 +346,7 @@
 		float coverage = 1.0f;
 
 		if (bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext|| bmaxx < -r_ext|| bminy > r_ext|| bmaxy < -r_ext) {
-			/* the bounding box does not overlap the square centered at O.*/
+			/* the bounding box does not overlap the square centered at O */
 			tree += level;
 			level = tree & -tree;
 		}
@@ -369,10 +368,10 @@
 				w = -(p_st.x * tg.x + p_st.y * tg.y) / w;
 				w = clamp((float)w, 0.0f, 1.0f);
 
-				/* compute u on the curve segment.*/
+				/* compute u on the curve segment */
 				u = i_st * (1 - w) + i_en * w;
 				r_curr = r_st + (r_en - r_st) * u;
-				/* compare x-y distances.*/
+				/* compare x-y distances */
 				float3 p_curr = ((curve_coef[3] * u + curve_coef[2]) * u + curve_coef[1]) * u + curve_coef[0];
 
 				float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1];
@@ -412,7 +411,7 @@
 					level = tree & -tree;
 					continue;
 				}
-				/* compare z distances.*/
+				/* compare z distances */
 				if (isect->t < p_curr.z) {
 					tree++;
 					level = tree & -tree;
@@ -422,7 +421,7 @@
 			}
 			else {
 				float l = len(p_en - p_st);
-				/*minimum width extension*/
+				/* minimum width extension */
 				float or1 = r1;
 				float or2 = r2;
 				if(difl != 0.0f) {
@@ -477,16 +476,16 @@
 				}
 
 				w = clamp((float)w, 0.0f, 1.0f);
-				/* compute u on the curve segment.*/
+				/* compute u on the curve segment */
 				u = i_st * (1 - w) + i_en * w;
 				r_curr = r1 + (r2 - r1) * w;
 				r_ext = or1 + (or2 - or1) * w;
 				coverage = r_curr/r_ext;
 
 			}
-			/* we found a new intersection.*/
+			/* we found a new intersection */
 
-			/*stochastic fade from minimum width*/
+			/* stochastic fade from minimum width */
 			if(lcg_state && coverage != 1.0f) {
 				if(lcg_step_float(lcg_state) > coverage)
 					return hit;
@@ -542,7 +541,7 @@
 	float3 p1 = float4_to_float3(P1);
 	float3 p2 = float4_to_float3(P2);
 
-	/*minimum width extension*/
+	/* minimum width extension */
 	float r1 = or1;
 	float r2 = or2;
 	if(difl != 0.0f) {
@@ -567,7 +566,7 @@
 	if(sdisc < 0.0f)
 		return false;
 
-	/* obtain parameters and test midpoint distance for suitable modes*/
+	/* obtain parameters and test midpoint distance for suitable modes */
 	float3 tg = (p2 - p1) / l;
 	float gd = (r2 - r1) / l;
 	float dirz = dot(dir,tg);
@@ -584,7 +583,7 @@
 	if((zcentre < 0 || zcentre > l) && !(flags & CURVE_KN_ACCURATE) && !(flags & CURVE_KN_INTERSECTCORRECTION))
 		return false;
 
-	/* test minimum separation*/
+	/* test minimum separation */
 	float3 cprod = cross(tg, dir);
 	float3 cprod2 = cross(tg, dif);
 	float cprodsq = len_squared(cprod);
@@ -599,7 +598,7 @@
 	if(distscaled > mr*mr)
 		return false;
 
-	/* calculate true intersection*/
+	/* calculate true intersection */
 	float3 tdif = P - p1 + tcentre * dir;
 	float tdifz = dot(tdif,tg);
 	float tb = 2*(dot(dir,tdif) - dirz*(tdifz + gd*(tdifz*gd + r1)));
@@ -636,7 +635,7 @@
 			z = zcentre + (dirz * correction);
 		}
 
-		/*stochastic fade from minimum width*/
+		/* stochastic fade from minimum width */
 		float adjradius = or1 + z * (or2 - or1) / l;
 		adjradius = adjradius / (r1 + z * gd);
 		if(lcg_state && adjradius != 1.0f) {

Modified: trunk/blender/intern/cycles/render/curves.cpp
===================================================================
--- trunk/blender/intern/cycles/render/curves.cpp	2013-08-23 11:46:08 UTC (rev 59417)
+++ trunk/blender/intern/cycles/render/curves.cpp	2013-08-23 12:19:35 UTC (rev 59418)
@@ -35,12 +35,14 @@
 	float *p1 = &p[1].x;
 	float *p2 = &p[2].x;
 	float *p3 = &p[3].x;
+
 	float fc = 0.71f;
 	float curve_coef[4];
 	curve_coef[0] = p1[dim];
 	curve_coef[1] = -fc*p0[dim] + fc*p2[dim];
 	curve_coef[2] = 2.0f * fc * p0[dim] + (fc - 3.0f) * p1[dim] + (3.0f - 2.0f * fc) * p2[dim] - fc * p3[dim];
 	curve_coef[3] = -fc * p0[dim] + (2.0f - fc) * p1[dim] + (fc - 2.0f) * p2[dim] + fc * p3[dim];
+
 	float discroot = curve_coef[2] * curve_coef[2] - 3 * curve_coef[3] * curve_coef[1];
 	float ta = -1.0f;
 	float tb = -1.0f;
@@ -70,7 +72,6 @@
 	}
 	*upper = max(*upper, max(exa,exb));
 	*lower = min(*lower, min(exa,exb));
-	
 }
 
 /* Hair System Manager */




More information about the Bf-blender-cvs mailing list