diff options
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_correctivesmooth.c | 27 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 18 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 36 |
3 files changed, 36 insertions, 45 deletions
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index ac1c0d46d7b..d9e6ed78070 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -45,6 +45,9 @@ #include "BLI_strict_flags.h" +#include "DEG_depsgraph_query.h" + + // #define DEBUG_TIME #include "PIL_time.h" @@ -558,7 +561,7 @@ static void calc_deltas( static void correctivesmooth_modifier_do( - ModifierData *md, Object *ob, Mesh *mesh, + ModifierData *md, Depsgraph *depsgraph, Object *ob, Mesh *mesh, float (*vertexCos)[3], unsigned int numVerts, struct BMEditMesh *em) { @@ -580,10 +583,20 @@ static void correctivesmooth_modifier_do( /* signal to recalculate, whoever sets MUST also free bind coords */ (csmd->bind_coords_num == (unsigned int)-1)) { - BLI_assert(csmd->bind_coords == NULL); - csmd->bind_coords = MEM_dupallocN(vertexCos); - csmd->bind_coords_num = numVerts; - BLI_assert(csmd->bind_coords != NULL); + if (DEG_is_active(depsgraph)) { + BLI_assert(csmd->bind_coords == NULL); + csmd->bind_coords = MEM_dupallocN(vertexCos); + csmd->bind_coords_num = numVerts; + BLI_assert(csmd->bind_coords != NULL); + /* Copy bound data to the original modifier. */ + CorrectiveSmoothModifierData *csmd_orig = + (CorrectiveSmoothModifierData *)modifier_get_original(&csmd->modifier); + csmd_orig->bind_coords = MEM_dupallocN(csmd->bind_coords); + csmd_orig->bind_coords_num = csmd->bind_coords_num; + } + else { + modifier_setError(md, "Attempt to bind from inactive dependency graph"); + } } if (UNLIKELY(use_only_smooth)) { @@ -711,7 +724,7 @@ static void deformVerts( { Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); - correctivesmooth_modifier_do(md, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, NULL); + correctivesmooth_modifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, NULL); if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); @@ -725,7 +738,7 @@ static void deformVertsEM( { Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); - correctivesmooth_modifier_do(md, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, editData); + correctivesmooth_modifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (unsigned int)numVerts, editData); if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 310b05d4580..7ae03cc43f3 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -298,14 +298,6 @@ static void meshdeformModifier_do( */ Object *ob_target = mmd->object; cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); -#if 0 /* This shall not be needed if we always get evaluated target object... */ - if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) { - /* Special case, binding happens outside of depsgraph evaluation, so we can build our own - * target mesh if needed. */ - cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, &CD_MASK_BAREMESH); - free_cagemesh = cagemesh != NULL; - } -#endif if (cagemesh == NULL) { modifier_setError(md, "Cannot get mesh from cage object"); return; @@ -321,13 +313,11 @@ static void meshdeformModifier_do( /* bind weights if needed */ if (!mmd->bindcagecos) { /* progress bar redraw can make this recursive .. */ + if (!DEG_is_active(ctx->depsgraph)) { + modifier_setError(md, "Attempt to bind from inactive dependency graph"); + goto finally; + } if (!recursive_bind_sentinel) { - if (ob != DEG_get_original_object(ob)) { - BLI_assert(!"Trying to bind inside of depsgraph evaluation"); - modifier_setError(md, "Trying to bind inside of depsgraph evaluation"); - goto finally; - } - recursive_bind_sentinel = 1; mmd->bindfunc(mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); recursive_bind_sentinel = 0; diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 44307b4271e..46f4f9c78e9 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1124,7 +1124,7 @@ static void deformVert( static void surfacedeformModifier_do( ModifierData *md, - const ModifierEvalContext *UNUSED(ctx), + const ModifierEvalContext *ctx, float (*vertexCos)[3], unsigned int numverts, Object *ob) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; @@ -1133,30 +1133,19 @@ static void surfacedeformModifier_do( /* Exit function if bind flag is not set (free bind data if any). */ if (!(smd->flags & MOD_SDEF_BIND)) { - /* Note: with new CoW system, we expect unbinding to be done by a special call from main thread, - * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */ if (smd->verts != NULL) { - if (ob != DEG_get_original_object(ob)) { - BLI_assert(!"Trying to unbind inside of depsgraph evaluation"); - modifier_setError(md, "Trying to unbind inside of depsgraph evaluation"); - } - else { - freeData(md); + if (!DEG_is_active(ctx->depsgraph)) { + modifier_setError(md, "Attempt to bind from inactive dependency graph"); + return; } + ModifierData *md_orig = modifier_get_original(md); + freeData(md_orig); } return; } Object *ob_target = smd->target; target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); -#if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */ - if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) { - /* Special case, binding happens outside of depsgraph evaluation, so we can build our own - * target mesh if needed. */ - target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, CD_MASK_BAREMESH); - free_target = target != NULL; - } -#endif if (!target) { modifier_setError(md, "No valid target mesh"); return; @@ -1166,20 +1155,19 @@ static void surfacedeformModifier_do( tnumpoly = target->totpoly; /* If not bound, execute bind. */ - /* Note: with new CoW system, we expect binding to be done by a special call from main thread, - * outside of depsgraph evaluation (see object_force_modifier_update_for_bind() in object_modifier.c). */ if (smd->verts == NULL) { - if (ob != DEG_get_original_object(ob)) { - BLI_assert(!"Trying to bind inside of depsgraph evaluation"); - modifier_setError(md, "Trying to bind inside of depsgraph evaluation"); + if (!DEG_is_active(ctx->depsgraph)) { + modifier_setError(md, "Attempt to unbind from inactive dependency graph"); return; } + + SurfaceDeformModifierData *smd_orig = (SurfaceDeformModifierData *)modifier_get_original(md); float tmp_mat[4][4]; invert_m4_m4(tmp_mat, ob->obmat); - mul_m4_m4m4(smd->mat, tmp_mat, ob_target->obmat); + mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->obmat); - if (!surfacedeformBind(smd, vertexCos, numverts, tnumpoly, tnumverts, target)) { + if (!surfacedeformBind(smd_orig, vertexCos, numverts, tnumpoly, tnumverts, target)) { smd->flags &= ~MOD_SDEF_BIND; } /* Early abort, this is binding 'call', no need to perform whole evaluation. */ |