diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-07-14 00:57:46 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-07-14 00:59:42 +0300 |
commit | ae379714e4f1eca74f5f77532a6e959f29445236 (patch) | |
tree | d0ca5308c352509736167883d00ca41880feebe3 /source/blender | |
parent | 96a4b54cfb5c183d9e05c6fe8d96e290f1a98bf6 (diff) |
Transform: Identify more safely when the mesh is deform only
Depending on the modifiers, geometry can be destructive which is not safe.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_convert_mesh.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index d740f7e3adb..383f9870714 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -2067,6 +2067,27 @@ static void tc_mesh_transdata_mirror_apply(TransDataContainer *tc) } } +static bool tc_mesh_is_deform_only_update(TransInfo *t, TransDataContainer *tc) +{ + if (tc->custom.type.data && + ((struct TransCustomDataMesh *)tc->custom.type.data)->cd_layer_correct) { + return false; + } + + Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(t->depsgraph, (ID *)tc->obedit->data); + Mesh *mesh_eval_cage = me_eval->edit_mesh->mesh_eval_cage; + Mesh *mesh_eval_final = me_eval->edit_mesh->mesh_eval_final; + if (mesh_eval_cage && !mesh_eval_cage->runtime.is_original) { + return false; + } + if (mesh_eval_final && mesh_eval_final != mesh_eval_cage && + !mesh_eval_final->runtime.is_original) { + return false; + } + + return me_eval->runtime.deformed_only; +} + void recalcData_mesh(TransInfo *t) { bool is_canceling = t->state == TRANS_CANCEL; @@ -2094,12 +2115,10 @@ void recalcData_mesh(TransInfo *t) tc_mesh_partial_types_calc(t, &partial_state); FOREACH_TRANS_DATA_CONTAINER (t, tc) { - const bool use_cd_layer_correct = - tc->custom.type.data && - ((struct TransCustomDataMesh *)tc->custom.type.data)->cd_layer_correct; + const bool is_deform_only = tc_mesh_is_deform_only_update(t, tc); DEG_id_tag_update(tc->obedit->data, - use_cd_layer_correct ? ID_RECALC_GEOMETRY : ID_RECALC_GEOMETRY_DEFORM); + is_deform_only ? ID_RECALC_GEOMETRY_DEFORM : ID_RECALC_GEOMETRY); tc_mesh_partial_update(t, tc, &partial_state); } |