2.5 - Bones can now have custom properties (as ID-Props)
authorJoshua Leung <aligorith@gmail.com>
Mon, 18 May 2009 02:25:33 +0000 (02:25 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 18 May 2009 02:25:33 +0000 (02:25 +0000)
Still need to find a way to enable RNA access for these though, since RNA access to ID-Props stored in data seems to be broken...

source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_action_types.h

index fd9da2059e1ea55a2cc4c58a40fde9705b586fa6..67887769d381077376d3378176ef3c8620f644de 100644 (file)
@@ -2176,9 +2176,12 @@ static void direct_link_constraints(FileData *fd, ListBase *lb)
                
                if (cons->type == CONSTRAINT_TYPE_PYTHON) {
                        bPythonConstraint *data= cons->data;
+                       
                        link_list(fd, &data->targets);
+                       
                        data->prop = newdataadr(fd, data->prop);
-                       IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+                       if (data->prop)
+                               IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
                }
        }
 }
@@ -3417,7 +3420,13 @@ static void direct_link_pose(FileData *fd, bPose *pose)
                pchan->bone= NULL;
                pchan->parent= newdataadr(fd, pchan->parent);
                pchan->child= newdataadr(fd, pchan->child);
+               
                direct_link_constraints(fd, &pchan->constraints);
+               
+               pchan->prop = newdataadr(fd, pchan->prop);
+               if (pchan->prop)
+                       IDP_DirectLinkProperty(pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+               
                pchan->iktree.first= pchan->iktree.last= NULL;
                pchan->path= NULL;
        }
index b690c708dc37853232e6a9ff0ff7d70cb8adc6aa..943e23861adc2c086468a351837d355af380084b 100644 (file)
@@ -956,6 +956,11 @@ static void write_pose(WriteData *wd, bPose *pose)
 
        /* Write channels */
        for (chan=pose->chanbase.first; chan; chan=chan->next) {
+               /* Write ID Properties -- and copy this comment EXACTLY for easy finding
+                of library blocks that implement this.*/
+               if (chan->prop)
+                       IDP_WriteProperty(chan->prop, wd);
+               
                write_constraints(wd, &chan->constraints);
                
                /* prevent crashes with autosave, when a bone duplicated in editmode has not yet been assigned to its posechannel */
index cf54d69bb8b3516bb45a955c9243816faf4a5e1b..7e54045b5e4bfb2e777bf9d5673a98c6d91b6e60 100644 (file)
@@ -52,6 +52,9 @@ struct Object;
  */
 typedef struct bPoseChannel {
        struct bPoseChannel     *next, *prev;
+       
+       IDProperty                      *prop;          /* User-Defined Properties on this PoseChannel */                       
+       
        ListBase                        constraints;/* Constraints that act on this PoseChannel */
        char                            name[32];       /* Channels need longer names than normal blender objects */
        
@@ -419,3 +422,4 @@ typedef enum ACHAN_FLAG {
 
 #endif
 
+