diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-05-03 12:37:24 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-05-03 12:51:49 +0300 |
commit | 66c74242bba3c2962ff5c3ddc02409171ec86dc3 (patch) | |
tree | 8902283a630a3aa24bf036e8e241b9b517808da6 /source/blender | |
parent | bf0ac873ba13996756f0b553c41ea36097a6dec3 (diff) |
Make IDP_MergeGroup recursive
With this we also do not need IDP_MergeGroupValues anymore.
If this causes problems in the future we can always make recursion an
option (like overwrite is).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_idprop.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 6 |
3 files changed, 21 insertions, 30 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 1f44719e2d3..ab8728faedb 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -91,7 +91,6 @@ void IDP_ReplaceGroupInGroup(struct IDProperty *dest, const struct IDProperty *s void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); void IDP_ReplaceInGroup_ex(struct IDProperty *group, struct IDProperty *prop, struct IDProperty *prop_exist); void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) ATTR_NONNULL(); -void IDP_MergeGroupValues(IDProperty *dest, IDProperty *src); bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); bool IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 27f7cac2a8e..a3bd15252cb 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -600,32 +600,8 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) } /** - * Same as IDP_MergeGroup but recursively - */ -void IDP_MergeGroupValues(IDProperty *dest, IDProperty *src) -{ - IDProperty *prop; - - BLI_assert(dest->type == IDP_GROUP); - BLI_assert(src->type == IDP_GROUP); - - for (prop = src->data.group.first; prop; prop = prop->next) { - if (prop->type == IDP_GROUP) { - IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); - - if (prop_exist != NULL) { - IDP_MergeGroupValues(prop_exist, prop); - continue; - } - } - - IDProperty *copy = IDP_CopyProperty(prop); - IDP_ReplaceInGroup(dest, copy); - } -} - -/** * If a property is missing in \a dest, add it. + * Do it recursively. */ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) { @@ -636,13 +612,29 @@ void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overw if (do_overwrite) { for (prop = src->data.group.first; prop; prop = prop->next) { + if (prop->type == IDP_GROUP) { + IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); + + if (prop_exist != NULL) { + IDP_MergeGroup(prop_exist, prop, do_overwrite); + continue; + } + } + IDProperty *copy = IDP_CopyProperty(prop); IDP_ReplaceInGroup(dest, copy); } } else { for (prop = src->data.group.first; prop; prop = prop->next) { - if (IDP_GetPropertyFromGroup(dest, prop->name) == NULL) { + IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name); + if (prop_exist != NULL) { + if (prop->type == IDP_GROUP) { + IDP_MergeGroup(prop_exist, prop, do_overwrite); + continue; + } + } + else { IDProperty *copy = IDP_CopyProperty(prop); dest->len++; BLI_addtail(&dest->data.group, copy); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 6442c53635d..b74b6ac7e6b 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -1391,7 +1391,7 @@ static void idproperty_reset(IDProperty **props, IDProperty *props_ref) *props = IDP_New(IDP_GROUP, &val, ROOT_PROP); if (props_ref) { - IDP_MergeGroupValues(*props, props_ref); + IDP_MergeGroup(*props, props_ref, true); } } @@ -1435,7 +1435,7 @@ void BKE_layer_eval_layer_collection(struct EvaluationContext *UNUSED(eval_ctx), } else { idproperty_reset(&layer_collection->properties_evaluated, parent_layer_collection->properties_evaluated); - IDP_MergeGroupValues(layer_collection->properties_evaluated, layer_collection->properties); + IDP_MergeGroup(layer_collection->properties_evaluated, layer_collection->properties, true); } } @@ -1443,7 +1443,7 @@ void BKE_layer_eval_layer_collection(struct EvaluationContext *UNUSED(eval_ctx), Base *base = link->data; if (is_visible) { - IDP_MergeGroupValues(base->collection_properties, layer_collection->properties_evaluated); + IDP_MergeGroup(base->collection_properties, layer_collection->properties_evaluated, true); base->flag |= BASE_VISIBLED; } |