Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/transform/transform.c60
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_input.c21
3 files changed, 63 insertions, 20 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index e4639b268de..b3944614e2f 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2064,6 +2064,16 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* ************************** WARP *************************** */
+void postInputWarp(TransInfo *t, float values[3])
+{
+ mul_v3_fl(values, (float)(M_PI * 2));
+
+ if (t->customData) /* non-null value indicates reversed input */
+ {
+ negate_v3(values);
+ }
+}
+
void initWarp(TransInfo *t)
{
float max[3], min[3];
@@ -2073,13 +2083,14 @@ void initWarp(TransInfo *t)
t->transform = Warp;
t->handleEvent = handleEventWarp;
+ setInputPostFct(&t->mouse, postInputWarp);
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = 5.0f;
- t->snap[2] = 1.0f;
+ t->snap[1] = 5.0f / 180 * M_PI;
+ t->snap[2] = 1.0f / 180 * M_PI;
t->num.increment = 1.0f;
@@ -2154,13 +2165,8 @@ int Warp(TransInfo *t, short mval[2])
mul_m4_v3(t->viewmat, cursor);
sub_v3_v3v3(cursor, cursor, t->viewmat[3]);
- /* amount of degrees for warp */
- circumfac = 360.0f * t->values[0];
-
- if (t->customData) /* non-null value indicates reversed input */
- {
- circumfac *= -1;
- }
+ /* amount of radians for warp */
+ circumfac = t->values[0];
snapGrid(t, &circumfac);
applyNumInput(&t->num, &circumfac);
@@ -2172,13 +2178,17 @@ int Warp(TransInfo *t, short mval[2])
outputNumInput(&(t->num), c);
sprintf(str, "Warp: %s", c);
+
+ circumfac = circumfac / 180 * M_PI;
}
else {
/* default header print */
- sprintf(str, "Warp: %.3f", circumfac);
+ sprintf(str, "Warp: %.3f", circumfac * 180 / M_PI);
}
- circumfac*= (float)(-M_PI/360.0);
+ t->values[0] = circumfac;
+
+ circumfac /= 2; /* only need 180 on each side to make 360 */
for(i = 0; i < t->total; i++, td++) {
float loc[3];
@@ -2225,12 +2235,18 @@ int Warp(TransInfo *t, short mval[2])
/* ************************** SHEAR *************************** */
+void postInputShear(TransInfo *t, float values[3])
+{
+ mul_v3_fl(values, 0.05f);
+}
+
void initShear(TransInfo *t)
{
t->mode = TFM_SHEAR;
t->transform = Shear;
t->handleEvent = handleEventShear;
+ setInputPostFct(&t->mouse, postInputShear);
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->idx_max = 0;
@@ -2281,7 +2297,7 @@ int Shear(TransInfo *t, short mval[2])
copy_m3_m4(persmat, t->viewmat);
invert_m3_m3(persinv, persmat);
- value = 0.05f * t->values[0];
+ value = t->values[0];
snapGrid(t, &value);
@@ -2652,6 +2668,8 @@ int ToSphere(TransInfo *t, short mval[2])
else if (ratio > 1)
ratio = 1.0f;
+ t->values[0] = ratio;
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
@@ -2696,11 +2714,19 @@ int ToSphere(TransInfo *t, short mval[2])
/* ************************** ROTATION *************************** */
+void postInputRotation(TransInfo *t, float values[3])
+{
+ if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
+ t->con.applyRot(t, NULL, t->axis, values);
+ }
+}
+
void initRotation(TransInfo *t)
{
t->mode = TFM_ROTATION;
t->transform = Rotation;
+ setInputPostFct(&t->mouse, postInputRotation);
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
t->ndof.axis = 16;
@@ -2973,7 +2999,7 @@ int Rotation(TransInfo *t, short mval[2])
snapGrid(t, &final);
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
- t->con.applyRot(t, NULL, t->axis, &final);
+ t->con.applyRot(t, NULL, t->axis, NULL);
} else {
/* reset axis if constraint is not set */
negate_v3_v3(t->axis, t->viewinv[2]);
@@ -3004,15 +3030,10 @@ int Rotation(TransInfo *t, short mval[2])
sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext);
}
- // fixes [#21433] but breaks, typical local axis rotation - campbell
- // t->values[0] = final;
+ t->values[0] = final;
vec_rot_to_mat3( mat, t->axis, final);
- // TRANSFORM_FIX_ME
-// t->values[0] = final; // used in manipulator
-// copy_m3_m3(t->mat, mat); // used in manipulator
-
applyRotation(t, final, t->axis);
recalcData(t);
@@ -5521,6 +5542,7 @@ int TimeSlide(TransInfo *t, short mval[2])
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
/* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */
+ // XXX Need to be able to repeat this
t->values[0] = cval[0];
/* handle numeric-input stuff */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 6a0c51da370..4f2a3960491 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -234,6 +234,7 @@ typedef struct TransData {
typedef struct MouseInput {
void (*apply)(struct TransInfo *, struct MouseInput *, short [2], float [3]);
+ void (*post)(struct TransInfo *, float [3]);
short imval[2]; /* initial mouse position */
char precision;
@@ -632,6 +633,7 @@ int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent
void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, short mval[2], float output[3]);
void setCustomPoints(TransInfo *t, MouseInput *mi, short start[2], short end[2]);
+void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]));
/*********************** Generics ********************************/
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 0e4521052ad..d4110eedee0 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -225,6 +225,8 @@ void InputAngle(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
double dx3 = mval[0] - mi->imval[0];
double dy3 = mval[1] - mi->imval[1];
+ 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 */
double deler = ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3))
/ (2.0 * (A*B?A*B:1.0));
@@ -266,7 +268,11 @@ void InputAngle(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
mi->imval[1] = mval[1];
}
- output[0] += dphi;
+ *angle += dphi;
+
+ printf("angle %.3f\n", *angle);
+
+ output[0] = *angle;
}
void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], short mval[2])
@@ -279,6 +285,8 @@ void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], short mval[2])
mi->imval[0] = mval[0];
mi->imval[1] = mval[1];
+
+ mi->post = NULL;
}
static void calcSpringFactor(MouseInput *mi)
@@ -314,6 +322,7 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
t->helpline = HLP_SPRING;
break;
case INPUT_ANGLE:
+ mi->data = MEM_callocN(sizeof(double), "angle accumulator");
mi->apply = InputAngle;
t->helpline = HLP_ANGLE;
break;
@@ -354,12 +363,22 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
applyMouseInput(t, mi, mi->imval, t->values);
}
+void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]))
+{
+ mi->post = post;
+}
+
void applyMouseInput(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
{
if (mi->apply != NULL)
{
mi->apply(t, mi, mval, output);
}
+
+ if (mi->post)
+ {
+ mi->post(t, output);
+ }
}
int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)