[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59809] trunk/blender/source/blender/ blenlib: remove error return value from BLI_bvhtree_insert, no callers were using.

Campbell Barton ideasman42 at gmail.com
Wed Sep 4 22:33:51 CEST 2013


Revision: 59809
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59809
Author:   campbellbarton
Date:     2013-09-04 20:33:50 +0000 (Wed, 04 Sep 2013)
Log Message:
-----------
remove error return value from BLI_bvhtree_insert, no callers were using.
in the case of an error - assert, rather then fail silently since it wont be working as expected anyway.

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

Modified: trunk/blender/source/blender/blenlib/BLI_kdopbvh.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_kdopbvh.h	2013-09-04 20:03:33 UTC (rev 59808)
+++ trunk/blender/source/blender/blenlib/BLI_kdopbvh.h	2013-09-04 20:33:50 UTC (rev 59809)
@@ -87,7 +87,7 @@
 void BLI_bvhtree_free(BVHTree *tree);
 
 /* construct: first insert points, then call balance */
-int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints);
+void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints);
 void BLI_bvhtree_balance(BVHTree *tree);
 
 /* update: first update points/nodes, then call update_tree to refit the bounding volumes */

Modified: trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2013-09-04 20:03:33 UTC (rev 59808)
+++ trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2013-09-04 20:33:50 UTC (rev 59809)
@@ -439,7 +439,7 @@
 
 /* only supports x,y,z axis in the moment
  * but we should use a plain and simple function here for speed sake */
-static char get_largest_axis(float *bv)
+static char get_largest_axis(const float *bv)
 {
 	float middle_point[3];
 
@@ -920,7 +920,7 @@
 	BVHNode **leafs_array    = tree->nodes;
 
 	/* This function should only be called once (some big bug goes here if its being called more than once per tree) */
-	assert(tree->totbranch == 0);
+	BLI_assert(tree->totbranch == 0);
 
 	/* Build the implicit tree */
 	non_recursive_bvh_div_nodes(tree, branches_array, leafs_array, tree->totleaf);
@@ -935,20 +935,15 @@
 	/* bvhtree_info(tree); */
 }
 
-int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
+void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
 {
 	axis_t axis_iter;
 	BVHNode *node = NULL;
 
 	/* insert should only possible as long as tree->totbranch is 0 */
-	if (tree->totbranch > 0)
-		return 0;
+	BLI_assert(tree->totbranch <= 0);
+	BLI_assert((size_t)tree->totleaf < MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes)));
 
-	if ((size_t)tree->totleaf + 1 >= MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes)))
-		return 0;
-
-	/* TODO check if have enough nodes in array */
-
 	node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]);
 	tree->totleaf++;
 
@@ -960,8 +955,6 @@
 		node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */
 		node->bv[(2 * axis_iter) + 1] += tree->epsilon; /* maximum */
 	}
-
-	return 1;
 }
 
 
@@ -1017,10 +1010,10 @@
  * overlap - is it possible for 2 bv's to collide ? */
 static int tree_overlap(BVHNode *node1, BVHNode *node2, axis_t start_axis, axis_t stop_axis)
 {
-	float *bv1 = node1->bv;
-	float *bv2 = node2->bv;
+	const float *bv1 = node1->bv;
+	const float *bv2 = node2->bv;
 
-	float *bv1_end = bv1 + (stop_axis << 1);
+	const float *bv1_end = bv1 + (stop_axis << 1);
 		
 	bv1 += start_axis << 1;
 	bv2 += start_axis << 1;




More information about the Bf-blender-cvs mailing list