diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-05 15:55:39 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-05 15:55:39 +0400 |
commit | b32036f5d6b08233e30dc62ea0f5e84a0e75cc7c (patch) | |
tree | 026173d6ad6b0cf8151ee1f85cfcaf5d27b9bb57 /source/blender/blenlib/intern/BLI_kdopbvh.c | |
parent | e8621cf05e6f54294057e3e68c971abda53fdf9a (diff) |
bvh nodes got parent node reference again
Diffstat (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdopbvh.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 989e516d161..341a27c4306 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -51,6 +51,7 @@ typedef struct BVHNode { struct BVHNode **children; + struct BVHNode *parent; // some user defined traversed need that float *bv; // Bounding volume of all nodes, max 13 axis int index; // face, edge, vertex index char totnode; // how many nodes are used, used for speedup @@ -700,6 +701,10 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, BVHBuildHelper data; int depth; + + // set parent from root node to NULL + BVHNode *tmp = branches_array+0; + tmp->parent = NULL; //Most of bvhtree code relies on 1-leaf trees having at least one branch //We handle that special case here @@ -709,7 +714,8 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, refit_kdop_hull(tree, root, 0, num_leafs); root->main_axis = get_largest_axis(root->bv) / 2; root->totnode = 1; - root->children[0] = leafs_array[0]; + root->children[0] = leafs_array[0]; + root->children[0]->parent = root; return; } @@ -772,9 +778,15 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int child_leafs_end = implicit_leafs_index(&data, depth+1, child_level_index+1); if(child_leafs_end - child_leafs_begin > 1) + { parent->children[k] = branches_array + child_index; + parent->children[k]->parent = parent; + } else if(child_leafs_end - child_leafs_begin == 1) + { parent->children[k] = leafs_array[ child_leafs_begin ]; + parent->children[k]->parent = parent; + } else break; |