diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_surfacedeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 36 |
1 files changed, 12 insertions, 24 deletions
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. */ |