diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-07 17:39:55 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-07 17:39:55 +0300 |
commit | 9da7dfa1586dd89b918cffcfb04068a1e9a6343b (patch) | |
tree | 1663c0aeea6caf32a19a557e52629d7a0717dafe /source/blender/modifiers | |
parent | 580741b317ae60eb3bf999d636da0325c7e67373 (diff) |
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_armature.c | 8 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 14 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_wave.c | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgedit.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgmix.c | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgproximity.c | 6 |
7 files changed, 11 insertions, 39 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 2400dbcb898..f2f76f13883 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -64,13 +64,13 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { +#if 0 ArmatureModifierData *amd = (ArmatureModifierData *) md; +#endif ArmatureModifierData *tamd = (ArmatureModifierData *) target; - tamd->object = amd->object; - tamd->deformflag = amd->deformflag; - tamd->multi = amd->multi; - BLI_strncpy(tamd->defgrp_name, amd->defgrp_name, sizeof(tamd->defgrp_name)); + modifier_copyData_generic(md, target); + tamd->prevCos = NULL; } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md)) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 5874029ae08..93dc0203f83 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -65,19 +65,11 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { +#if 0 BevelModifierData *bmd = (BevelModifierData *) md; BevelModifierData *tbmd = (BevelModifierData *) target; - - tbmd->value = bmd->value; - tbmd->res = bmd->res; - tbmd->flags = bmd->flags; - tbmd->val_flags = bmd->val_flags; - tbmd->lim_flags = bmd->lim_flags; - tbmd->e_flags = bmd->e_flags; - tbmd->mat = bmd->mat; - tbmd->profile = bmd->profile; - tbmd->bevel_angle = bmd->bevel_angle; - BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, sizeof(tbmd->defgrp_name)); +#endif + modifier_copyData_generic(md, target); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 3325f05025f..fb8c0dd05a5 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -75,14 +75,10 @@ static void copyData(ModifierData *md, ModifierData *target) { #if 0 DisplaceModifierData *dmd = (DisplaceModifierData *) md; -#endif DisplaceModifierData *tdmd = (DisplaceModifierData *) target; +#endif modifier_copyData_generic(md, target); - - if (tdmd->texture) { - id_us_plus(&tdmd->texture->id); - } } static void freeData(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index f0c4940816e..b4990c5250e 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -90,14 +90,10 @@ static void copyData(ModifierData *md, ModifierData *target) { #if 0 WaveModifierData *wmd = (WaveModifierData *) md; -#endif WaveModifierData *twmd = (WaveModifierData *) target; +#endif modifier_copyData_generic(md, target); - - if (twmd->texture) { - id_us_plus(&twmd->texture->id); - } } static bool dependsOnTime(ModifierData *UNUSED(md)) diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 85d6e5186a1..13a97c1c13d 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -93,10 +93,6 @@ static void copyData(ModifierData *md, ModifierData *target) modifier_copyData_generic(md, target); twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve); - - if (twmd->mask_texture) { - id_us_plus(&twmd->mask_texture->id); - } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 543dc7eb900..392f42040b0 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -138,14 +138,10 @@ static void copyData(ModifierData *md, ModifierData *target) { #if 0 WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; -#endif WeightVGMixModifierData *twmd = (WeightVGMixModifierData *) target; +#endif modifier_copyData_generic(md, target); - - if (twmd->mask_texture) { - id_us_plus(&twmd->mask_texture->id); - } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 5457792a744..2ca380ba5c2 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -288,14 +288,10 @@ static void copyData(ModifierData *md, ModifierData *target) { #if 0 WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; -#endif WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData *) target; +#endif modifier_copyData_generic(md, target); - - if (twmd->mask_texture) { - id_us_plus(&twmd->mask_texture->id); - } } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) |