diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-01-22 03:55:19 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-01-22 03:55:19 +0300 |
commit | e965e92fa5712c2635ee45c8cd2be953bfc68915 (patch) | |
tree | 84298df06b5af9571fa935f9a2ce97eac096818d | |
parent | 8cde671f8bd221bc29a117de09946599c343fcd8 (diff) |
Fix: Breakdowner value would jump when starting the tool a second time during a Blender session
As reported on the Blender Institute Podcast 009. See my comment on the cloud blog
for further details.
When used a second (or third, etc.) time, the breakdowner's (Shift-E) percentage value
would initially be the last-used value (e.g. 33% or 75%), before suddenly jumping
to another value as soon as the mouse moves. The cause of this behaviour was that it
was initially reusing the value from the previous time the operator was run, but then
as soon as the mouse moved, it would snap to the percentage implied by the mouse position.
(Note: The mapping from mouse position to percentage is "absolute" - i.e. the percentage
is based on how far across the 3D view the mouse is, instead of being some kind of
relative offset thing).
To make things a bit less jumpy, I've changed the behaviour so that the mouse position
always gets used immediately, instead of having it jump suddenly only when making
some mouse movement.
-rw-r--r-- | source/blender/editors/armature/pose_slide.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 40328e0c06e..16ba1483e38 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -655,6 +655,15 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p return OPERATOR_RUNNING_MODAL; } +/* calculate percentage based on position of mouse (we only use x-axis for now. + * since this is more convenient for users to do), and store new percentage value + */ +static void pose_slide_mouse_update_percentage(tPoseSlideOp *pso, wmOperator *op, const wmEvent *event) +{ + pso->percentage = (event->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); + RNA_float_set(op->ptr, "percentage", pso->percentage); +} + /* common code for modal() */ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) { @@ -702,11 +711,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) { /* only handle mousemove if not doing numinput */ if (has_numinput == false) { - /* calculate percentage based on position of mouse (we only use x-axis for now. - * since this is more convenient for users to do), and store new percentage value - */ - pso->percentage = (event->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); - RNA_float_set(op->ptr, "percentage", pso->percentage); + /* update percentage based on position of mouse */ + pose_slide_mouse_update_percentage(pso, op, event); /* update percentage indicator in header */ pose_slide_draw_status(pso); @@ -787,7 +793,7 @@ static void pose_slide_opdef_properties(wmOperatorType *ot) /* ------------------------------------ */ /* invoke() - for 'push' mode */ -static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; @@ -798,6 +804,9 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *UN } else pso = op->customdata; + + /* initialise percentage so that it won't pop on first mouse move */ + pose_slide_mouse_update_percentage(pso, op, event); /* do common setup work */ return pose_slide_invoke_common(C, op, pso); @@ -844,7 +853,7 @@ void POSE_OT_push(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'relax' mode */ -static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; @@ -856,6 +865,9 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *U else pso = op->customdata; + /* initialise percentage so that it won't pop on first mouse move */ + pose_slide_mouse_update_percentage(pso, op, event); + /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } @@ -901,7 +913,7 @@ void POSE_OT_relax(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'breakdown' mode */ -static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; @@ -913,6 +925,9 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven else pso = op->customdata; + /* initialise percentage so that it won't pop on first mouse move */ + pose_slide_mouse_update_percentage(pso, op, event); + /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } |