Transform: Identify more safely when the mesh is deform only

Depending on the modifiers, geometry can be destructive which is not safe.
This commit is contained in:
Germano Cavalcante 2021-07-13 18:57:46 -03:00
parent 96a4b54cfb
commit ae379714e4
Notes: blender-bot 2023-02-14 02:22:07 +01:00
Referenced by issue #91902, Ambient Occlusion not working right
Referenced by issue #89842, Crash when baking vertex colors when Auto Smooth is enabled
Referenced by issue #88738, Blender crashes with Glass BSDF + Sharp + Linux CPU
1 changed files with 23 additions and 4 deletions

View File

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