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 | |
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')
-rw-r--r-- | source/blender/render/intern/include/strand.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/raytrace/bvh.h | 6 | ||||
-rw-r--r-- | source/blender/render/intern/raytrace/rayobject_blibvh.cpp | 4 | ||||
-rw-r--r-- | source/blender/render/intern/raytrace/svbvh.h | 26 | ||||
-rw-r--r-- | source/blender/render/intern/source/strand.c | 2 |
5 files changed, 19 insertions, 21 deletions
diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h index 7482b4d10ee..720354219e9 100644 --- a/source/blender/render/intern/include/strand.h +++ b/source/blender/render/intern/include/strand.h @@ -93,7 +93,7 @@ typedef struct StrandShadeCache StrandShadeCache; void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint); void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg); -void strand_minmax(struct StrandRen *strand, float *min, float *max, float width); +void strand_minmax(struct StrandRen *strand, float min[3], float max[3], const float width); struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4], int timeoffset); void free_strand_surface(struct Render *re); diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h index c38d9b1dcb4..c2e18a9236e 100644 --- a/source/blender/render/intern/raytrace/bvh.h +++ b/source/blender/render/intern/raytrace/bvh.h @@ -147,14 +147,14 @@ template<class Node> static inline int bvh_node_hit_test(Node *node, Isect *isec template<class Node> -static inline void bvh_node_merge_bb(Node *node, float *min, float *max) +static inline void bvh_node_merge_bb(Node *node, float min[3], float max[3]) { if (is_leaf(node)) { RE_rayobject_merge_bb((RayObject *)node, min, max); } else { - DO_MIN(node->bb, min); - DO_MAX(node->bb+3, max); + DO_MIN(node->bb, min); + DO_MAX(node->bb + 3, max); } } diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp index 8f1b730bf10..79ca21270fa 100644 --- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp @@ -44,7 +44,7 @@ static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec); static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob); static void RE_rayobject_blibvh_done(RayObject *o); static void RE_rayobject_blibvh_free(RayObject *o); -static void RE_rayobject_blibvh_bb(RayObject *o, float *min, float *max); +static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3]); static float RE_rayobject_blibvh_cost(RayObject *UNUSED(o)) { @@ -162,7 +162,7 @@ static void RE_rayobject_blibvh_free(RayObject *o) MEM_freeN(obj); } -static void RE_rayobject_blibvh_bb(RayObject *o, float *min, float *max) +static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3]) { BVHObject *obj = (BVHObject*)o; DO_MIN(obj->bb[0], min); 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++) { diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index f986be5eaeb..cc824087c87 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -1060,7 +1060,7 @@ void free_strand_surface(Render *re) BLI_freelistN(&re->strandsurface); } -void strand_minmax(StrandRen *strand, float *min, float *max, float width) +void strand_minmax(StrandRen *strand, float min[3], float max[3], const float width) { StrandVert *svert; float vec[3], width2= 2.0f*width; |