Fix T56167: Crash when extruding + snap to face.

This is a local fix.
The problem with duplicate looptris still remains.
That is, it can still be released in one place but not upgraded in the other.

(note: setting the looptris to NULL in the evaluated mesh and assert whether it is still NULL when the mesh is freed could indicate where those cases are).
This commit is contained in:
Germano Cavalcante 2018-11-25 16:00:26 -02:00
parent 33cbcd7344
commit 36429a5bc9
Notes: blender-bot 2023-02-14 08:47:25 +01:00
Referenced by issue #56167, [2.8 Crash] Program crash when extruding+face snap
1 changed files with 10 additions and 8 deletions

View File

@ -533,7 +533,7 @@ static bool raycastEditMesh(
return retval;
}
BLI_assert(em->ob->data == BKE_object_get_pre_modified_mesh(ob));
BLI_assert(BKE_object_get_pre_modified_mesh(em->ob) == BKE_object_get_pre_modified_mesh(ob));
float imat[4][4];
float ray_start_local[3], ray_normal_local[3];
@ -599,8 +599,11 @@ static bool raycastEditMesh(
bvh_cache = &em_bvh_cache;
}
/* Get original version of the edit_btmesh. */
BMEditMesh *em_orig = BKE_editmesh_from_object(DEG_get_original_object(ob));
bvhtree_from_editmesh_looptri_ex(
treedata, em, elem_mask, looptri_num_active,
treedata, em_orig, elem_mask, looptri_num_active,
0.0f, 4, 6, bvh_cache);
if (elem_mask) {
@ -610,10 +613,6 @@ static bool raycastEditMesh(
return retval;
}
}
else {
/* COW hack: Update pointers */
treedata->em = em;
}
/* Only use closer ray_start in case of ortho view! In perspective one, ray_start
* may already been *inside* boundbox, leading to snap failures (see T38409).
@ -687,7 +686,10 @@ static bool raycastEditMesh(
retval = true;
if (r_index) {
*r_index = BM_elem_index_get(em->looptris[hit.index][0]->f);
/* Get original version of the edit_btmesh. */
BMEditMesh *em_orig = BKE_editmesh_from_object(DEG_get_original_object(ob));
*r_index = BM_elem_index_get(em_orig->looptris[hit.index][0]->f);
}
}
}
@ -2036,7 +2038,7 @@ static short snapEditMesh(
BVHTreeFromEditMesh *treedata_vert = NULL, *treedata_edge = NULL;
BLI_assert(em->ob->data == BKE_object_get_pre_modified_mesh(ob));
BLI_assert(BKE_object_get_pre_modified_mesh(ob) == BKE_object_get_pre_modified_mesh(ob));
UNUSED_VARS_NDEBUG(ob);
float lpmat[4][4];