Skip to content

Commit

Permalink
add: evaluate drivers on Python node trees
Browse files Browse the repository at this point in the history
  • Loading branch information
bdancer committed Sep 12, 2018
1 parent 1eba01b commit ddba5f3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion release/scripts/addons
Submodule addons updated from 142ef5 to b8c954
2 changes: 1 addition & 1 deletion release/scripts/addons_contrib
Submodule addons_contrib updated from 15b25a to 8d0956
3 changes: 3 additions & 0 deletions source/blender/blenkernel/BKE_animsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ void BKE_fcurves_main_cb(struct Main *bmain, ID_FCurve_Edit_Callback func, void
/* Evaluation loop for evaluating animation data */
void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, short recalc);

/* Evaluation loop for evaluating Python nodes trees animation data */
void BKE_animsys_evaluate_animdata_pyntree(struct Main *main, struct Scene *scene, float ctime, short recalc);

/* 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);

Expand Down
9 changes: 9 additions & 0 deletions source/blender/blenkernel/intern/anim_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,15 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct
adt->recalc = 0;
}

void BKE_animsys_evaluate_animdata_pyntree(struct Main *main, struct Scene *scene, float ctime, short recalc)
{
for (bNodeTree *ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
if (ntree->type == NTREE_CUSTOM) {
BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, recalc);
}
}
}

/* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only
*
* This will evaluate only the animation info available in the animation data-blocks
Expand Down
9 changes: 8 additions & 1 deletion source/blender/blenkernel/intern/scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ void BKE_scene_frame_set(struct Scene *scene, double cfra)
* - these happen after objects are all done so that we can read in their final transform values,
* though this means that objects can't refer to scene info for guidance...
*/
static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
static void scene_update_drivers(Main *bmain, Scene *scene)
{
SceneRenderLayer *srl;
float ctime = BKE_scene_frame_get(scene);
Expand Down Expand Up @@ -1334,6 +1334,9 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS);
}

/* A hacky way to evaluate drivers for Python nodes */
BKE_animsys_evaluate_animdata_pyntree(bmain, scene, ctime, ADT_RECALC_DRIVERS);

/* world nodes */
if (scene->world && scene->world->nodetree) {
ID *nid = (ID *)scene->world->nodetree;
Expand Down Expand Up @@ -1888,6 +1891,10 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
#endif
{
DEG_evaluate_on_refresh(eval_ctx, scene->depsgraph, scene);

/* A hacky way to evaluate drivers for Python nodes */
const float ctime = BKE_scene_frame_get(scene);
BKE_animsys_evaluate_animdata_pyntree(bmain, scene, ctime, ADT_RECALC_DRIVERS);
}

/* update sound system animation (TODO, move to depsgraph) */
Expand Down
16 changes: 16 additions & 0 deletions source/blender/editors/animation/anim_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,19 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, Scene *scene, int
return sorted_bases;
}

static size_t animdata_filter_dopesheet_pyntree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode)
{
Main *main = (Main*)ac->bmain;
size_t items = 0;

for (bNodeTree *ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
if (ntree->type == NTREE_CUSTOM) {
items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, &sce->id, ntree, filter_mode);
}
}

return items;
}

// TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted)
static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode)
Expand Down Expand Up @@ -2982,6 +2995,9 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b
/* scene-linked animation - e.g. world, compositing nodes, scene anim (including sequencer currently) */
items += animdata_filter_dopesheet_scene(ac, anim_data, ads, scene, filter_mode);

/* Python node trees */
items += animdata_filter_dopesheet_pyntree(ac, anim_data, ads, scene, filter_mode);

/* If filtering for channel drawing, we want the objects in alphabetical order,
* to make it easier to predict where items are in the hierarchy
* - This order only really matters if we need to show all channels in the list (e.g. for drawing)
Expand Down
2 changes: 1 addition & 1 deletion source/tools
Submodule tools updated from 869b0a to 870f46

0 comments on commit ddba5f3

Please sign in to comment.