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 Marmont <Kdaf>2022-02-28 14:23:56 +0300
committerSybren A. Stüvel <sybren@blender.org>2022-02-28 14:28:19 +0300
commit1558b270e9fcbc2e23fa248b0e7e770dddae155c (patch)
tree1377db616df34efcb147664788808d85338ba19d /source/blender/editors/object/object_edit.c
parent6f23401e984ee5bad621109ff78eeb6850044fee (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 The Motion Paths operators are now also added to the Object context menu and the Dopesheet context menu. The scene range operator was removed, because the operators now automatically find the range when baking the motion paths. The clear operator now appears separated in "Selected Only" and "All", because it was not clear for the user what the button was doing. Reviewed By: sybren, looch 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.c108
1 files changed, 37 insertions, 71 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4da278b7a31..96970c3e208 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -21,6 +21,7 @@
#include "BLT_translation.h"
+#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
@@ -73,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"
@@ -1209,30 +1211,32 @@ 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;
+ /* When operator is not invoked, dismiss the operator settings */
+ if (op->flag & OP_IS_INVOKE) {
+ bAnimVizSettings *avs = &ob->avs;
+ /* grab baking settings from operator settings */
+ 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);
@@ -1251,9 +1255,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;
@@ -1264,24 +1268,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",
+ "");
}
/** \} */
@@ -1300,13 +1298,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);
@@ -1456,44 +1460,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;
-}
-
/** \} */
/* -------------------------------------------------------------------- */