[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25730] trunk/blender/source/blender/ blenkernel: IDGroup utility function to copy a group inside another one

Martin Poirier theeth at yahoo.com
Tue Jan 5 04:29:42 CET 2010


Revision: 25730
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25730
Author:   theeth
Date:     2010-01-05 04:29:41 +0100 (Tue, 05 Jan 2010)

Log Message:
-----------
IDGroup utility function to copy a group inside another one

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_idprop.h
    trunk/blender/source/blender/blenkernel/intern/idprop.c

Modified: trunk/blender/source/blender/blenkernel/BKE_idprop.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_idprop.h	2010-01-05 03:26:11 UTC (rev 25729)
+++ trunk/blender/source/blender/blenkernel/BKE_idprop.h	2010-01-05 03:29:41 UTC (rev 25730)
@@ -82,6 +82,11 @@
 
 /*-------- 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);

Modified: trunk/blender/source/blender/blenkernel/intern/idprop.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-01-05 03:26:11 UTC (rev 25729)
+++ trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-01-05 03:29:41 UTC (rev 25730)
@@ -386,6 +386,31 @@
 }
 
 /*
+ 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.
 */





More information about the Bf-blender-cvs mailing list