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:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2008-08-18 03:48:16 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2008-08-18 03:48:16 +0400
commit89a735e4f80c59d8faeae04ff11d66572da107b4 (patch)
tree6453bb8b27ba7b8a2e6cd466818570f54909a0a6 /source/blender/blenlib
parent0c79804dbe7cb6c2a65640f599939b6ccf6d989a (diff)
BVHTree fix (non 2.47)
It was building incorrect trees when there was only 1 leaf. Code fixed to always generate a tree with at least 1 branch.. since most of bvh code relies on this.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/BLI_kdopbvh.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index 9671551a7f1..49f3c3cc9e6 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -634,6 +634,18 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
BVHBuildHelper data;
int depth;
+ //Most of bvhtree code relies on 1-leaf trees having at least one branch
+ //We handle that special case here
+ if(num_leafs == 1)
+ {
+ BVHNode *root = branches_array+0;
+ 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];
+ return;
+ }
+
branches_array--; //Implicit trees use 1-based indexs
build_implicit_tree_helper(tree, &data);