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:
authorColin Marmond <Kdaf>2022-04-26 13:29:22 +0300
committerSybren A. Stüvel <sybren@blender.org>2022-04-26 13:33:35 +0300
commit4e57b6ce77b15709d7a76382c2d185f9c845532c (patch)
tree2ba2d7c1ef368799779fbd3fd484f72077101e36 /source/blender/editors/object/object_edit.c
parent6cf148227b220dd5087241ad01b6d2d6fe9afb80 (diff)
Animation: Sensible frame range for motion paths
Motion paths can now be initialised to more sensible frame ranges, rather than simply 1-250: - Scene Frame Range - Selected Keyframes - All Keyframes Reviewed By: sybren, looch, dfelinto, pablico Maniphest Tasks: T93047 Differential Revision: https://developer.blender.org/D13687
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r--source/blender/editors/object/object_edit.c100
1 files changed, 31 insertions, 69 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 2518b2d201d..0275ace8ec9 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -74,6 +74,7 @@
#include "ED_curve.h"
#include "ED_gpencil.h"
#include "ED_image.h"
+#include "ED_keyframes_keylist.h"
#include "ED_lattice.h"
#include "ED_mball.h"
#include "ED_mesh.h"
@@ -1207,30 +1208,29 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEv
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->avs;
-
- RNA_int_set(op->ptr, "start_frame", avs->path_sf);
- RNA_int_set(op->ptr, "end_frame", avs->path_ef);
+ RNA_enum_set(op->ptr, "display_type", avs->path_type);
+ RNA_enum_set(op->ptr, "range", avs->path_range);
}
/* show popup dialog to allow editing of range... */
/* FIXME: hard-coded dimensions here are just arbitrary. */
- return WM_operator_props_dialog_popup(C, op, 200);
+ return WM_operator_props_dialog_popup(C, op, 270);
}
/* Calculate/recalculate whole paths (avs.path_sf to avs.path_ef) */
static int object_calculate_paths_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- int start = RNA_int_get(op->ptr, "start_frame");
- int end = RNA_int_get(op->ptr, "end_frame");
+ short path_type = RNA_enum_get(op->ptr, "display_type");
+ short path_range = RNA_enum_get(op->ptr, "range");
- /* set up path data for bones being calculated */
+ /* set up path data for objects being calculated */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
bAnimVizSettings *avs = &ob->avs;
-
/* grab baking settings from operator settings */
- avs->path_sf = start;
- avs->path_ef = end;
+ avs->path_type = path_type;
+ avs->path_range = path_range;
+ animviz_motionpath_compute_range(ob, scene);
/* verify that the selected object has the appropriate settings */
animviz_verify_motionpaths(op->reports, scene, ob, NULL);
@@ -1249,9 +1249,9 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
void OBJECT_OT_paths_calculate(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Calculate Object Paths";
+ ot->name = "Calculate Object Motion Paths";
ot->idname = "OBJECT_OT_paths_calculate";
- ot->description = "Calculate motion paths for the selected objects";
+ ot->description = "Generate motion paths for the selected objects";
/* api callbacks */
ot->invoke = object_calculate_paths_invoke;
@@ -1262,24 +1262,18 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- RNA_def_int(ot->srna,
- "start_frame",
- 1,
- MINAFRAME,
- MAXFRAME,
- "Start",
- "First frame to calculate object paths on",
- MINFRAME,
- MAXFRAME / 2.0);
- RNA_def_int(ot->srna,
- "end_frame",
- 250,
- MINAFRAME,
- MAXFRAME,
- "End",
- "Last frame to calculate object paths on",
- MINFRAME,
- MAXFRAME / 2.0);
+ RNA_def_enum(ot->srna,
+ "display_type",
+ rna_enum_motionpath_display_type_items,
+ MOTIONPATH_TYPE_RANGE,
+ "Display type",
+ "");
+ RNA_def_enum(ot->srna,
+ "range",
+ rna_enum_motionpath_range_items,
+ MOTIONPATH_RANGE_SCENE,
+ "Computation Range",
+ "");
}
/** \} */
@@ -1298,13 +1292,19 @@ static bool object_update_paths_poll(bContext *C)
return false;
}
-static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
+static int object_update_paths_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
if (scene == NULL) {
return OPERATOR_CANCELLED;
}
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
+ animviz_motionpath_compute_range(ob, scene);
+ /* verify that the selected object has the appropriate settings */
+ animviz_verify_motionpaths(op->reports, scene, ob, NULL);
+ }
+ CTX_DATA_END;
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths_selected(C, scene, OBJECT_PATH_CALC_RANGE_FULL);
@@ -1454,44 +1454,6 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot)
/** \} */
-/* -------------------------------------------------------------------- */
-/** \name Update Motion Paths Range from Scene Operator
- * \{ */
-
-static int object_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Scene *scene = CTX_data_scene(C);
-
- /* Loop over all editable objects in scene. */
- CTX_DATA_BEGIN (C, Object *, ob, editable_objects) {
- /* use Preview Range or Full Frame Range - whichever is in use */
- ob->avs.path_sf = PSFRA;
- ob->avs.path_ef = PEFRA;
-
- /* tag for updates */
- DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
- WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
- }
- CTX_DATA_END;
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_paths_range_update(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Update Range from Scene";
- ot->idname = "OBJECT_OT_paths_range_update";
- ot->description = "Update frame range for motion paths from the Scene's current frame range";
-
- /* callbacks */
- ot->exec = object_update_paths_range_exec;
- ot->poll = ED_operator_object_active_editable;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
/** \} */
/* -------------------------------------------------------------------- */