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)
This commit is contained in:
2018-08-20 16:12:37 +12:00
parent 76ea32d192
commit 6f2735b2bf
7 changed files with 84 additions and 0 deletions

View File

@@ -52,6 +52,12 @@ class MotionPathButtonsPanel:
sub.prop(mps, "frame_step", text="Step")
if mps.type == 'RANGE':
if bones:
sub.operator("pose.paths_range_update")
else:
sub.operator("object.paths_range_update")
col = layout.column(align=True)
if bones:
col.label(text="Cache for Bone:")

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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 *********************/

View File

@@ -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);

View File

@@ -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);