[Bf-blender-cvs] [9c9eb03d784] master: Fix T78855: Knife tool crashes when the geometry has no face

Germano Cavalcante noreply at git.blender.org
Mon Jul 13 14:03:00 CEST 2020


Commit: 9c9eb03d7840471173964b0f2758e2053bb700b4
Author: Germano Cavalcante
Date:   Sun Jul 12 21:47:50 2020 -0300
Branches: master
https://developer.blender.org/rB9c9eb03d7840471173964b0f2758e2053bb700b4

Fix T78855: Knife tool crashes when the geometry has no face

I don't see the need for a BVH Tree to have root but not have leafs.
But apparently this case is possible.

===================================================================

M	source/blender/blenlib/intern/BLI_kdopbvh.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c
index e9946d81f75..a3f93ccc753 100644
--- a/source/blender/blenlib/intern/BLI_kdopbvh.c
+++ b/source/blender/blenlib/intern/BLI_kdopbvh.c
@@ -1441,13 +1441,13 @@ int *BLI_bvhtree_intersect_plane(BVHTree *tree, float plane[4], uint *r_intersec
   int *intersect = NULL;
   size_t total = 0;
 
-  BVHNode *root = tree->nodes[tree->totleaf];
-  if (root != NULL) {
+  if (tree->totleaf) {
     BVHIntersectPlaneData data;
     data.tree = tree;
     copy_v4_v4(data.plane, plane);
     data.intersect = BLI_stack_new(sizeof(int), __func__);
 
+    BVHNode *root = tree->nodes[tree->totleaf];
     bvhtree_intersect_plane_dfs_recursive(&data, root);
 
     total = BLI_stack_count(data.intersect);



More information about the Bf-blender-cvs mailing list