RNA wrapping of Action Groups:
authorJoshua Leung <aligorith@gmail.com>
Fri, 18 Dec 2009 03:47:57 +0000 (03:47 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 18 Dec 2009 03:47:57 +0000 (03:47 +0000)
Finished wrapping Action Groups in RNA to help debug some bugs showing up in the Animation Editors for some files from the Durian team. Access is strictly read-only for these added settings, given the trouble already caused by these problems.

source/blender/editors/animation/anim_filter.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_fcurve.c

index 2d9ab6366428757345d0612225a106f038ee5e07..89f9511688f1d88ceb890eb75843801457580185 100644 (file)
@@ -763,12 +763,12 @@ static int skip_fcurve_selected_data(FCurve *fcu, ID *owner_id)
                Object *ob= (Object *)owner_id;
                
                /* only consider if F-Curve involves pose.bones */
-               if ((fcu->rna_path) && strstr(fcu->rna_path, "bones")) {
+               if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) {
                        bPoseChannel *pchan;
                        char *bone_name;
                        
                        /* get bone-name, and check if this bone is selected */
-                       bone_name= BLI_getQuotedStr(fcu->rna_path, "bones[");
+                       bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones[");
                        pchan= get_pose_channel(ob->pose, bone_name);
                        if (bone_name) MEM_freeN(bone_name);
                        
index 8ae0ebacff7a8f9479f2753571a81b71e3839d80..59200a2de55e49f4388219bbb0c9cb16daf62e30 100644 (file)
@@ -507,7 +507,7 @@ int RNA_struct_is_a(StructRNA *type, StructRNA *srna)
 
 PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
 {
-       if(identifier[0]=='[' && identifier[1]=='"') {
+       if(identifier[0]=='[' && identifier[1]=='"') { // "  (dummy comment to avoid confusing some function lists in text editors)
                /* id prop lookup, not so common */
                PropertyRNA *r_prop= NULL;
                PointerRNA r_ptr; /* only support single level props */
index 4cb7080f05e2f2691c0e659c8b4498a4a49ade5f..3f6729136d5cbed2b44e2cca5b94d7e26cc8693d 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "rna_internal.h"
 
+#include "DNA_anim_types.h"
 #include "DNA_action_types.h"
 #include "DNA_scene_types.h"
 
 
 #ifdef RNA_RUNTIME
 
+static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
+{
+       ListBaseIterator *internal= iter->internal;
+       FCurve *fcu= (FCurve*)internal->link;
+       bActionGroup *grp= fcu->grp;
+       
+       /* only continue if the next F-Curve (if existant) belongs in the same group */
+       if ((fcu->next) && (fcu->next->grp == grp))
+               internal->link= (Link*)fcu->next;
+       else
+               internal->link= NULL;
+               
+       iter->valid= (internal->link != NULL);
+}
+
 #else
 
 static void rna_def_dopesheet(BlenderRNA *brna)
@@ -167,13 +183,18 @@ static void rna_def_action_group(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Name", "");
        RNA_def_struct_name_property(srna, prop);
        
-       /* dna warns not to treat the Action Channel listbase in the Action Group struct like a
-          normal listbase. I'll leave this here but comment out, for Joshua to review. He can 
-          probably shed some more light on why this is */
-       /*prop= RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
+       /* WARNING: be very careful when working with this list, since the endpoint is not
+        * defined like a standard ListBase. Adding/removing channels from this list needs
+        * extreme care, otherwise the F-Curve list running through adjacent groups does
+        * not match up with the one stored in the Action, resulting in curves which do not
+        * show up in animation editors. For that reason, such operations are currently 
+        * prohibited.
+        */
+       prop= RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);
        RNA_def_property_struct_type(prop, "FCurve");
-       RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group.");*/
+       RNA_def_property_collection_funcs(prop, 0, "rna_ActionGroup_channels_next", 0, 0, 0, 0, 0);
+       RNA_def_property_ui_text(prop, "Channels", "F-Curves in this group.");
        
        prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED);
index 9791855697602b22b820dbb2ab8016ee2abecd7a..f3d36d60c23ce199f4aa384a2beb5bda3746d4b4 100644 (file)
@@ -925,6 +925,11 @@ static void rna_def_fcurve(BlenderRNA *brna)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
        
+       prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "grp");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX this is not editable for now, since editing this will easily break the visible hierarchy
+       RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to.");
+       
        /* Path + Array Index */
        prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
        RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");