Correct own error in editmesh bvh
authorCampbell Barton <ideasman42@gmail.com>
Fri, 9 Oct 2015 00:04:24 +0000 (11:04 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 9 Oct 2015 05:35:42 +0000 (16:35 +1100)
Flag mix-up and uninitialized var.

source/blender/blenkernel/intern/bvhutils.c
source/blender/editors/transform/transform_snap.c

index d48635d21d98e0294e5bc6e72b311fca1f746a20..9004985aebddc7f50293eae851773d759439380e 100644 (file)
@@ -597,7 +597,8 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *dm, float e
 
 static BVHTree *bvhtree_from_mesh_faces_create_tree(
         float epsilon, int tree_type, int axis,
-        BMEditMesh *em, MVert *vert, MFace *face, const int numFaces,
+        BMEditMesh *em, const bool em_all,
+        MVert *vert, MFace *face, const int numFaces,
         BLI_bitmap *mask, int numFaces_active)
 {
        BVHTree *tree = NULL;
@@ -646,7 +647,7 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(
                                                insert = insert_prev;
                                        }
                                        else if (insert) {
-                                               if (tree_type == BVHTREE_FROM_FACES_EDITMESH_ALL) {
+                                               if (em_all) {
                                                        /* pass */
                                                }
                                                else if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
@@ -786,7 +787,10 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float e
                                BLI_assert(!(numFaces == 0 && dm->getNumPolys(dm) != 0));
                        }
 
-                       tree = bvhtree_from_mesh_faces_create_tree(epsilon, tree_type, axis, em, vert, face, numFaces, NULL, -1);
+                       tree = bvhtree_from_mesh_faces_create_tree(
+                               epsilon, tree_type, axis,
+                               em, (bvhcache_type == BVHTREE_FROM_FACES_EDITMESH_ALL),
+                               vert, face, numFaces, NULL, -1);
                        if (tree) {
                                /* Save on cache for later use */
                                /* printf("BVHTree built and saved on cache\n"); */
@@ -818,7 +822,9 @@ BVHTree *bvhtree_from_mesh_faces_ex(
         BLI_bitmap *mask, int numFaces_active, float epsilon, int tree_type, int axis)
 {
        BVHTree *tree = bvhtree_from_mesh_faces_create_tree(
-               epsilon, tree_type, axis, NULL, vert, face, numFaces,
+               epsilon, tree_type, axis,
+               NULL, false,
+               vert, face, numFaces,
                mask, numFaces_active);
 
        /* Setup BVHTreeFromMesh */
@@ -837,7 +843,8 @@ BVHTree *bvhtree_from_mesh_faces_ex(
 
 static BVHTree *bvhtree_from_mesh_looptri_create_tree(
         float epsilon, int tree_type, int axis,
-        BMEditMesh *em, const MVert *vert, const MLoop *mloop, const MLoopTri *looptri, const int looptri_num,
+        BMEditMesh *em, const bool em_all,
+        const MVert *vert, const MLoop *mloop, const MLoopTri *looptri, const int looptri_num,
         BLI_bitmap *mask, int looptri_num_active)
 {
        BVHTree *tree = NULL;
@@ -886,7 +893,7 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(
                                                insert = insert_prev;
                                        }
                                        else if (insert) {
-                                               if (tree_type == BVHTREE_FROM_FACES_EDITMESH_ALL) {
+                                               if (em_all) {
                                                        /* pass */
                                                }
                                                else if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
@@ -1054,7 +1061,8 @@ BVHTree *bvhtree_from_mesh_looptri(BVHTreeFromMesh *data, DerivedMesh *dm, float
                        }
 
                        tree = bvhtree_from_mesh_looptri_create_tree(
-                               epsilon, tree_type, axis, em,
+                               epsilon, tree_type, axis,
+                               em, (bvhcache_type == BVHTREE_FROM_FACES_EDITMESH_ALL),
                                mvert, mloop, looptri, looptri_num, NULL, -1);
                        if (tree) {
                                /* Save on cache for later use */
@@ -1087,7 +1095,9 @@ BVHTree *bvhtree_from_mesh_looptri_ex(
         float epsilon, int tree_type, int axis)
 {
        BVHTree *tree = bvhtree_from_mesh_looptri_create_tree(
-               epsilon, tree_type, axis, NULL, vert, mloop, looptri, looptri_num,
+               epsilon, tree_type, axis,
+               NULL, false,
+               vert, mloop, looptri, looptri_num,
                mask, looptri_num_active);
 
        /* Setup BVHTreeFromMesh */
index a7aad427dd6cde5bbd6359951e0bf091afa2f4f2..5230c39af53e9292fe45a2e37e2a0f8f208fe1be 100644 (file)
@@ -1549,6 +1549,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
                        len_diff = 0.0f;  /* In case BVHTree would fail for some reason... */
 
                        treeData.em_evil = em;
+                       treeData.em_evil_all = false;
                        bvhtree_from_mesh_looptri(&treeData, dm, 0.0f, 2, 6);
                        if (treeData.tree != NULL) {
                                nearest.index = -1;
@@ -1591,6 +1592,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
                                }
 
                                treeData.em_evil = em;
+                               treeData.em_evil_all = false;
                                bvhtree_from_mesh_looptri(&treeData, dm, 0.0f, 4, 6);
 
                                hit.index = -1;
@@ -2177,6 +2179,7 @@ static bool peelDerivedMesh(
                        struct PeelRayCast_Data data;
 
                        data.bvhdata.em_evil = em;
+                       data.bvhdata.em_evil_all = false;
                        bvhtree_from_mesh_looptri(&data.bvhdata, dm, 0.0f, 4, 6);
 
                        if (data.bvhdata.tree != NULL) {