small merge needed for testing new animsys in 2.5 BGE, mixing own changes with merge...
[blender.git] / source / blender / blenkernel / intern / depsgraph.c
index 4f083c4bf9b5f93c364d93a8d6c6e8a096b8e897..dfe3b7ea27943f5d2ca8301c4290a21f683c7709 100644 (file)
@@ -33,8 +33,6 @@
 #include "BLI_winstuff.h"
 #endif
 
-//#include "BMF_Api.h"
-
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 
@@ -55,7 +53,7 @@
 #include "DNA_object_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_fluidsim.h"
-#include "DNA_oops_types.h"
+#include "DNA_outliner_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -312,57 +310,29 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
        
        for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
                ChannelDriver *driver= fcu->driver;
+               DriverTarget *dtar;
                
-               if (driver->type == DRIVER_TYPE_PYTHON) {
-                       /* PyDriver / 'Expression' */
-                       
-                       /* skip if invalid in some way */
-                       if ((driver->flag & DRIVER_FLAG_INVALID) || (driver->expression[0] == '\0'))
-                               continue;
-#ifndef DISABLE_PYTHON
-                       else {
-                               /* now we need refs to all objects mentioned in this
-                                * pydriver expression, to call 'dag_add_relation'
-                                * for each of them */
-                               Object **obarray = BPY_pydriver_get_objects(fcu->driver);
-                               if (obarray) {
-                                       Object *ob, **oba = obarray;
+               /* loop over targets, adding relationships as appropriate */
+               for (dtar= driver->targets.first; dtar; dtar= dtar->next) {
+                       if (dtar->id) {
+                               if (GS(dtar->id->name)==ID_OB) {
+                                       Object *ob= (Object *)dtar->id;
                                        
-                                       while (*oba) {
-                                               ob = *oba;
-                                               node1 = dag_get_node(dag, ob);
-                                               if (ob->type == OB_ARMATURE)
-                                                       dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Python Driver");
-                                               else
-                                                       dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Python Driver");
-                                               oba++;
-                                       }
+                                       /* normal channel-drives-channel */
+                                       node1 = dag_get_node(dag, dtar->id);
                                        
-                                       MEM_freeN(obarray);
+                                       /* check if bone... */
+                                       if ((ob->type==OB_ARMATURE) && dtar->rna_path && strstr(dtar->rna_path, "pose.pose_channels["))
+                                               dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver");
+                                       /* check if ob data */
+                                       else if (dtar->rna_path && strstr(dtar->rna_path, "data."))
+                                               dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver");
+                                       /* normal */
+                                       else
+                                               dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Driver");
                                }
                        }
-#endif /* DISABLE_PYTHON */
-               }
-               else if (driver->type == DRIVER_TYPE_ROTDIFF) {
-                       // XXX rotational difference 
-               }
-               else if (driver->id) {
-                       /* normal channel-drives-channel */
-                       node1 = dag_get_node(dag, driver->id);  // XXX we assume that id is an object...
-                       
-                       // XXX what happens for bone drivers?
-                       dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Ipo Driver");
-               }
-#if 0 // XXX old 'normal' type
-
-               else if (icu->driver->ob) {
-                       node1 = dag_get_node(dag, icu->driver->ob);
-                       if(icu->driver->blocktype==ID_AR)
-                               dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Ipo Driver");
-                       else
-                               dag_add_relation(dag, node1, node, isdata?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Ipo Driver");
                }
-#endif // XXX old 'normal' type
        }
 }
 
@@ -442,35 +412,10 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
        
        /* driver dependencies, nla modifiers */
 #if 0 // XXX old animation system
-       if(ob->ipo) 
-               dag_add_driver_relation(ob->ipo, dag, node, 0);
-       
-       key= ob_get_key(ob);
-       if(key && key->ipo)
-               dag_add_driver_relation(key->ipo, dag, node, 1);
-       
-       for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next)
-               if(conchan->ipo)
-                       dag_add_driver_relation(conchan->ipo, dag, node, 0);
-
-       if(ob->action) {
-               bActionChannel *chan;
-               for (chan = ob->action->chanbase.first; chan; chan=chan->next){
-                       if(chan->ipo)
-                               dag_add_driver_relation(chan->ipo, dag, node, 1);
-                       for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next)
-                               if(conchan->ipo)
-                                       dag_add_driver_relation(conchan->ipo, dag, node, 1);
-               }
-       }
        if(ob->nlastrips.first) {
                bActionStrip *strip;
                bActionChannel *chan;
                for(strip= ob->nlastrips.first; strip; strip= strip->next) {
-                       if(strip->act && strip->act!=ob->action)
-                               for (chan = strip->act->chanbase.first; chan; chan=chan->next)
-                                       if(chan->ipo)
-                                               dag_add_driver_relation(chan->ipo, dag, node, 1);
                        if(strip->modifiers.first) {
                                bActionModifier *amod;
                                for(amod= strip->modifiers.first; amod; amod= amod->next) {
@@ -2040,7 +1985,12 @@ static void dag_object_time_update_flags(Object *ob)
                }
        }
 #endif // XXX old animation system
-       if(animdata_use_time(ob->adt)) ob->recalc |= OB_RECALC;
+       
+       if(animdata_use_time(ob->adt)) {
+               ob->recalc |= OB_RECALC;
+               ob->adt->recalc |= ADT_RECALC_ANIM;
+       }
+       
        if((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
        
        if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;