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:
authorMartin Poirier <theeth@yahoo.com>2010-01-05 06:29:41 +0300
committerMartin Poirier <theeth@yahoo.com>2010-01-05 06:29:41 +0300
commit22c32973e73363b7179303d601f59bd5c4d17d45 (patch)
treeed0b7967621c8df9d8a8f63ee11094c835fe2d11
parent8f3db6bb241fbc7f01e0ce9f036007f77bf1b5e3 (diff)
IDGroup utility function to copy a group inside another one
-rw-r--r--source/blender/blenkernel/BKE_idprop.h5
-rw-r--r--source/blender/blenkernel/intern/idprop.c25
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 9c7460851cb..7981fadccb6 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -82,6 +82,11 @@ void IDP_UnlinkID(struct IDProperty *prop);
/*-------- Group Functions -------*/
+/*
+ replaces all properties with the same name in a destination group from a source group.
+*/
+void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src);
+
/*checks if a property with the same name as prop exists, and if so replaces it.
Use this to preserve order!*/
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop);
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 7e081982f24..ddfb28437a9 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -386,6 +386,31 @@ IDProperty *IDP_CopyGroup(IDProperty *prop)
}
/*
+ replaces all properties with the same name in a destination group from a source group.
+*/
+void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src)
+{
+ IDProperty *loop, *prop;
+ for (prop=src->data.group.first; prop; prop=prop->next) {
+ IDProperty *copy = IDP_CopyProperty(prop);
+
+ for (loop=dest->data.group.first; loop; loop=loop->next) {
+ if (BSTR_EQ(loop->name, prop->name)) {
+ if (loop->next) BLI_insertlinkbefore(&dest->data.group, loop->next, copy);
+ else BLI_addtail(&dest->data.group, copy);
+
+ BLI_remlink(&dest->data.group, loop);
+ IDP_FreeProperty(loop);
+ MEM_freeN(loop);
+ break;
+ }
+ }
+
+ dest->len++;
+ BLI_addtail(&dest->data.group, copy);
+ }
+}
+/*
replaces a property with the same name in a group, or adds
it if the propery doesn't exist.
*/