[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26937] trunk/blender/source/blender/ blenkernel: Proxy ID property syncing

Campbell Barton ideasman42 at gmail.com
Mon Feb 15 19:43:55 CET 2010


Revision: 26937
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26937
Author:   campbellbarton
Date:     2010-02-15 19:43:54 +0100 (Mon, 15 Feb 2010)

Log Message:
-----------
Proxy ID property syncing
This means pose bones on proxy poses can have their own values as long as the name and type matches that of the library pose bone.
without this the only way to add new values on a pose bone proxy is to protect in the lib, reload the proxy blend and save.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_idprop.h
    trunk/blender/source/blender/blenkernel/intern/armature.c
    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-02-15 18:36:06 UTC (rev 26936)
+++ trunk/blender/source/blender/blenkernel/BKE_idprop.h	2010-02-15 18:43:54 UTC (rev 26937)
@@ -82,6 +82,9 @@
 
 /*-------- Group Functions -------*/
 
+/* Sync values from one group to another, only where they match */
+void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src);
+
 /*
  replaces all properties with the same name in a destination group from a source group.
 */

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2010-02-15 18:36:06 UTC (rev 26936)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2010-02-15 18:43:54 UTC (rev 26937)
@@ -1529,9 +1529,15 @@
 			pchanw.path= NULL;
 			
 			/* this is freed so copy a copy, else undo crashes */
-			if(pchanw.prop)
+			if(pchanw.prop) {
 				pchanw.prop= IDP_CopyProperty(pchanw.prop);
 
+				/* use the values from the the existing props */
+				if(pchan->prop) {
+					IDP_SyncGroupValues(pchanw.prop, pchan->prop);
+				}
+			}
+
 			/* constraints - proxy constraints are flushed... local ones are added after 
 			 *	1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
 			 *	2. copy proxy-pchan's constraints on-to new
@@ -1570,6 +1576,25 @@
 			/* always copy custom shape */
 			pchan->custom= pchanp->custom;
 			pchan->custom_tx= pchanp->custom_tx;
+
+			/* ID-Property Syncing */
+			{
+				IDProperty *prop_orig= pchan->prop;
+				if(pchanp->prop) {
+					pchan->prop= IDP_CopyProperty(pchanp->prop);
+					if(prop_orig) {
+						/* copy existing values across when types match */
+						IDP_SyncGroupValues(pchan->prop, prop_orig);
+					}
+				}
+				else {
+					pchan->prop= NULL;
+				}
+				if (prop_orig) {
+					IDP_FreeProperty(prop_orig);
+					MEM_freeN(prop_orig);
+				}
+			}
 		}
 	}
 }

Modified: trunk/blender/source/blender/blenkernel/intern/idprop.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-02-15 18:36:06 UTC (rev 26936)
+++ trunk/blender/source/blender/blenkernel/intern/idprop.c	2010-02-15 18:43:54 UTC (rev 26937)
@@ -385,6 +385,49 @@
 	return newp;
 }
 
+/* use for syncing proxies.
+ * When values name and types match, copy the values, else ignore */
+void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
+{
+	IDProperty *loop, *prop;
+	for (prop=src->data.group.first; prop; prop=prop->next) {
+		for (loop=dest->data.group.first; loop; loop=loop->next) {
+			if (BSTR_EQ(loop->name, prop->name)) {
+				int copy_done= 0;
+
+				if(prop->type==loop->type) {
+
+					switch (prop->type) {
+						case IDP_INT:
+						case IDP_FLOAT:
+						case IDP_DOUBLE:
+							loop->data= prop->data;
+							copy_done= 1;
+							break;
+						case IDP_GROUP:
+							IDP_SyncGroupValues(loop, prop);
+							copy_done= 1;
+							break;
+						default:
+						{
+							IDProperty *tmp= loop;
+							IDProperty *copy= IDP_CopyProperty(prop);
+
+							BLI_insertlinkafter(&dest->data.group, loop, copy);
+							BLI_remlink(&dest->data.group, tmp);
+							loop = copy;
+
+							IDP_FreeProperty(tmp);
+							MEM_freeN(tmp);
+						}
+					}
+				}
+				break;
+			}
+		}
+	}
+}
+
 /*
  replaces all properties with the same name in a destination group from a source group.
 */





More information about the Bf-blender-cvs mailing list