[Bf-blender-cvs] [c56da67716d] master: Fix: Bmesh from_object applies modifiers twice

Omar Emara noreply at git.blender.org
Tue Jan 12 12:03:25 CET 2021


Commit: c56da67716d9e222baefe78b45412b7652b141a5
Author: Omar Emara
Date:   Tue Jan 12 13:03:53 2021 +0200
Branches: master
https://developer.blender.org/rBc56da67716d9e222baefe78b45412b7652b141a5

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

===================================================================

M	source/blender/python/bmesh/bmesh_py_types.c

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list