Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-01-19 18:02:25 +0300
committerBastien Montagne <bastien@blender.org>2021-01-19 20:50:32 +0300
commitbc95c249a76563bffd8ce9242f7de6849cebe801 (patch)
tree0554bfb9393d7fc230e9d80460cd9fb3dff5fa0d /source/blender/blenkernel/intern/dynamicpaint.c
parentbcdba7c34da05b1ab54f7ba2494fc8b93e0d3d6c (diff)
Refactor modifier copying code.
Things like pointers to particle systems, or softbody data being stored outside of its modifier, make it impossible for internal modifier copy data code to be self-contained currently. It requires extra processing. In existing code this was handled in several different places, in several ways, and alltogether fairly inconsistently. Some cases were even not properly handled, causing e.g. crashes as in T82945. This commit addresses those issues by: * Adding comments about the hackish/unsafe parts `psys` implies when copying some modifier data (since we need to ensure particle system copying and remapping of those pointers separately). * Adding as-best-as-possible handling of those cases to `BKE_object_copy_modifier` (note that it remains fragile, but is expected to behave 'good enough' in any practical usecase). * Remove special handling for specific editor code (`copy_or_reuse_particle_system`). This should never have been accepted in ED code area, and is now handled by `BKE_object_copy_modifier`. * Factorize copying of the whole modifier stack into new `BKE_object_modifier_stack_copy`, now used by both `object_copy_data` and `BKE_object_link_modifiers`. Note that this implies that `BKE_object_copy_modifier` and `BKE_object_copy_gpencil_modifier` are now to be used exclusively to copy single modifiers. Full modifier stack copy should always use `BKE_object_modifier_stack_copy` instead. Fix T82945: Crash when dragging modifiers in Outliner. Maniphest Tasks: T82945 Differential Revision: https://developer.blender.org/D10148
Diffstat (limited to 'source/blender/blenkernel/intern/dynamicpaint.c')
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index e18b2d87459..811a27c9f3f 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1316,6 +1316,10 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
t_brush->particle_radius = brush->particle_radius;
t_brush->particle_smooth = brush->particle_smooth;
t_brush->paint_distance = brush->paint_distance;
+
+ /* NOTE: This is dangerous, as it will generate invalid data in case we are copying between
+ * different objects. Extra external code has to be called then to ensure proper remapping of
+ * that pointer. See e.g. `BKE_object_copy_particlesystems` or `BKE_object_copy_modifier`. */
t_brush->psys = brush->psys;
if (brush->paint_ramp) {