diff options
author | Omar Emara <mail@OmarEmara.dev> | 2021-01-12 14:03:53 +0300 |
---|---|---|
committer | Omar Emara <mail@OmarEmara.dev> | 2021-01-12 14:07:12 +0300 |
commit | c56da67716d9e222baefe78b45412b7652b141a5 (patch) | |
tree | 5c5c0076bc01a6cd072013de99f6b7378cc2576b | |
parent | 26fd55fad17f8177b52cf7c4bfe6d086e6ff1745 (diff) |
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
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; } |