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/makesdna
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/makesdna')
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h5
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h4
2 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 24dc90d6c21..c8e09225432 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -241,6 +241,11 @@ enum {
typedef struct DynamicPaintBrushSettings {
/** For fast RNA access. */
struct DynamicPaintModifierData *pmd;
+
+ /* NOTE: Storing the particle system pointer here is very weak, as it prevents modfiers' data
+ * copying to be self-sufficient (extra external code needs to ensure the pointer remains valid
+ * when the modifier data is copied from one object to another). See e.g.
+ * `BKE_object_copy_particlesystems` or `BKE_object_copy_modifier`. */
struct ParticleSystem *psys;
int flags;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 03cf4aca963..3de4299e0bd 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -984,6 +984,10 @@ enum {
typedef struct ParticleSystemModifierData {
ModifierData modifier;
+ /* NOTE: Storing the particle system pointer here is very weak, as it prevents modfiers' data
+ * copying to be self-sufficient (extra external code needs to ensure the pointer remains valid
+ * when the modifier data is copied from one object to another). See e.g.
+ * `BKE_object_copy_particlesystems` or `BKE_object_copy_modifier`. */
struct ParticleSystem *psys;
/** Final Mesh - its topology may differ from orig mesh. */
struct Mesh *mesh_final;