Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Broadfoot <gbroadfoot@hotmail.com>2013-01-15 23:44:41 +0400
committerStuart Broadfoot <gbroadfoot@hotmail.com>2013-01-15 23:44:41 +0400
commit3373b8154b16d345b0e1fcbdb55d03d8ec088006 (patch)
treeeec2b36ebf0f70ca882a26e6525839c9f7f2013a /intern/cycles/bvh/bvh_build.cpp
parent0967b39be1cf9644454e1d4e9c6d0250d9a36e85 (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_build.cpp')
-rw-r--r--intern/cycles/bvh/bvh_build.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index 38fb1a15a13..022c4c8d294 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -24,6 +24,7 @@
#include "mesh.h"
#include "object.h"
#include "scene.h"
+#include "curves.h"
#include "util_debug.h"
#include "util_foreach.h"
@@ -91,11 +92,20 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh,
for(int k = 0; k < curve.num_keys - 1; k++) {
BoundBox bounds = BoundBox::empty;
- float3 co0 = mesh->curve_keys[curve.first_key + k].co;
- float3 co1 = mesh->curve_keys[curve.first_key + k + 1].co;
-
- bounds.grow(co0, mesh->curve_keys[curve.first_key + k].radius);
- bounds.grow(co1, mesh->curve_keys[curve.first_key + k + 1].radius);
+ float3 co[4];
+ co[0] = mesh->curve_keys[max(curve.first_key + k - 1,curve.first_key)].co;
+ co[1] = mesh->curve_keys[curve.first_key + k].co;
+ co[2] = mesh->curve_keys[curve.first_key + k + 1].co;
+ co[3] = mesh->curve_keys[min(curve.first_key + k + 2, curve.first_key + curve.num_keys - 1)].co;
+
+ float3 lower;
+ float3 upper;
+ curvebounds(&lower.x, &upper.x, co, 0);
+ curvebounds(&lower.y, &upper.y, co, 1);
+ curvebounds(&lower.z, &upper.z, co, 2);
+ float mr = max(mesh->curve_keys[curve.first_key + k].radius, mesh->curve_keys[curve.first_key + k + 1].radius);
+ bounds.grow(lower, mr);
+ bounds.grow(upper, mr);
if(bounds.valid()) {
references.push_back(BVHReference(bounds, j, i, k));