diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-10-06 09:55:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-10-06 09:57:15 +0300 |
commit | 65bd2a6e6ae72a64dd2d3822fe79b44736b82264 (patch) | |
tree | 541808a7a708fa66bfbd1e038b800864abfc710e /source | |
parent | 51f00499cd4e0bd8d80ad7107d13a00bf2ddd904 (diff) |
Fix T46389: Shrinkwrap fails in editmode
Own regression caused by fix for T46067,
edit-mode bvh only contained unselected faces.
This commit adds support for an edit-mode bvh containing all faces.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_bvhutils.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bvhutils.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 2 |
3 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 18eda63bcf1..749b0db7c27 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -68,7 +68,8 @@ typedef struct BVHTreeFromMesh { float sphere_radius; /* Private data */ - void *em_evil; /* var only for snapping */ + void *em_evil; + bool em_evil_all; /* ignore selection/hidden state, adding all loops to the tree */ bool cached; } BVHTreeFromMesh; @@ -141,8 +142,11 @@ enum { BVHTREE_FROM_VERTS = 0, BVHTREE_FROM_EDGES = 1, BVHTREE_FROM_FACES = 2, - BVHTREE_FROM_FACES_EDITMESH = 3, - BVHTREE_FROM_LOOPTRI = 4, + BVHTREE_FROM_LOOPTRI = 3, + /* all faces */ + BVHTREE_FROM_FACES_EDITMESH_ALL = 4, + /* visible unselected, only used for transform snapping */ + BVHTREE_FROM_FACES_EDITMESH_SNAP = 5, }; typedef struct LinkNode *BVHCache; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 626be0eaf4e..5b904d4822c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -646,7 +646,10 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree( insert = insert_prev; } else if (insert) { - if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + if (tree_type == BVHTREE_FROM_FACES_EDITMESH_ALL) { + /* pass */ + } + else if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { /* Don't insert triangles tessellated from faces that are hidden or selected */ insert = false; } @@ -746,7 +749,9 @@ static void bvhtree_from_mesh_faces_setup_data( BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float epsilon, int tree_type, int axis) { BMEditMesh *em = data->em_evil; - const int bvhcache_type = em ? BVHTREE_FROM_FACES_EDITMESH : BVHTREE_FROM_FACES; + const int bvhcache_type = em ? + (data->em_evil_all ? BVHTREE_FROM_FACES_EDITMESH_ALL : BVHTREE_FROM_FACES_EDITMESH_SNAP) : + BVHTREE_FROM_FACES; BVHTree *tree; MVert *vert = NULL; MFace *face = NULL; @@ -881,7 +886,10 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree( insert = insert_prev; } else if (insert) { - if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + if (tree_type == BVHTREE_FROM_FACES_EDITMESH_ALL) { + /* pass */ + } + else if (BM_elem_flag_test(f, BM_ELEM_SELECT) || BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { /* Don't insert triangles tessellated from faces that are hidden or selected */ insert = false; } @@ -986,7 +994,9 @@ static void bvhtree_from_mesh_looptri_setup_data( BVHTree *bvhtree_from_mesh_looptri(BVHTreeFromMesh *data, DerivedMesh *dm, float epsilon, int tree_type, int axis) { BMEditMesh *em = data->em_evil; - const int bvhcache_type = em ? BVHTREE_FROM_FACES_EDITMESH : BVHTREE_FROM_LOOPTRI; + const int bvhcache_type = em ? + (data->em_evil_all ? BVHTREE_FROM_FACES_EDITMESH_ALL : BVHTREE_FROM_FACES_EDITMESH_SNAP) : + BVHTREE_FROM_LOOPTRI; BVHTree *tree; MVert *mvert = NULL; MLoop *mloop = NULL; diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 7d492586b7d..40c58cea3d9 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -282,9 +282,11 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for /* use editmesh to avoid array allocation */ if (calc->smd->target && calc->target->type == DM_TYPE_EDITBMESH) { treeData.em_evil = BKE_editmesh_from_object(calc->smd->target); + treeData.em_evil_all = true; } if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) { auxData.em_evil = BKE_editmesh_from_object(calc->smd->auxTarget); + auxData.em_evil_all = true; } /* After sucessufuly build the trees, start projection vertexs */ |