[Bf-blender-cvs] [cc650c3] master: Add asserts to check bvhutils args are correct
Campbell Barton
noreply at git.blender.org
Thu May 5 22:09:33 CEST 2016
Commit: cc650c3d075566c760088e59a316c7efee14fd4a
Author: Campbell Barton
Date: Fri May 6 06:00:36 2016 +1000
Branches: master
https://developer.blender.org/rBcc650c3d075566c760088e59a316c7efee14fd4a
Add asserts to check bvhutils args are correct
Would have prevented previous error going unnoticed.
===================================================================
M source/blender/blenkernel/intern/bvhutils.c
M source/blender/blenlib/BLI_kdopbvh.h
M source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 5e9c185..a2998e8 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -419,6 +419,7 @@ static BVHTree *bvhtree_from_editmesh_verts_create_tree(
}
BLI_bvhtree_insert(tree, i, eve->co, 1);
}
+ BLI_assert(BLI_bvhtree_get_size(tree) == verts_num_active);
BLI_bvhtree_balance(tree);
}
@@ -454,7 +455,7 @@ static BVHTree *bvhtree_from_mesh_verts_create_tree(
}
BLI_bvhtree_insert(tree, i, vert[i].co, 1);
}
-
+ BLI_assert(BLI_bvhtree_get_size(tree) == verts_num_active);
BLI_bvhtree_balance(tree);
}
}
@@ -728,6 +729,7 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
}
}
+ BLI_assert(BLI_bvhtree_get_size(tree) == faces_num_active);
BLI_bvhtree_balance(tree);
}
}
@@ -892,6 +894,7 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(
}
}
}
+ BLI_assert(BLI_bvhtree_get_size(tree) == looptri_num_active);
BLI_bvhtree_balance(tree);
}
}
@@ -938,6 +941,7 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(
BLI_bvhtree_insert(tree, i, co[0], 3);
}
}
+ BLI_assert(BLI_bvhtree_get_size(tree) == looptri_num_active);
BLI_bvhtree_balance(tree);
}
}
diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h
index be79266..4813e7b 100644
--- a/source/blender/blenlib/BLI_kdopbvh.h
+++ b/source/blender/blenlib/BLI_kdopbvh.h
@@ -132,6 +132,8 @@ BVHTreeOverlap *BLI_bvhtree_overlap(
const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_tot,
BVHTree_OverlapCallback callback, void *userdata);
+int BLI_bvhtree_get_size(const BVHTree *tree);
+
float BLI_bvhtree_getepsilon(const BVHTree *tree);
/* find nearest node to the given coordinates
diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index bba3fdb..f0fc2c7 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1114,6 +1114,14 @@ void BLI_bvhtree_update_tree(BVHTree *tree)
for (; index >= root; index--)
node_join(tree, *index);
}
+/**
+ * Number of times #BLI_bvhtree_insert has been called.
+ * mainly useful for asserts functions to check we added the correct number.
+ */
+int BLI_bvhtree_get_size(const BVHTree *tree)
+{
+ return tree->totleaf;
+}
float BLI_bvhtree_getepsilon(const BVHTree *tree)
{
More information about the Bf-blender-cvs
mailing list