diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py index 3f25006766e..1f798f46590 100644 --- a/release/scripts/startup/bl_ui/properties_animviz.py +++ b/release/scripts/startup/bl_ui/properties_animviz.py @@ -65,12 +65,10 @@ class MotionPathButtonsPanel(): sub.prop(mpath, "frame_start", text="From") sub.prop(mpath, "frame_end", text="To") - sub = col.column() # align=True - sub.operator_context = 'EXEC_DEFAULT' if bones: - col.operator("pose.paths_calculate", text="Update", icon='BONE_DATA') + col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA') else: - col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA') + col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA') else: col.label(text="Not available yet...", icon='ERROR') col.label(text="Calculate Paths first", icon='INFO') diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 72d261ec187..11129f34f3e 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -117,6 +117,7 @@ void POSE_OT_group_select(struct wmOperatorType *ot); 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_autoside_names(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 9a15a100179..d7814e1eb4c 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -133,6 +133,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_group_deselect); 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_autoside_names); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 15d2d32c073..2ed5421e8ba 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -197,6 +197,7 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -291,6 +292,41 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + + if (ELEM(NULL, ob, scene)) + return OPERATOR_CANCELLED; + + /* calculate the bones that now have motionpaths... */ + // TODO: only make for the selected bones? + ED_pose_recalculate_paths(scene, ob); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Bone Paths"; + ot->idname = "POSE_OT_paths_update"; + ot->description = "Recalculate paths for bones that already have them"; + + /* api callbakcs */ + ot->exec = pose_update_paths_exec; + ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* for the object with pose/action: clear path curves for selected bones only */ static void ED_pose_clear_paths(Object *ob) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index dfc99f09a96..96099d51dc9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1125,6 +1125,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -1200,6 +1201,39 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + if (scene == NULL) + return OPERATOR_CANCELLED; + + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ + ED_objects_recalculate_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Object Paths"; + ot->idname = "OBJECT_OT_paths_update"; + ot->description = "Recalculate paths for selected objects"; + + /* api callbakcs */ + ot->exec = object_update_paths_exec; + ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* Clear motion paths for selected objects only */ void ED_objects_clear_paths(bContext *C) { diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ee9d776ea3b..e834c93b0d8 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -84,6 +84,7 @@ void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); 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_forcefield_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index feb7c075264..b7dc3fd7bea 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -77,6 +77,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); 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_forcefield_toggle); diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index a9801012d67..f8d942b4fd1 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -88,38 +88,50 @@ void draw_motion_path_instance(Scene *scene, //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; - int sfra, efra, len; - + int sfra, efra, sind, len; /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - int sind; - /* With "Around Current", we only choose frames from around - * the current frame to draw. However, this range is still - * restricted by the limits of the original path. + * the current frame to draw. */ sfra = CFRA - avs->path_bc; efra = CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra = mpath->start_frame; - if (efra > mpath->end_frame) efra = mpath->end_frame; - - len = efra - sfra; - - sind = sfra - mpath->start_frame; - mpv_start = (mpath->points + sind); } else { - sfra = mpath->start_frame; - efra = sfra + mpath->length; - len = mpath->length; - mpv_start = mpath->points; + /* Use the current display range */ + sfra = avs->path_sf; + efra = avs->path_ef; } - + + /* no matter what, we can only show what is in the cache and no more + * - abort if whole range is past ends of path + * - otherwise clamp endpoints to extents of path + */ + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { + /* whole path is out of bounds */ + return; + } + + if (sfra < mpath->start_frame) { + /* start clamp */ + sfra = mpath->start_frame; + } + if (efra > mpath->end_frame) { + /* end clamp */ + efra = mpath->end_frame; + } + + len = efra - sfra; + if (len <= 0) { return; } - + + /* get pointers to parts of path */ + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); + /* draw curve-line of path */ glShadeModel(GL_SMOOTH);