[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16160] trunk/blender/source/blender/ blenlib/intern/BLI_kdopbvh.c: BVHTree fix (non 2.47)

André Pinto andresusanopinto at gmail.com
Mon Aug 18 01:48:16 CEST 2008


Revision: 16160
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16160
Author:   jaguarandi
Date:     2008-08-18 01:48:16 +0200 (Mon, 18 Aug 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c

Modified: trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2008-08-17 23:03:45 UTC (rev 16159)
+++ trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2008-08-17 23:48:16 UTC (rev 16160)
@@ -634,6 +634,18 @@
 	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);





More information about the Bf-blender-cvs mailing list