diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-02-02 14:20:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-02-03 12:02:20 +0300 |
commit | c8cca888518182914e6b4f1b98e0f7b861add08d (patch) | |
tree | dd93675a11be5b9240e6112c3513c88c87607686 /source/blender/modifiers | |
parent | 45d5773519bdd760d8ac1d8742a9471ebcbf5023 (diff) |
Fix assert in original modifiers pointer update function
The issue was happening with a specific file where the ID management
code was not fully copying all modifiers because of the extra check
in the `BKE_object_support_modifier_type_check()`.
While it is arguable that copy-on-write should be a 1:1 copy there is
no real need to maintain the per-modifier pointer to its original.
Use its SessionUUID to perform lookup in the original datablock.
Downside of this approach is that it is a linear lookup instead of
direct pointer access, but the upside is that there is less pointers
to manage and that the file with unsupported modifiers does behave
correct without any asserts.
Differential Revision: https://developer.blender.org/D13993
Diffstat (limited to 'source/blender/modifiers')
4 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 49ff4acb31f..dd62e354de8 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -610,7 +610,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, BLI_assert(csmd->bind_coords != NULL); /* Copy bound data to the original modifier. */ CorrectiveSmoothModifierData *csmd_orig = (CorrectiveSmoothModifierData *) - BKE_modifier_get_original(&csmd->modifier); + BKE_modifier_get_original(ob, &csmd->modifier); csmd_orig->bind_coords = MEM_dupallocN(csmd->bind_coords); csmd_orig->bind_coords_num = csmd->bind_coords_num; } diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index cb043643dd9..bfca5a39e8d 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -390,7 +390,7 @@ static void meshdeformModifier_do(ModifierData *md, } if (!recursive_bind_sentinel) { recursive_bind_sentinel = 1; - mmd->bindfunc(mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); + mmd->bindfunc(ob, mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); recursive_bind_sentinel = 0; } diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 625d31b3548..a7c29efbebd 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1113,7 +1113,8 @@ static GeometrySet compute_geometry(const DerivedNodeTree &tree, if (geo_logger.has_value()) { geo_logger->log_output_geometry(output_geometry_set); - NodesModifierData *nmd_orig = (NodesModifierData *)BKE_modifier_get_original(&nmd->modifier); + NodesModifierData *nmd_orig = (NodesModifierData *)BKE_modifier_get_original(ctx->object, + &nmd->modifier); clear_runtime_data(nmd_orig); nmd_orig->runtime_eval_log = new geo_log::ModifierLog(*geo_logger); } diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index ec6de8f8387..fd5a87571fc 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1454,7 +1454,7 @@ static void surfacedeformModifier_do(ModifierData *md, BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph"); return; } - ModifierData *md_orig = BKE_modifier_get_original(md); + ModifierData *md_orig = BKE_modifier_get_original(ob, md); freeData(md_orig); } return; @@ -1478,7 +1478,7 @@ static void surfacedeformModifier_do(ModifierData *md, } SurfaceDeformModifierData *smd_orig = (SurfaceDeformModifierData *)BKE_modifier_get_original( - md); + ob, md); float tmp_mat[4][4]; invert_m4_m4(tmp_mat, ob->obmat); |