diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-08-20 07:12:37 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-08-20 07:12:37 +0300 |
commit | 6f2735b2bf6f2cd532a9a816c39cde17006afe49 (patch) | |
tree | 3aa6e9bbc7829ec616d1269cd0e905a0dca81ed8 /source | |
parent | 76ea32d192693ac0d46270dd30c7e50a0bfcea62 (diff) |
Motion Paths UI: "Update from Scene Range" operator
Make it easier to update the frame range for motion paths from
the Scene's current frame range (render or preview range)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/armature/armature_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_edit.c | 37 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 37 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 1 |
6 files changed, 78 insertions, 0 deletions
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 7c0dd09a237..e28e9877eba 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -128,6 +128,7 @@ void POSE_OT_group_deselect(struct wmOperatorType *ot); void POSE_OT_paths_calculate(struct wmOperatorType *ot); void POSE_OT_paths_update(struct wmOperatorType *ot); void POSE_OT_paths_clear(struct wmOperatorType *ot); +void POSE_OT_paths_range_update(struct wmOperatorType *ot); void POSE_OT_autoside_names(struct wmOperatorType *ot); void POSE_OT_flip_names(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index d43d051deba..366aafcfa07 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -123,6 +123,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_paths_calculate); WM_operatortype_append(POSE_OT_paths_update); WM_operatortype_append(POSE_OT_paths_clear); + WM_operatortype_append(POSE_OT_paths_range_update); WM_operatortype_append(POSE_OT_autoside_names); WM_operatortype_append(POSE_OT_flip_names); diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index a2cd3c57101..571f766ee4c 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -436,6 +436,43 @@ void POSE_OT_paths_clear(wmOperatorType *ot) RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); } +/* --------- */ + +static int pose_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + + if (ELEM(NULL, scene, ob, ob->pose)) { + return OPERATOR_CANCELLED; + } + + /* use Preview Range or Full Frame Range - whichever is in use */ + ob->pose->avs.path_sf = PSFRA; + ob->pose->avs.path_ef = PEFRA; + + /* tag for updates */ + DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_paths_range_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Range from Scene"; + ot->idname = "POSE_OT_paths_range_update"; + ot->description = "Update frame range for motion paths from the Scene's current frame range"; + + /* callbacks */ + ot->exec = pose_update_paths_range_exec; + ot->poll = ED_operator_posemode_exclusive; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /* ********************************************** */ #if 0 /* UNUSED 2.5 */ static void pose_copy_menu(Scene *scene) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a6dad906579..1ca67f4132f 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1449,6 +1449,43 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot) RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); } +/* --------- */ + +static int object_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + /* loop over all edtiable 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, DEG_TAG_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; +} + /********************** Smooth/Flat *********************/ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ef8653541f0..c750a3fb2bd 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -89,6 +89,7 @@ void OBJECT_OT_shade_flat(struct wmOperatorType *ot); void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); void OBJECT_OT_paths_update(struct wmOperatorType *ot); void OBJECT_OT_paths_clear(struct wmOperatorType *ot); +void OBJECT_OT_paths_range_update(struct wmOperatorType *ot); void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot); void OBJECT_OT_move_to_collection(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index fd65867a246..c8726d92983 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -78,6 +78,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_paths_calculate); WM_operatortype_append(OBJECT_OT_paths_update); WM_operatortype_append(OBJECT_OT_paths_clear); + WM_operatortype_append(OBJECT_OT_paths_range_update); WM_operatortype_append(OBJECT_OT_forcefield_toggle); WM_operatortype_append(OBJECT_OT_parent_set); |