diff options
author | Thomas Dinges <blender@dingto.org> | 2013-08-23 16:19:35 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2013-08-23 16:19:35 +0400 |
commit | f560d25666b6aa7b1451a5626525505183f8fffa (patch) | |
tree | fc5ca40a0f6ef1a31b230dde3e4b693d35e65ed5 /intern | |
parent | c752346cfa6b3bfeb99857492dc524dcfb3366f7 (diff) |
Code cleanup / Cycles:
* Some style tweaks for hair code.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/kernel_bvh.h | 55 | ||||
-rw-r--r-- | intern/cycles/render/curves.cpp | 3 |
2 files changed, 29 insertions, 29 deletions
diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h index 21320dadb44..0339ec0a3cc 100644 --- a/intern/cycles/kernel/kernel_bvh.h +++ b/intern/cycles/kernel/kernel_bvh.h @@ -26,8 +26,8 @@ CCL_NAMESPACE_BEGIN */ /* 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio level = tree & -tree; continue; } - /* compare z distances.*/ + /* compare z distances */ if (isect->t < p_curr.z) { tree++; level = tree & -tree; @@ -422,7 +421,7 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio } 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 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio } 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 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, 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 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, 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 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, 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 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, 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 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, 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) { diff --git a/intern/cycles/render/curves.cpp b/intern/cycles/render/curves.cpp index fd2b4b5c7e9..5730b5218ca 100644 --- a/intern/cycles/render/curves.cpp +++ b/intern/cycles/render/curves.cpp @@ -35,12 +35,14 @@ void curvebounds(float *lower, float *upper, float3 *p, int dim) 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 @@ void curvebounds(float *lower, float *upper, float3 *p, int dim) } *upper = max(*upper, max(exa,exb)); *lower = min(*lower, min(exa,exb)); - } /* Hair System Manager */ |