Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-09-20 13:48:28 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-09-25 15:40:05 +0300
commit4db2a08281f8495421938e0b2f6a802420afba36 (patch)
treebf5eed46c77864e47f50566a8ffa9162cc07670d
parentc77a0d7dc62ee1b07ba50cdb3870ad5dbed3450a (diff)
Motion paths: Refactor, make update range more explicit
Allows to have a higher versatility in the API. Should be no functional changes.
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c10
-rw-r--r--source/blender/editors/armature/pose_edit.c24
-rw-r--r--source/blender/editors/armature/pose_transform.c4
-rw-r--r--source/blender/editors/armature/pose_utils.c3
-rw-r--r--source/blender/editors/include/ED_anim_api.h15
-rw-r--r--source/blender/editors/include/ED_armature.h10
-rw-r--r--source/blender/editors/include/ED_object.h10
-rw-r--r--source/blender/editors/object/object_edit.c24
-rw-r--r--source/blender/editors/transform/transform_convert.c10
-rw-r--r--source/blender/editors/transform/transform_generics.c4
10 files changed, 86 insertions, 28 deletions
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 33be56ce870..9d94b14250a 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -220,8 +220,8 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
Main *bmain,
Scene *scene,
ListBase *targets,
- bool restore,
- bool current_frame_only)
+ eAnimvizCalcRange range,
+ bool restore)
{
/* sanity check */
if (ELEM(NULL, targets, targets->first)) {
@@ -248,7 +248,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
/* Limit frame range if we are updating just the current frame. */
/* set frame values */
int cfra = CFRA;
- if (current_frame_only) {
+ if (range == ANIMVIZ_CALC_RANGE_CURRENT_FRAME) {
if (cfra < sfra || cfra > efra) {
return;
}
@@ -308,7 +308,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
efra,
efra - sfra + 1);
for (CFRA = sfra; CFRA <= efra; CFRA++) {
- if (current_frame_only) {
+ if (range == ANIMVIZ_CALC_RANGE_CURRENT_FRAME) {
/* For current frame, only update tagged. */
BKE_scene_graph_update_tagged(depsgraph, bmain);
}
@@ -326,7 +326,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
* may be a temporary one that works on a subset of the data.
* We always have to restore the current frame though. */
CFRA = cfra;
- if (!current_frame_only && restore) {
+ if (range != ANIMVIZ_CALC_RANGE_CURRENT_FRAME && restore) {
motionpaths_calc_update_scene(bmain, depsgraph);
}
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);
}
}
}
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index cb6c66ed795..c262f390dc6 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -834,12 +834,23 @@ void ED_drivers_editor_init(struct bContext *C, struct ScrArea *sa);
/* ************************************************ */
+typedef enum eAnimvizCalcRange {
+ /* Update motion paths at the current frame only. */
+ ANIMVIZ_CALC_RANGE_CURRENT_FRAME,
+
+ /* Try to limit updates to a close neighborhood of the current frame. */
+ ANIMVIZ_CALC_RANGE_CHANGED,
+
+ /* Update an entire range of the motion paths. */
+ ANIMVIZ_CALC_RANGE_FULL,
+} eAnimvizCalcRange;
+
void animviz_calc_motionpaths(struct Depsgraph *depsgraph,
struct Main *bmain,
struct Scene *scene,
ListBase *targets,
- bool restore,
- bool current_frame_only);
+ eAnimvizCalcRange range,
+ bool restore);
void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 173ba65fc47..7ac42967dda 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -284,10 +284,18 @@ bool ED_pose_deselect_all_multi(struct bContext *C, int select_mode, const bool
bool ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility);
void ED_pose_bone_select_tag_update(struct Object *ob);
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
+
+/* Corresponds to eAnimvizCalcRange. */
+typedef enum ePosePathCalcRange {
+ POSE_PATH_CALC_RANGE_CURRENT_FRAME,
+ POSE_PATH_CALC_RANGE_CHANGED,
+ POSE_PATH_CALC_RANGE_FULL,
+} ePosePathCalcRange;
void ED_pose_recalculate_paths(struct bContext *C,
struct Scene *scene,
struct Object *ob,
- bool current_frame_only);
+ ePosePathCalcRange range);
+
struct Object *ED_pose_object_from_context(struct bContext *C);
/* meshlaplacian.c */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index c481c19a552..38d75aa57e9 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -238,9 +238,17 @@ void ED_object_single_user(struct Main *bmain, struct Scene *scene, struct Objec
/* object motion paths */
void ED_objects_clear_paths(struct bContext *C, bool only_selected);
+
+/* Corresponds to eAnimvizCalcRange. */
+typedef enum eObjectPathCalcRange {
+ OBJECT_PATH_CALC_RANGE_CURRENT_FRAME,
+ OBJECT_PATH_CALC_RANGE_CHANGED,
+ OBJECT_PATH_CALC_RANGE_FULL,
+} eObjectPathCalcRange;
+
void ED_objects_recalculate_paths(struct bContext *C,
struct Scene *scene,
- bool current_frame_only);
+ eObjectPathCalcRange range);
/* constraints */
struct ListBase *get_active_constraints(struct Object *ob);
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);
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 67bb132972e..81b7c7f8c9e 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -2237,9 +2237,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Update motion paths once for all transformed bones in an object. */
GSetIterator gs_iter;
GSET_ITER (gs_iter, motionpath_updates) {
- bool current_frame_only = canceled;
+ const ePosePathCalcRange range = canceled ? POSE_PATH_CALC_RANGE_CURRENT_FRAME :
+ POSE_PATH_CALC_RANGE_CHANGED;
ob = BLI_gsetIterator_getKey(&gs_iter);
- ED_pose_recalculate_paths(C, t->scene, ob, current_frame_only);
+ ED_pose_recalculate_paths(C, t->scene, ob, range);
}
BLI_gset_free(motionpath_updates, NULL);
}
@@ -2320,8 +2321,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (motionpath_update) {
/* Update motion paths once for all transformed objects. */
- bool current_frame_only = canceled;
- ED_objects_recalculate_paths(C, t->scene, current_frame_only);
+ const eObjectPathCalcRange range = canceled ? OBJECT_PATH_CALC_RANGE_CURRENT_FRAME :
+ OBJECT_PATH_CALC_RANGE_CHANGED;
+ ED_objects_recalculate_paths(C, t->scene, range);
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 76f699e3dc4..d05edb8d805 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1088,7 +1088,7 @@ static void recalcData_objects(TransInfo *t)
GSetIterator gs_iter;
GSET_ITER (gs_iter, motionpath_updates) {
Object *ob = BLI_gsetIterator_getKey(&gs_iter);
- ED_pose_recalculate_paths(t->context, t->scene, ob, true);
+ ED_pose_recalculate_paths(t->context, t->scene, ob, POSE_PATH_CALC_RANGE_CURRENT_FRAME);
}
BLI_gset_free(motionpath_updates, NULL);
}
@@ -1146,7 +1146,7 @@ static void recalcData_objects(TransInfo *t)
if (motionpath_update) {
/* Update motion paths once for all transformed objects. */
- ED_objects_recalculate_paths(t->context, t->scene, true);
+ ED_objects_recalculate_paths(t->context, t->scene, OBJECT_PATH_CALC_RANGE_CHANGED);
}
if (t->options & CTX_OBMODE_XFORM_SKIP_CHILDREN) {