diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 02:34:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-05-13 02:34:20 +0400 |
commit | c1570d9f499b3fa8e45e5de386a23aef54d4f054 (patch) | |
tree | d3358e19d3f13d0f2041996678f2bbb3751747ea /source/blender/render/intern/raytrace/svbvh.h | |
parent | 145289ad958e43b3f4f8475c581fca2180f6be88 (diff) |
code cleanup: missed some min/max use of float[3], also found case of DO_MIN/MAX re-reading same value from array 4 times when it can do once (use minf rather then MIN2, same for maxf)
Diffstat (limited to 'source/blender/render/intern/raytrace/svbvh.h')
-rw-r--r-- | source/blender/render/intern/raytrace/svbvh.h | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h index a4044db8208..ff402446b9f 100644 --- a/source/blender/render/intern/raytrace/svbvh.h +++ b/source/blender/render/intern/raytrace/svbvh.h @@ -157,29 +157,27 @@ static int svbvh_node_stack_raycast(SVBVHNode *root, Isect *isec) template<> -inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float *min, float *max) +inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float max[3]) { if (is_leaf(node)) { RE_rayobject_merge_bb((RayObject*)node, min, max); } else { - int i=0; - while (i+4 <= node->nchilds) { - float *res = node->child_bb + 6*i; + int i; + for (i = 0; i + 4 <= node->nchilds; i += 4) { + float *res = node->child_bb + 6 * i; for (int j = 0; j < 3; j++) { - min[j] = MIN2(min[j], res[4*j+0]); - min[j] = MIN2(min[j], res[4*j+1]); - min[j] = MIN2(min[j], res[4*j+2]); - min[j] = MIN2(min[j], res[4*j+3]); + min[j] = minf(res[4 * j + 0], + minf(res[4 * j + 1], + minf(res[4 * j + 2], + minf(res[4 * j + 3], min[j])))); } for (int j = 0; j < 3; j++) { - max[j] = MAX2(max[j], res[4*(j+3)+0]); - max[j] = MAX2(max[j], res[4*(j+3)+1]); - max[j] = MAX2(max[j], res[4*(j+3)+2]); - max[j] = MAX2(max[j], res[4*(j+3)+3]); + max[j] = maxf(res[4 * (j + 3) + 0], + maxf(res[4 * (j + 3) + 1], + maxf(res[4 * (j + 3) + 2], + maxf(res[4 * (j + 3) + 3], max[j])))); } - - i += 4; } for ( ; i < node->nchilds; i++) { |