diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-03-29 16:03:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-03-29 16:03:46 +0400 |
commit | 934767cf7f51ae82224138de2ffcafe7bae2b8fa (patch) | |
tree | 2b59a0b23431be2acc84d1e20d22b964e459a087 /intern/cycles/bvh/bvh.cpp | |
parent | 0509553b5eb240b3970848a4432e0bbfcbba8690 (diff) |
Cycles code refactor: change curve key to float4 for easier storage as attribute.
Diffstat (limited to 'intern/cycles/bvh/bvh.cpp')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 0d46638c82d..c0d70e0bc61 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -283,8 +283,8 @@ void BVH::pack_curve_segment(int idx, float4 woop[3]) int segment = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[idx]); int k0 = mesh->curves[tidx].first_key + segment; int k1 = mesh->curves[tidx].first_key + segment + 1; - float3 v0 = mesh->curve_keys[k0].co; - float3 v1 = mesh->curve_keys[k1].co; + float3 v0 = float4_to_float3(mesh->curve_keys[k0]); + float3 v1 = float4_to_float3(mesh->curve_keys[k1]); float3 d0 = v1 - v0; float l = len(d0); @@ -632,34 +632,20 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility if(pack.prim_type[prim] & PRIMITIVE_ALL_CURVE) { /* curves */ int str_offset = (params.top_level)? mesh->curve_offset: 0; - int k0 = mesh->curves[pidx - str_offset].first_key + PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]); - int k1 = k0 + 1; - - 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); + const Mesh::Curve& curve = mesh->curves[pidx - str_offset]; + int k = PRIMITIVE_UNPACK_SEGMENT(pack.prim_type[prim]); + + curve.bounds_grow(k, &mesh->curve_keys[0], bbox); visibility |= PATH_RAY_CURVE; } else { /* triangles */ int tri_offset = (params.top_level)? mesh->tri_offset: 0; - const int *vidx = mesh->triangles[pidx - tri_offset].v; + const Mesh::Triangle& triangle = mesh->triangles[pidx - tri_offset]; const float3 *vpos = &mesh->verts[0]; - bbox.grow(vpos[vidx[0]]); - bbox.grow(vpos[vidx[1]]); - bbox.grow(vpos[vidx[2]]); + triangle.bounds_grow(vpos, bbox); } } |