diff options
author | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-01-15 23:44:41 +0400 |
---|---|---|
committer | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2013-01-15 23:44:41 +0400 |
commit | 3373b8154b16d345b0e1fcbdb55d03d8ec088006 (patch) | |
tree | eec2b36ebf0f70ca882a26e6525839c9f7f2013a /intern/cycles/bvh/bvh.cpp | |
parent | 0967b39be1cf9644454e1d4e9c6d0250d9a36e85 (diff) |
Cycles Hair: Introduction of Cardinal Spline Curve Segments and minor fixes.
The curve segment primitive has been added. This includes an intersection function and changes to the BVH.
A few small errors in the line segment intersection routine are also fixed.
Diffstat (limited to 'intern/cycles/bvh/bvh.cpp')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 412b44031e6..011406344ea 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -18,6 +18,7 @@ #include "mesh.h" #include "object.h" #include "scene.h" +#include "curves.h" #include "bvh.h" #include "bvh_build.h" @@ -631,8 +632,19 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility int k0 = mesh->curves[pidx - str_offset].first_key + pack.prim_segment[prim]; // XXX! int k1 = k0 + 1; - bbox.grow(mesh->curve_keys[k0].co, mesh->curve_keys[k0].radius); - bbox.grow(mesh->curve_keys[k1].co, mesh->curve_keys[k1].radius); + float3 p[4]; + p[0] = mesh->curve_keys[max(k0 - 1,mesh->curves[pidx - str_offset].first_key)].co; + p[1] = mesh->curve_keys[k0].co; + p[2] = mesh->curve_keys[k1].co; + p[3] = mesh->curve_keys[min(k1 + 1,mesh->curves[pidx - str_offset].first_key + mesh->curves[pidx - str_offset].num_keys - 1)].co; + float3 lower; + float3 upper; + curvebounds(&lower.x, &upper.x, p, 0); + curvebounds(&lower.y, &upper.y, p, 1); + curvebounds(&lower.z, &upper.z, p, 2); + float mr = max(mesh->curve_keys[k0].radius,mesh->curve_keys[k1].radius); + bbox.grow(lower, mr); + bbox.grow(upper, mr); } else { /* triangles */ |