Fix #140130: Crash with shared edit mode mesh with subdivision modifier
This assert added by321ec72c74notes that changing the mesh wrapper type from subdivision to normal mesh data just discards the potentially-subdivided geometry and doesn't make sense, and possibly breaks other assumptions. This wrapper type change was done years ago by0f89bcdbebto fix issues with shared object data during evaluation. It noted that the mesh drawing data extraction didn't handle BMesh wrappers correctly when the object isn't in edit mode, but that doesn't seem to be the case after two trivial changes. The other bugs mentioned by that commit are still solved after this change. Pull Request: https://projects.blender.org/blender/blender/pulls/140290
This commit is contained in:
@@ -1043,17 +1043,6 @@ static void editbmesh_build_data(Depsgraph &depsgraph,
|
||||
editbmesh_calc_modifiers(
|
||||
depsgraph, scene, obedit, dataMask, &me_cage, &me_final, &non_mesh_components);
|
||||
|
||||
/* Object has edit_mesh but is not in edit mode (object shares mesh datablock with another object
|
||||
* with is in edit mode).
|
||||
* Convert edit mesh to mesh until the draw manager can draw mesh wrapper which is not in the
|
||||
* edit mode. */
|
||||
if (!(obedit.mode & OB_MODE_EDIT)) {
|
||||
BKE_mesh_wrapper_ensure_mdata(me_final);
|
||||
if (me_final != me_cage) {
|
||||
BKE_mesh_wrapper_ensure_mdata(me_cage);
|
||||
}
|
||||
}
|
||||
|
||||
const bool is_mesh_eval_owned = (me_final != mesh->runtime->mesh_eval);
|
||||
BKE_object_eval_assign_data(&obedit, &me_final->id, is_mesh_eval_owned);
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ MeshRenderData mesh_render_data_create(Object &object,
|
||||
mr.use_hide = use_hide;
|
||||
|
||||
const Mesh *editmesh_orig = BKE_object_get_pre_modified_mesh(&object);
|
||||
if (is_editmode && editmesh_orig && editmesh_orig->runtime->edit_mesh) {
|
||||
if (editmesh_orig && editmesh_orig->runtime->edit_mesh) {
|
||||
const Mesh *eval_cage = DRW_object_get_editmesh_cage_for_drawing(object);
|
||||
|
||||
mr.bm = editmesh_orig->runtime->edit_mesh->bm;
|
||||
@@ -605,10 +605,10 @@ MeshRenderData mesh_render_data_create(Object &object,
|
||||
mr.freestyle_face_ofs = CustomData_get_offset(&mr.bm->pdata, CD_FREESTYLE_FACE);
|
||||
#endif
|
||||
|
||||
/* Use bmesh directly when the object is in edit mode unchanged by any modifiers.
|
||||
* For non-final UVs, always use original bmesh since the UV editor does not support
|
||||
* using the cage mesh with deformed coordinates. */
|
||||
if ((is_editmode && mr.mesh->runtime->is_original_bmesh &&
|
||||
/* Use bmesh directly when the object is unchanged by any modifiers. For non-final UVs, always
|
||||
* use original bmesh since the UV editor does not support using the cage mesh with deformed
|
||||
* coordinates. */
|
||||
if ((mr.mesh->runtime->is_original_bmesh &&
|
||||
mr.mesh->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) ||
|
||||
(do_uvedit && !do_final))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user