From 4db2a08281f8495421938e0b2f6a802420afba36 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 20 Sep 2019 12:48:28 +0200 Subject: Motion paths: Refactor, make update range more explicit Allows to have a higher versatility in the API. Should be no functional changes. --- source/blender/editors/object/object_edit.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/object/object_edit.c') diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 74abe104134..77897c909d9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -910,12 +910,25 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) /* ********************************************** */ /* Motion Paths */ +static eAnimvizCalcRange object_path_convert_range(eObjectPathCalcRange range) +{ + switch (range) { + case OBJECT_PATH_CALC_RANGE_CURRENT_FRAME: + return ANIMVIZ_CALC_RANGE_CURRENT_FRAME; + case OBJECT_PATH_CALC_RANGE_CHANGED: + return ANIMVIZ_CALC_RANGE_CHANGED; + case OBJECT_PATH_CALC_RANGE_FULL: + return ANIMVIZ_CALC_RANGE_FULL; + } + return ANIMVIZ_CALC_RANGE_FULL; +} + /* For the objects with animation: update paths for those that have got them * This should selectively update paths that exist... * * To be called from various tools that do incremental updates */ -void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_only) +void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRange range) { /* Transform doesn't always have context available to do update. */ if (C == NULL) { @@ -937,10 +950,11 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_ CTX_DATA_END; /* recalculate paths, then free */ - animviz_calc_motionpaths(depsgraph, bmain, scene, &targets, true, current_frame_only); + animviz_calc_motionpaths( + depsgraph, bmain, scene, &targets, object_path_convert_range(range), true); BLI_freelistN(&targets); - if (!current_frame_only) { + if (range != OBJECT_PATH_CALC_RANGE_CURRENT_FRAME) { /* Tag objects for copy on write - so paths will draw/redraw * For currently frame only we update evaluated object directly. */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -995,7 +1009,7 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* calculate the paths for objects that have them (and are tagged to get refreshed) */ - ED_objects_recalculate_paths(C, scene, false); + ED_objects_recalculate_paths(C, scene, OBJECT_PATH_CALC_RANGE_FULL); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -1060,7 +1074,7 @@ static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) } /* calculate the paths for objects that have them (and are tagged to get refreshed) */ - ED_objects_recalculate_paths(C, scene, false); + ED_objects_recalculate_paths(C, scene, OBJECT_PATH_CALC_RANGE_FULL); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); -- cgit v1.2.3