Commit: 84e7b5a1079deb0e75b95885f0c7ab722062294c
Author: Sergey Sharybin
Date:   Wed Nov 12 16:04:48 2014 +0100
Branches: depsgraph_refactor
https://developer.blender.org/rB84e7b5a1079deb0e75b95885f0c7ab722062294c

Depsgraph: Cleanup of animation callbacks

- Use single callback for all action fcurves
- Driver evaluation was actually evaluating the whole animation system,
  not just a given fcurve.

===================================================================

M       source/blender/blenkernel/BKE_animsys.h
M       source/blender/blenkernel/intern/anim_sys.c
M       source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M       source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M       source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M       source/blender/depsgraph/intern/depsgraph_types.h
M       source/blender/depsgraph/intern/stubs.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_animsys.h 
b/source/blender/blenkernel/BKE_animsys.h
index a5109ac..02e280f 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -157,6 +157,9 @@ void BKE_animsys_evaluate_animdata(struct Scene *scene, 
struct ID *id, struct An
 /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data 
Only */
 void BKE_animsys_evaluate_all_animation(struct Main *main, struct Scene 
*scene, float ctime);
 
+/* TODO(sergey): This is mainly a temp public function. */
+struct FCurve;
+bool BKE_animsys_execute_fcurve(struct PointerRNA *ptr, struct AnimMapper 
*remap, struct FCurve *fcu);
 
 /* ------------ Specialized API --------------- */
 /* There are a few special tools which require these following functions. They 
are NOT to be used
diff --git a/source/blender/blenkernel/intern/anim_sys.c 
b/source/blender/blenkernel/intern/anim_sys.c
index 2fb832d..ab80b32 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1484,7 +1484,7 @@ static bool animsys_write_rna_setting(PointerRNA *ptr, 
char *path, int array_ind
 }
 
 /* Simple replacement based data-setting of the FCurve using RNA */
-static bool animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve 
*fcu)
+bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve 
*fcu)
 {
        char *path = NULL;
        bool free_path = false;
@@ -1519,7 +1519,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr, 
ListBase *list, AnimMapper
                        /* check if this curve should be skipped */
                        if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 
0) {
                                calculate_fcurve(fcu, ctime);
-                               animsys_execute_fcurve(ptr, remap, fcu); 
+                               BKE_animsys_execute_fcurve(ptr, remap, fcu); 
                        }
                }
        }
@@ -1549,7 +1549,7 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, 
AnimData *adt, float ctime
                                 * NOTE: for 'layering' option later on, we 
should check if we should remove old value before adding
                                 *       new to only be done when drivers only 
changed */
                                calculate_fcurve(fcu, ctime);
-                               ok = animsys_execute_fcurve(ptr, NULL, fcu);
+                               ok = BKE_animsys_execute_fcurve(ptr, NULL, fcu);
                                
                                /* clear recalc flag */
                                driver->flag &= ~DRIVER_FLAG_RECALC;
@@ -1618,7 +1618,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, 
bAction *act, bActionGroup *
                /* check if this curve should be skipped */
                if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
                        calculate_fcurve(fcu, ctime);
-                       animsys_execute_fcurve(ptr, remap, fcu); 
+                       BKE_animsys_execute_fcurve(ptr, remap, fcu); 
                }
        }
 }
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp 
b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 890cf86..85bf12f 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -349,19 +349,17 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
 
                /* actions */
                if (adt->action != NULL) {
-                       for (FCurve *fcu = (FCurve *)adt->action->curves.first; 
fcu; fcu = fcu->next) {
-                               TimeSourceDepsNode *time_src = 
m_graph->find_time_source();
-                               add_operation_node(id, DEPSNODE_TYPE_ANIMATION,
-                                                  DEPSOP_TYPE_EXEC, 
bind(BKE_animsys_eval_driver, _1, id, fcu, time_src),
-                                                  
deg_op_name_action_fcurve(adt->action, fcu));
-                       }
+                       TimeSourceDepsNode *time_src = 
m_graph->find_time_source();
+                       add_operation_node(id, DEPSNODE_TYPE_ANIMATION,
+                                          DEPSOP_TYPE_EXEC, 
bind(BKE_animsys_eval_action, _1, id, adt->action, time_src),
+                                          deg_op_name_action(adt->action));
                        /* TODO(sergey): Action groups. */
                }
 
                /* drivers */
                for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = 
fcu->next) {
                        /* create driver */
-                       /*OperationDepsNode *driver_node =*/ build_driver(id, 
fcu);
+                       /*OperationDepsNode *driver_node =*/ //build_driver(id, 
fcu);
 
                        /* hook up update callback associated with F-Curve */
                        // ...
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp 
b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 4babe4d..f6d455e 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -500,11 +500,12 @@ void DepsgraphRelationBuilder::build_driver(ID *id, 
FCurve *fcurve)
                        if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && 
(dtar->pchan_name[0])) {
                                Object *ob = (Object *)dtar->id;
                                bPoseChannel *pchan = 
BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
-                               
-                               /* get node associated with bone */
-                               ComponentKey target_key(dtar->id, 
DEPSNODE_TYPE_BONE, pchan->name);
-                               add_relation(target_key, driver_key, 
DEPSREL_TYPE_DRIVER_TARGET,
-                                            "[Target -> Driver] DepsRel");
+                               if (pchan != NULL) {
+                                       /* get node associated with bone */
+                                       ComponentKey target_key(dtar->id, 
DEPSNODE_TYPE_BONE, pchan->name);
+                                       add_relation(target_key, driver_key, 
DEPSREL_TYPE_DRIVER_TARGET,
+                                                    "[Target -> Driver] 
DepsRel");
+                               }
                        }
                        else {
                                /* resolve path to get node */
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp 
b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 4e10824..59603df 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -44,6 +44,7 @@ extern "C" {
 #include "BKE_action.h"
 #include "BKE_animsys.h"
 #include "BKE_armature.h"
+#include "BKE_fcurve.h"
 #include "BKE_object.h"
 
 #include "DEG_depsgraph.h"
@@ -62,7 +63,7 @@ extern "C" {
 
 #include "stubs.h" // XXX: THIS MUST BE REMOVED WHEN THE DEPSGRAPH REFACTOR IS 
DONE
 
-void BKE_animsys_eval_driver(EvaluationContext *eval_ctx, ID *id, FCurve 
*fcurve, TimeSourceDepsNode *time_src)
+void BKE_animsys_eval_action(EvaluationContext *eval_ctx, ID *id, bAction 
*action, TimeSourceDepsNode *time_src)
 {
        printf("%s on %s\n", __func__, id->name);
        if (ID_REAL_USERS(id) > 0) {
@@ -72,6 +73,22 @@ void BKE_animsys_eval_driver(EvaluationContext *eval_ctx, ID 
*id, FCurve *fcurve
        }
 }
 
+void BKE_animsys_eval_driver(EvaluationContext *eval_ctx, ID *id, FCurve 
*fcurve, TimeSourceDepsNode *time_src)
+{
+       /* TODO(sergey): De-duplicate with BKE animsys. */
+       printf("%s on %s\n", __func__, id->name);
+       if (ID_REAL_USERS(id) > 0 && (fcurve->driver->flag & 
DRIVER_FLAG_INVALID) == 0) {
+               float ctime = time_src->cfra;
+               PointerRNA id_ptr;
+               RNA_id_pointer_create(id, &id_ptr);
+               calculate_fcurve(fcurve, ctime);
+               if (!BKE_animsys_execute_fcurve(&id_ptr, NULL, fcurve)) {
+                       fcurve->driver->flag |= DRIVER_FLAG_INVALID;
+               }
+               fcurve->driver->flag &= ~DRIVER_FLAG_RECALC;
+       }
+}
+
 void BKE_pose_constraints_evaluate(EvaluationContext *eval_ctx, Object *ob, 
bPoseChannel *pchan) {}
 
 void BKE_pose_iktree_evaluate(EvaluationContext *eval_ctx, Object *ob, 
bPoseChannel *rootchan) {}
@@ -108,14 +125,9 @@ const string deg_op_name_pose_eval_flush = "Flush Pose 
Eval";
 const string deg_op_name_ik_solver = "IK Solver";
 const string deg_op_name_spline_ik_solver = "Spline IK Solver";
 const string deg_op_name_psys_eval = "PSys Eval";
-string deg_op_name_action_fcurve(const bAction *action, const FCurve *fcu)
+string deg_op_name_action(const bAction *action)
 {
-       if (fcu->rna_path != NULL) {
-               return string_format("Action FCurve @ %s:%s[%d]", 
action->id.name + 2, fcu->rna_path, fcu->array_index);
-       }
-       else {
-               return string_format("Action FCurve @ %s:%p", action->id.name, 
fcu);
-       }
+       return string_format("Action %s", action->id.name);
 }
 string deg_op_name_driver(const ChannelDriver *driver)
 {
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h 
b/source/blender/depsgraph/intern/depsgraph_types.h
index b283565..c772582 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -99,7 +99,7 @@ extern const string deg_op_name_pose_eval_flush;
 extern const string deg_op_name_ik_solver;
 extern const string deg_op_name_spline_ik_solver;
 extern const string deg_op_name_psys_eval;
-string deg_op_name_action_fcurve(const bAction *action, const FCurve *fcu);
+string deg_op_name_action(const bAction *action);
 string deg_op_name_driver(const ChannelDriver *driver);
 string deg_op_name_modifier(const ModifierData *md);
 
diff --git a/source/blender/depsgraph/intern/stubs.h 
b/source/blender/depsgraph/intern/stubs.h
index 86783cb..096650a 100644
--- a/source/blender/depsgraph/intern/stubs.h
+++ b/source/blender/depsgraph/intern/stubs.h
@@ -25,6 +25,7 @@ struct ParticleSystem;
 struct EvaluationContext;
 struct TimeSourceDepsNode;
 
+void BKE_animsys_eval_action(struct EvaluationContext *eval_ctx, ID *id, 
bAction *action, TimeSourceDepsNode *time_src);
 void BKE_animsys_eval_driver(struct EvaluationContext *eval_ctx, ID *id, 
FCurve *fcurve, TimeSourceDepsNode *time_src);
 
 void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx, Object 
*ob, bPoseChannel *pchan);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to