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
This commit is contained in:
Omar Emara 2021-01-12 13:03:53 +02:00
parent 26fd55fad1
commit c56da67716
1 changed files with 7 additions and 1 deletions

View File

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