Driver Editing Tweaks:
authorJoshua Leung <aligorith@gmail.com>
Fri, 13 Nov 2009 01:04:01 +0000 (01:04 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 13 Nov 2009 01:04:01 +0000 (01:04 +0000)
* Updating dependencies for drivers now clears the disabled status of the relevant Driver FCurve too
* Changing the type of ID-block used for Driver Targets and Keying Set Paths will now clear the pointer to the ID-block if it is of the wrong type.

source/blender/blenkernel/intern/fcurve.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/makesrna/intern/rna_animation.c
source/blender/makesrna/intern/rna_fcurve.c

index a1e6570608f8eeccfb5dc2d1f0c6b381ab6c8a1d..e8dc843dd011ea8d7d8f39c36bd9d6e204925406 100644 (file)
@@ -801,8 +801,13 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar)
                                break;
                }
        }
-       else if (G.f & G_DEBUG)
-               printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path);
+       else {
+               if (G.f & G_DEBUG)
+                       printf("Driver Evaluation Error: cannot resolve target for %s -> %s \n", id->name, path);
+               
+               driver->flag |= DRIVER_FLAG_INVALID;
+               return 0.0f;
+       }
        
        return value;
 }
@@ -924,8 +929,8 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
                        }                       
                        
                        /* use the final posed locations */
-                       mat4_to_quat( q1,pchan->pose_mat);
-                       mat4_to_quat( q2,pchan2->pose_mat);
+                       mat4_to_quat(q1, pchan->pose_mat);
+                       mat4_to_quat(q2, pchan2->pose_mat);
                        
                        invert_qt(q1);
                        mul_qt_qtqt(quat, q1, q2);
index 38289e983914e3236fc77526ec5c24503cee5f76..f686d8f24b9a5b75cbf8bbf907f9aa996c56d7f1 100644 (file)
@@ -279,6 +279,7 @@ static void driver_update_flags_cb (bContext *C, void *fcu_v, void *dummy_v)
        ChannelDriver *driver= fcu->driver;
        
        /* clear invalid flags */
+       fcu->flag &= ~FCURVE_DISABLED; // XXX?
        driver->flag &= ~DRIVER_FLAG_INVALID;
 }
 
index 23a9c48710eefd9b8ed727fd4d174a4009694fe0..3e7638b3d51fde11014b0da642e2774c257572c9 100644 (file)
@@ -78,6 +78,16 @@ static int rna_ksPath_id_editable(PointerRNA *ptr)
        return (ksp->idtype)? PROP_EDITABLE : 0;
 }
 
+static void rna_ksPath_id_type_set(PointerRNA *ptr, int value)
+{
+       KS_Path *data= (KS_Path*)(ptr->data);
+       
+       /* set the driver type, then clear the id-block if the type is invalid */
+       data->idtype= value;
+       if ((data->id) && (GS(data->id->name) != data->idtype))
+               data->id= NULL;
+}
+
 static void rna_ksPath_RnaPath_get(PointerRNA *ptr, char *value)
 {
        KS_Path *ksp= (KS_Path *)ptr->data;
@@ -179,6 +189,7 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "idtype");
        RNA_def_property_enum_items(prop, id_type_items);
        RNA_def_property_enum_default(prop, ID_OB);
+       RNA_def_property_enum_funcs(prop, NULL, "rna_ksPath_id_type_set", NULL);
        RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used.");
        
        /* Group */
index 294f38cf3f79b750ee71195bd580e515253ae166..085f0030422966137780921b15fdb20aafe6a264 100644 (file)
@@ -111,6 +111,16 @@ static int rna_DriverTarget_id_editable(PointerRNA *ptr)
        return (dtar->idtype)? PROP_EDITABLE : 0;
 }
 
+static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
+{
+       DriverTarget *data= (DriverTarget*)(ptr->data);
+       
+       /* set the driver type, then clear the id-block if the type is invalid */
+       data->idtype= value;
+       if ((data->id) && (GS(data->id->name) != data->idtype))
+               data->id= NULL;
+}
+
 static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
 {
        DriverTarget *dtar= (DriverTarget *)ptr->data;
@@ -568,6 +578,7 @@ static void rna_def_drivertarget(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "idtype");
        RNA_def_property_enum_items(prop, id_type_items);
        RNA_def_property_enum_default(prop, ID_OB);
+       RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL);
        RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used.");
        //RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX disabled for now, until we can turn off auto updates