From c56da67716d9e222baefe78b45412b7652b141a5 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Tue, 12 Jan 2021 13:03:53 +0200 Subject: [PATCH] Fix: Bmesh from_object applies modifiers twice The Bmesh from_object method applies modifiers twice when the input deform is enabled and the input depsgraph is a render one. The evaluated object already have modifiers applied, and mesh_create_eval_final() applies modifiers again. To fix this, the BKE_mesh_new_from_object() function is used instead. Reviewed By: Brecht Differential Revision: https://developer.blender.org/D10053 --- source/blender/python/bmesh/bmesh_py_types.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 2b174de7136..38122c45ef1 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -1123,6 +1123,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject const bool use_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER; scene_eval = DEG_get_evaluated_scene(depsgraph); ob_eval = DEG_get_evaluated_object(depsgraph, ob); + bool need_free = false; /* Write the display mesh into the dummy mesh */ if (use_deform) { @@ -1134,7 +1135,8 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject return NULL; } - me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &data_masks); + me_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true); + need_free = true; } else { if (use_cage) { @@ -1175,6 +1177,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject .calc_face_normal = use_fnorm, })); + if (need_free) { + BKE_id_free(NULL, me_eval); + } + Py_RETURN_NONE; }