diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-20 13:48:28 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-25 15:40:05 +0300 |
commit | 4db2a08281f8495421938e0b2f6a802420afba36 (patch) | |
tree | bf5eed46c77864e47f50566a8ffa9162cc07670d /source/blender/editors/armature | |
parent | c77a0d7dc62ee1b07ba50cdb3870ad5dbed3450a (diff) |
Motion paths: Refactor, make update range more explicit
Allows to have a higher versatility in the API.
Should be no functional changes.
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/pose_edit.c | 24 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_transform.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_utils.c | 3 |
3 files changed, 23 insertions, 8 deletions
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 8f4896c0b82..e2c9828c20f 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -182,12 +182,25 @@ static bool pose_has_protected_selected(Object *ob, short warn) /* ********************************************** */ /* Motion Paths */ +static eAnimvizCalcRange pose_path_convert_range(ePosePathCalcRange range) +{ + switch (range) { + case POSE_PATH_CALC_RANGE_CURRENT_FRAME: + return ANIMVIZ_CALC_RANGE_CURRENT_FRAME; + case POSE_PATH_CALC_RANGE_CHANGED: + return ANIMVIZ_CALC_RANGE_CHANGED; + case POSE_PATH_CALC_RANGE_FULL: + return ANIMVIZ_CALC_RANGE_FULL; + } + return ANIMVIZ_CALC_RANGE_FULL; +} + /* For the object with pose/action: 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_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool current_frame_only) +void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathCalcRange range) { /* Transform doesn't always have context available to do update. */ if (C == NULL) { @@ -210,7 +223,8 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre TIMEIT_START(pose_path_calc); #endif - animviz_calc_motionpaths(depsgraph, bmain, scene, &targets, !free_depsgraph, current_frame_only); + animviz_calc_motionpaths( + depsgraph, bmain, scene, &targets, pose_path_convert_range(range), !free_depsgraph); #ifdef DEBUG_TIME TIMEIT_END(pose_path_calc); @@ -218,7 +232,7 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre BLI_freelistN(&targets); - if (!current_frame_only) { + if (range != POSE_PATH_CALC_RANGE_CURRENT_FRAME) { /* Tag armature object for copy on write - so paths will draw/redraw. * For currently frame only we update evaluated object directly. */ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); @@ -293,7 +307,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) /* calculate the bones that now have motionpaths... */ /* TODO: only make for the selected bones? */ - ED_pose_recalculate_paths(C, scene, ob, false); + ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL); #ifdef DEBUG_TIME TIMEIT_END(recalc_pose_paths); @@ -371,7 +385,7 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) /* calculate the bones that now have motionpaths... */ /* TODO: only make for the selected bones? */ - ED_pose_recalculate_paths(C, scene, ob, false); + ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 52a3f7711c4..c03fc0415ef 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -831,7 +831,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) /* Recalculate paths if any of the bones have paths... */ if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { - ED_pose_recalculate_paths(C, scene, ob, false); + ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL); } /* Notifiers for updates, */ @@ -1112,7 +1112,7 @@ static int pose_clear_transform_generic_exec(bContext *C, /* now recalculate paths */ if ((ob_iter->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { - ED_pose_recalculate_paths(C, scene, ob_iter, false); + ED_pose_recalculate_paths(C, scene, ob_iter, POSE_PATH_CALC_RANGE_FULL); } BLI_freelistN(&dsources); diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index fbaf2c896d0..3f6db956643 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -327,7 +327,8 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, if (ob->id.tag & LIB_TAG_DOIT) { if (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) { // ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear - ED_pose_recalculate_paths(C, scene, ob, false); + /* TODO(sergey): Should ensure we can use more narrow update range here. */ + ED_pose_recalculate_paths(C, scene, ob, POSE_PATH_CALC_RANGE_FULL); } } } |