[Bf-blender-cvs] [ae379714e4f] master: Transform: Identify more safely when the mesh is deform only

Germano Cavalcante noreply at git.blender.org
Wed Jul 14 00:00:02 CEST 2021


Commit: ae379714e4f1eca74f5f77532a6e959f29445236
Author: Germano Cavalcante
Date:   Tue Jul 13 18:57:46 2021 -0300
Branches: master
https://developer.blender.org/rBae379714e4f1eca74f5f77532a6e959f29445236

Transform: Identify more safely when the mesh is deform only

Depending on the modifiers, geometry can be destructive which is not safe.

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

M	source/blender/editors/transform/transform_convert_mesh.c

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

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



More information about the Bf-blender-cvs mailing list