From de491abf996281785391b18b3547d1bff305355f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 7 Dec 2018 15:45:53 +0100 Subject: Fix modifiers evaluation outside of depsgraph/CoW context. Fix T58237: Exporters: Curve Modifier not applied when "apply modifiers" are selected. Fix T58856: Python: "to_mesh" broken in 2.8. ...And many other cases... ;) Thing is, we need target IDs to always be evaluated ones (at least I cannot see any case where having orig ones is desired effect here). Depsgraph/Cow system ensures us that when modifiers are evaluated by it, but they can also be called outside of this context, e.g. when doing binding, or object conversion... So we need to ensure in modifiers code that we actually are always working with eval data for those targets. Note that I did not touch to physics modifiers, those are a bit touchy and rather not 'fix' something there until proven broken! --- source/blender/modifiers/intern/MOD_datatransfer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_datatransfer.c') diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 71e2c7c3e09..6e823a8518a 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -166,6 +166,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes /* Only used to check wehther we are operating on org data or not... */ Mesh *me = ctx->object->data; + Object *ob_source = DEG_get_evaluated_object(ctx->depsgraph, dtmd->ob_source); + const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0; const float max_dist = (dtmd->flags & MOD_DATATRANSFER_MAP_MAXDIST) ? dtmd->map_max_distance : FLT_MAX; @@ -174,7 +176,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes SpaceTransform *space_transform = (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) ? &space_transform_data : NULL; if (space_transform) { - BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, dtmd->ob_source); + BLI_SPACE_TRANSFORM_SETUP(space_transform, ctx->object, ob_source); } if (((result == me) || (me->mvert == result->mvert) || (me->medge == result->medge)) && @@ -194,7 +196,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes BKE_reports_init(&reports, RPT_STORE); /* Note: no islands precision for now here. */ - BKE_object_data_transfer_ex(ctx->depsgraph, scene, dtmd->ob_source, ctx->object, result, dtmd->data_types, false, + BKE_object_data_transfer_ex(ctx->depsgraph, scene, ob_source, ctx->object, result, dtmd->data_types, false, dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode, space_transform, false, max_dist, dtmd->map_ray_radius, 0.0f, dtmd->layers_select_src, dtmd->layers_select_dst, @@ -206,7 +208,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes else if ((dtmd->data_types & DT_TYPE_LNOR) && !(me->flag & ME_AUTOSMOOTH)) { modifier_setError((ModifierData *)dtmd, "Enable 'Auto Smooth' option in mesh settings"); } - else if (result->totvert > HIGH_POLY_WARNING || ((Mesh *)(dtmd->ob_source->data))->totvert > HIGH_POLY_WARNING) { + else if (result->totvert > HIGH_POLY_WARNING || ((Mesh *)(ob_source->data))->totvert > HIGH_POLY_WARNING) { modifier_setError(md, "You are using a rather high poly as source or destination, computation might be slow"); } -- cgit v1.2.3