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:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-03-06 02:24:49 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-03-06 02:24:49 +0400
commit1eb893a11410955a9cf3ceb41ab50d515f5393b1 (patch)
treecf5e64daf54e9b4831743161ace41856afab3bfd /source/blender/blenlib
parent190c233293ffb07667c2ba3d0ffcfa7638bd543e (diff)
Code cleanup: factor out some common code from PBVH build_sub/build_leaf.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/pbvh.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index eedccab185b..f8562df07a8 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -402,29 +402,33 @@ static void build_grids_leaf_node(PBVH *bvh, PBVHNode *node)
node->flag |= PBVH_UpdateDrawBuffers;
}
-static void build_leaf(PBVH *bvh, int node_index, const BBC *prim_bbc,
- int offset, int count)
+static void update_vb(PBVH *bvh, PBVHNode *node, BBC *prim_bbc,
+ int offset, int count)
{
int i;
+
+ BB_reset(&node->vb);
+ for(i = offset + count - 1; i >= offset; --i) {
+ BB_expand_with_bb(&node->vb, (BB*)(&prim_bbc[bvh->prim_indices[i]]));
+ }
+ node->orig_vb = node->vb;
+}
+static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc,
+ int offset, int count)
+{
bvh->nodes[node_index].flag |= PBVH_Leaf;
bvh->nodes[node_index].prim_indices = bvh->prim_indices + offset;
bvh->nodes[node_index].totprim = count;
/* Still need vb for searches */
- BB_reset(&bvh->nodes[node_index].vb);
- for(i = offset + count - 1; i >= offset; --i) {
- BB_expand_with_bb(&bvh->nodes[node_index].vb,
- (BB*)(prim_bbc +
- bvh->prim_indices[i]));
- }
+ update_vb(bvh, &bvh->nodes[node_index], prim_bbc, offset, count);
if(bvh->faces)
build_mesh_leaf_node(bvh, bvh->nodes + node_index);
else
build_grids_leaf_node(bvh, bvh->nodes + node_index);
- bvh->nodes[node_index].orig_vb= bvh->nodes[node_index].vb;
}
/* Recursively build a node in the tree
@@ -451,16 +455,11 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc,
}
/* Add two child nodes */
- BB_reset(&bvh->nodes[node_index].vb);
bvh->nodes[node_index].children_offset = bvh->totnode;
grow_nodes(bvh, bvh->totnode + 2);
/* Update parent node bounding box */
- for(i = offset + count - 1; i >= offset; --i) {
- BB_expand_with_bb(&bvh->nodes[node_index].vb,
- (BB*)(prim_bbc + bvh->prim_indices[i]));
- }
- bvh->nodes[node_index].orig_vb= bvh->nodes[node_index].vb;
+ update_vb(bvh, &bvh->nodes[node_index], prim_bbc, offset, count);
/* Find axis with widest range of primitive centroids */
if(!cb) {