/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
dx = (float)(mi->center[0] - mi->precision_mval[0]);
dy = (float)(mi->center[1] - mi->precision_mval[1]);
- ratio = sqrtf(dx * dx + dy * dy);
+ ratio = hypotf(dx, dy);
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
- precise_ratio = (float)sqrt(dx * dx + dy * dy);
+ precise_ratio = hypotf(dx, dy);
ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor;
}
else {
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
- ratio = sqrtf(dx * dx + dy * dy) / mi->factor;
+ ratio = hypotf(dx, dy) / mi->factor;
}
output[0] = ratio;
}
}
+static void InputSpringDelta(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
+ InputSpring(t, mi, mval, output);
+ output[0] -= 1.0f;
+}
+
static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3])
{
output[0] = dot_v3v3(t->viewinv[1], vec) * 2.0f;
}
-void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, const int start[2], const int end[2])
+void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, const int mval_start[2], const int mval_end[2])
{
int *data;
- if (mi->data == NULL) {
- mi->data = MEM_callocN(sizeof(int) * 4, "custom points");
- }
+ mi->data = MEM_reallocN(mi->data, sizeof(int) * 4);
data = mi->data;
- data[0] = start[0];
- data[1] = start[1];
- data[2] = end[0];
- data[3] = end[1];
+ data[0] = mval_start[0];
+ data[1] = mval_start[1];
+ data[2] = mval_end[0];
+ data[3] = mval_end[1];
}
static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3])
double length;
double distance;
double dx, dy;
- int *data = mi->data;
+ const int *data = mi->data;
if (data) {
dx = data[2] - data[0];
dy = data[3] - data[1];
- length = sqrt(dx * dx + dy * dy);
+ length = hypot(dx, dy);
if (mi->precision) {
/* deal with Shift key by adding motion / 10 to motion before shift press */
double *angle = mi->data;
- /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */
+ /* use doubles here, to make sure a "1.0" (no rotation) doesn't become 9.999999e-01, which gives 0.02 for acos */
double deler = (((dx1 * dx1 + dy1 * dy1) +
(dx2 * dx2 + dy2 * dy2) -
(dx3 * dx3 + dy3 * dy3)) / (2.0 * ((A * B) ? (A * B) : 1.0)));
output[0] = *angle;
}
-void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const int center[2], const int mval[2])
+static void InputAngleSpring(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
+ float toutput[3];
+
+ InputAngle(t, mi, mval, output);
+ InputSpring(t, mi, mval, toutput);
+
+ output[1] = toutput[0];
+}
+
+void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const float center[2], const int mval[2])
{
mi->factor = 0;
mi->precision = 0;
mi->apply = InputSpringFlip;
t->helpline = HLP_SPRING;
break;
+ case INPUT_SPRING_DELTA:
+ calcSpringFactor(mi);
+ mi->apply = InputSpringDelta;
+ t->helpline = HLP_SPRING;
+ break;
case INPUT_ANGLE:
mi->data = MEM_callocN(sizeof(double), "angle accumulator");
mi->apply = InputAngle;
t->helpline = HLP_ANGLE;
break;
+ case INPUT_ANGLE_SPRING:
+ calcSpringFactor(mi);
+ mi->data = MEM_callocN(sizeof(double), "angle accumulator");
+ mi->apply = InputAngleSpring;
+ t->helpline = HLP_ANGLE;
+ break;
case INPUT_TRACKBALL:
/* factor has to become setting or so */
mi->factor = 0.01f;
}
}
-int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)
+eRedrawFlag handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event)
{
- int redraw = TREDRAW_NOTHING;
+ eRedrawFlag redraw = TREDRAW_NOTHING;
switch (event->type) {
case LEFTSHIFTKEY: