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:
authorJoseph Eagar <joeedh@gmail.com>2011-05-09 03:43:18 +0400
committerJoseph Eagar <joeedh@gmail.com>2011-05-09 03:43:18 +0400
commit6ef77cf95accc3cb914e7efd964118ce6e9521cf (patch)
tree1d8dbf95355038c93f79f9053a0bf1d55b561ec3 /source/blender/editors/transform
parent3462ddf17f38eb61fc3bb2751d55de15a47455c3 (diff)
parent770119d16f7dbee99a60d19540818892c970c4e2 (diff)
=bmesh= merge from trunk at r36529
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c104
-rw-r--r--source/blender/editors/transform/transform.h54
-rw-r--r--source/blender/editors/transform/transform_constraints.c50
-rw-r--r--source/blender/editors/transform/transform_conversions.c10
-rw-r--r--source/blender/editors/transform/transform_generics.c29
-rw-r--r--source/blender/editors/transform/transform_input.c24
-rw-r--r--source/blender/editors/transform/transform_manipulator.c2
-rw-r--r--source/blender/editors/transform/transform_snap.c2
8 files changed, 177 insertions, 98 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index d0d328eb48e..fd2bb59294b 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -196,15 +196,18 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
}
else if(t->spacetype == SPACE_ACTION) {
- SpaceAction *sact = t->sa->spacedata.first;
int out[2] = {0, 0};
+#if 0
+ SpaceAction *sact = t->sa->spacedata.first;
if (sact->flag & SACTION_DRAWTIME) {
//vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base));
-
+ /* same as below */
UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
}
- else {
+ else
+#endif
+ {
UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1);
}
@@ -2289,7 +2292,7 @@ int handleEventWarp(TransInfo *t, wmEvent *event)
return status;
}
-int Warp(TransInfo *t, short UNUSED(mval[2]))
+int Warp(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
@@ -2437,7 +2440,7 @@ int handleEventShear(TransInfo *t, wmEvent *event)
}
-int Shear(TransInfo *t, short UNUSED(mval[2]))
+int Shear(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float vec[3];
@@ -2703,7 +2706,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
constraintTransLim(t, td);
}
-int Resize(TransInfo *t, short mval[2])
+int Resize(TransInfo *t, const short mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -2808,7 +2811,7 @@ void initToSphere(TransInfo *t)
t->val /= (float)t->total;
}
-int ToSphere(TransInfo *t, short UNUSED(mval[2]))
+int ToSphere(TransInfo *t, const short UNUSED(mval[2]))
{
float vec[3];
float ratio, radius;
@@ -3155,9 +3158,9 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
}
}
-int Rotation(TransInfo *t, short UNUSED(mval[2]))
+int Rotation(TransInfo *t, const short UNUSED(mval[2]))
{
- char str[128];
+ char str[128], *spos= str;
float final;
@@ -3183,18 +3186,20 @@ int Rotation(TransInfo *t, short UNUSED(mval[2]))
outputNumInput(&(t->num), c);
- sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
+ spos+= sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext);
/* Clamp between -180 and 180 */
final= angle_wrap_rad(DEG2RADF(final));
}
else {
- sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext);
+ spos += sprintf(spos, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED))
- sprintf(str, "%s Proportional size: %.2f", str, t->prop_size);
-
+ if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
+ }
+ (void)spos;
+
t->values[0] = final;
applyRotation(t, final, t->axis);
@@ -3261,9 +3266,9 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
}
}
-int Trackball(TransInfo *t, short UNUSED(mval[2]))
+int Trackball(TransInfo *t, const short UNUSED(mval[2]))
{
- char str[128];
+ char str[128], *spos= str;
float axis1[3], axis2[3];
float mat[3][3], totmat[3][3], smat[3][3];
float phi[2];
@@ -3287,15 +3292,20 @@ int Trackball(TransInfo *t, short UNUSED(mval[2]))
outputNumInput(&(t->num), c);
- sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
+ spos += sprintf(spos, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
phi[0] = DEG2RADF(phi[0]);
phi[1] = DEG2RADF(phi[1]);
}
else {
- sprintf(str, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext);
+ spos += sprintf(spos, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext);
}
+ if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
+ }
+ (void)spos;
+
vec_rot_to_mat3( smat,axis1, phi[0]);
vec_rot_to_mat3( totmat,axis2, phi[1]);
@@ -3351,6 +3361,7 @@ void initTranslation(TransInfo *t)
}
static void headerTranslation(TransInfo *t, float vec[3], char *str) {
+ char *spos= str;
char tvec[60];
char distvec[20];
char autoik[20];
@@ -3401,24 +3412,26 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
if (t->con.mode & CON_APPLY) {
switch(t->num.idx_max) {
case 0:
- sprintf(str, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
break;
case 1:
- sprintf(str, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
break;
case 2:
- sprintf(str, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
}
}
else {
if(t->flag & T_2D_EDIT)
- sprintf(str, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext);
+ spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext);
else
- sprintf(str, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
}
- if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED))
- sprintf(str, "%s Proportional size: %.2f", str, t->prop_size);
+ if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ spos += sprintf(spos, " Proportional size: %.2f", t->prop_size);
+ }
+ (void)spos;
}
static void applyTranslation(TransInfo *t, float vec[3]) {
@@ -3484,7 +3497,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
}
/* uses t->vec to store actual translation in */
-int Translation(TransInfo *t, short UNUSED(mval[2]))
+int Translation(TransInfo *t, const short UNUSED(mval[2]))
{
char str[250];
@@ -3551,7 +3564,7 @@ void initShrinkFatten(TransInfo *t)
-int ShrinkFatten(TransInfo *t, short UNUSED(mval[2]))
+int ShrinkFatten(TransInfo *t, const short UNUSED(mval[2]))
{
float vec[3];
float distance;
@@ -3626,7 +3639,7 @@ void initTilt(TransInfo *t)
-int Tilt(TransInfo *t, short UNUSED(mval[2]))
+int Tilt(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
int i;
@@ -3698,7 +3711,7 @@ void initCurveShrinkFatten(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int CurveShrinkFatten(TransInfo *t, short UNUSED(mval[2]))
+int CurveShrinkFatten(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float ratio;
@@ -3766,7 +3779,7 @@ void initPushPull(TransInfo *t)
}
-int PushPull(TransInfo *t, short UNUSED(mval[2]))
+int PushPull(TransInfo *t, const short UNUSED(mval[2]))
{
float vec[3], axis[3];
float distance;
@@ -3899,7 +3912,7 @@ int handleEventBevel(TransInfo *t, wmEvent *event)
return 0;
}
-int Bevel(TransInfo *t, short UNUSED(mval[2]))
+int Bevel(TransInfo *t, const short UNUSED(mval[2]))
{
float distance,d;
int i;
@@ -3967,7 +3980,7 @@ void initBevelWeight(TransInfo *t)
t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
}
-int BevelWeight(TransInfo *t, short UNUSED(mval[2]))
+int BevelWeight(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float weight;
@@ -4040,7 +4053,7 @@ void initCrease(TransInfo *t)
t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
}
-int Crease(TransInfo *t, short UNUSED(mval[2]))
+int Crease(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float crease;
@@ -4108,6 +4121,7 @@ void initBoneSize(TransInfo *t)
t->idx_max = 2;
t->num.idx_max = 2;
t->num.flag |= NUM_NULL_ONE;
+ t->num.flag |= NUM_AFFECT_ALL;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
@@ -4158,7 +4172,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
td->loc[1]= oldy;
}
-int BoneSize(TransInfo *t, short mval[2])
+int BoneSize(TransInfo *t, const short mval[2])
{
TransData *td = t->data;
float size[3], mat[3][3];
@@ -4234,7 +4248,7 @@ void initBoneEnvelope(TransInfo *t)
t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
}
-int BoneEnvelope(TransInfo *t, short UNUSED(mval[2]))
+int BoneEnvelope(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float ratio;
@@ -4840,7 +4854,7 @@ int doEdgeSlide(TransInfo *t, float perc)
return 1;
}
-int EdgeSlide(TransInfo *t, short UNUSED(mval[2]))
+int EdgeSlide(TransInfo *t, const short UNUSED(mval[2]))
{
char str[50];
float final;
@@ -4899,7 +4913,7 @@ void initBoneRoll(TransInfo *t)
t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT;
}
-int BoneRoll(TransInfo *t, short UNUSED(mval[2]))
+int BoneRoll(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
int i;
@@ -4960,7 +4974,7 @@ void initBakeTime(TransInfo *t)
t->num.increment = t->snap[1];
}
-int BakeTime(TransInfo *t, short mval[2])
+int BakeTime(TransInfo *t, const short mval[2])
{
TransData *td = t->data;
float time;
@@ -5035,7 +5049,7 @@ void initMirror(TransInfo *t)
}
}
-int Mirror(TransInfo *t, short UNUSED(mval[2]))
+int Mirror(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td;
float size[3], mat[3][3];
@@ -5112,7 +5126,7 @@ void initAlign(TransInfo *t)
initMouseInputMode(t, &t->mouse, INPUT_NONE);
}
-int Align(TransInfo *t, short UNUSED(mval[2]))
+int Align(TransInfo *t, const short UNUSED(mval[2]))
{
TransData *td = t->data;
float center[3];
@@ -5215,7 +5229,7 @@ static void applySeqSlide(TransInfo *t, float val[2]) {
}
}
-int SeqSlide(TransInfo *t, short UNUSED(mval[2]))
+int SeqSlide(TransInfo *t, const short UNUSED(mval[2]))
{
char str[200];
@@ -5331,7 +5345,7 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
/* snap key to nearest frame? */
if (autosnap == SACTSNAP_FRAME) {
const Scene *scene= t->scene;
- const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t);
+ const short doTime= 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behaviour given the option's label, hence disabled
const double secf= FPS;
double val;
@@ -5505,7 +5519,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
}
}
-int TimeTranslate(TransInfo *t, short mval[2])
+int TimeTranslate(TransInfo *t, const short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
@@ -5635,7 +5649,7 @@ static void applyTimeSlide(TransInfo *t, float sval)
}
}
-int TimeSlide(TransInfo *t, short mval[2])
+int TimeSlide(TransInfo *t, const short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
@@ -5760,7 +5774,7 @@ static void applyTimeScale(TransInfo *t) {
}
}
-int TimeScale(TransInfo *t, short UNUSED(mval[2]))
+int TimeScale(TransInfo *t, const short UNUSED(mval[2]))
{
char str[200];
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 76569a86e11..380633fe874 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -254,7 +254,7 @@ typedef struct TransData {
} TransData;
typedef struct MouseInput {
- void (*apply)(struct TransInfo *, struct MouseInput *, short [2], float [3]);
+ void (*apply)(struct TransInfo *, struct MouseInput *, const short [2], float [3]);
void (*post)(struct TransInfo *, float [3]);
short imval[2]; /* initial mouse position */
@@ -273,7 +273,7 @@ typedef struct TransInfo {
int options; /* current context/options for transform */
float val; /* init value for some transformations (and rotation angle) */
float fac; /* factor for distance based transform */
- int (*transform)(struct TransInfo *, short *);
+ int (*transform)(struct TransInfo *, const short *);
/* transform function pointer */
int (*handleEvent)(struct TransInfo *, struct wmEvent *);
/* event handler function pointer RETURN 1 if redraw is needed */
@@ -479,81 +479,81 @@ void removeAspectRatio(TransInfo *t, float *vec);
void initWarp(TransInfo *t);
int handleEventWarp(TransInfo *t, struct wmEvent *event);
-int Warp(TransInfo *t, short mval[2]);
+int Warp(TransInfo *t, const short mval[2]);
void initShear(TransInfo *t);
int handleEventShear(TransInfo *t, struct wmEvent *event);
-int Shear(TransInfo *t, short mval[2]);
+int Shear(TransInfo *t, const short mval[2]);
void initResize(TransInfo *t);
-int Resize(TransInfo *t, short mval[2]);
+int Resize(TransInfo *t, const short mval[2]);
void initTranslation(TransInfo *t);
-int Translation(TransInfo *t, short mval[2]);
+int Translation(TransInfo *t, const short mval[2]);
void initToSphere(TransInfo *t);
-int ToSphere(TransInfo *t, short mval[2]);
+int ToSphere(TransInfo *t, const short mval[2]);
void initRotation(TransInfo *t);
-int Rotation(TransInfo *t, short mval[2]);
+int Rotation(TransInfo *t, const short mval[2]);
void initShrinkFatten(TransInfo *t);
-int ShrinkFatten(TransInfo *t, short mval[2]);
+int ShrinkFatten(TransInfo *t, const short mval[2]);
void initTilt(TransInfo *t);
-int Tilt(TransInfo *t, short mval[2]);
+int Tilt(TransInfo *t, const short mval[2]);
void initCurveShrinkFatten(TransInfo *t);
-int CurveShrinkFatten(TransInfo *t, short mval[2]);
+int CurveShrinkFatten(TransInfo *t, const short mval[2]);
void initTrackball(TransInfo *t);
-int Trackball(TransInfo *t, short mval[2]);
+int Trackball(TransInfo *t, const short mval[2]);
void initPushPull(TransInfo *t);
-int PushPull(TransInfo *t, short mval[2]);
+int PushPull(TransInfo *t, const short mval[2]);
void initBevel(TransInfo *t);
int handleEventBevel(TransInfo *t, struct wmEvent *event);
-int Bevel(TransInfo *t, short mval[2]);
+int Bevel(TransInfo *t, const short mval[2]);
void initBevelWeight(TransInfo *t);
-int BevelWeight(TransInfo *t, short mval[2]);
+int BevelWeight(TransInfo *t, const short mval[2]);
void initCrease(TransInfo *t);
-int Crease(TransInfo *t, short mval[2]);
+int Crease(TransInfo *t, const short mval[2]);
void initBoneSize(TransInfo *t);
-int BoneSize(TransInfo *t, short mval[2]);
+int BoneSize(TransInfo *t, const short mval[2]);
void initBoneEnvelope(TransInfo *t);
-int BoneEnvelope(TransInfo *t, short mval[2]);
+int BoneEnvelope(TransInfo *t, const short mval[2]);
void initBoneRoll(TransInfo *t);
-int BoneRoll(TransInfo *t, short mval[2]);
+int BoneRoll(TransInfo *t, const short mval[2]);
void initEdgeSlide(TransInfo *t);
-int EdgeSlide(TransInfo *t, short mval[2]);
+int EdgeSlide(TransInfo *t, const short mval[2]);
void initTimeTranslate(TransInfo *t);
-int TimeTranslate(TransInfo *t, short mval[2]);
+int TimeTranslate(TransInfo *t, const short mval[2]);
void initTimeSlide(TransInfo *t);
-int TimeSlide(TransInfo *t, short mval[2]);
+int TimeSlide(TransInfo *t, const short mval[2]);
void initTimeScale(TransInfo *t);
-int TimeScale(TransInfo *t, short mval[2]);
+int TimeScale(TransInfo *t, const short mval[2]);
void initBakeTime(TransInfo *t);
-int BakeTime(TransInfo *t, short mval[2]);
+int BakeTime(TransInfo *t, const short mval[2]);
void initMirror(TransInfo *t);
-int Mirror(TransInfo *t, short mval[2]);
+int Mirror(TransInfo *t, const short mval[2]);
void initAlign(TransInfo *t);
-int Align(TransInfo *t, short mval[2]);
+int Align(TransInfo *t, const short mval[2]);
void initSeqSlide(TransInfo *t);
-int SeqSlide(TransInfo *t, short mval[2]);
+int SeqSlide(TransInfo *t, const short mval[2]);
void drawPropCircle(const struct bContext *C, TransInfo *t);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 0ef8633e6e3..fe20bd74ce7 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -185,12 +185,44 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
mul_m3_v3(t->con.mtx, vec);
}
+static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
+{
+ if(t->spacetype == SPACE_VIEW3D) {
+ // View3D *v3d = t->sa->spacedata.first;
+ const float min_dist= 1.0f; // v3d->near;
+ float dir[3];
+ float l;
+
+ sub_v3_v3v3(dir, t_con_center, t->viewinv[3]);
+ if(dot_v3v3(dir, t->viewinv[2]) < 0.0f) {
+ negate_v3(dir);
+ }
+ project_v3_v3v3(dir, dir, t->viewinv[2]);
+
+ l= len_v3(dir);
+
+ if(l < min_dist) {
+ float diff[3];
+ normalize_v3_v3(diff, t->viewinv[2]);
+ mul_v3_fl(diff, min_dist - l);
+
+ sub_v3_v3(t_con_center, diff);
+ }
+ }
+}
+
static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
float norm[3], vec[3], factor, angle;
+ float t_con_center[3];
if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
return;
+ copy_v3_v3(t_con_center, t->con.center);
+
+ /* checks for center being too close to the view center */
+ viewAxisCorrectCenter(t, t_con_center);
+
angle = fabsf(angle_v3v3(axis, t->viewinv[2]));
if (angle > (float)M_PI / 2.0f) {
angle = (float)M_PI - angle;
@@ -217,13 +249,13 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
float norm_center[3];
float plane[3];
- getViewVector(t, t->con.center, norm_center);
+ getViewVector(t, t_con_center, norm_center);
cross_v3_v3v3(plane, norm_center, axis);
project_v3_v3v3(vec, in, plane);
sub_v3_v3v3(vec, in, vec);
- add_v3_v3v3(v, vec, t->con.center);
+ add_v3_v3v3(v, vec, t_con_center);
getViewVector(t, v, norm);
/* give arbitrary large value if projection is impossible */
@@ -236,14 +268,20 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
mul_v3_fl(out, -1000000000.0f);
}
} else {
- add_v3_v3v3(v2, t->con.center, axis);
+ add_v3_v3v3(v2, t_con_center, axis);
add_v3_v3v3(v4, v, norm);
- isect_line_line_v3(t->con.center, v2, v, v4, i1, i2);
+ isect_line_line_v3(t_con_center, v2, v, v4, i1, i2);
sub_v3_v3v3(v, i2, v);
- sub_v3_v3v3(out, i1, t->con.center);
+ sub_v3_v3v3(out, i1, t_con_center);
+
+ /* possible some values become nan when
+ * viewpoint and object are both zero */
+ if(!finite(out[0])) out[0]= 0.0f;
+ if(!finite(out[1])) out[1]= 0.0f;
+ if(!finite(out[2])) out[2]= 0.0f;
}
}
}
@@ -870,7 +908,7 @@ static void setNearestAxis3d(TransInfo *t)
axis[1] = (float)(icoord[1] - t->center2d[1]);
axis[2] = 0.0f;
- if (normalize_v3(axis) != 0.0f) {
+ if (normalize_v3(axis) != 0.0f) {
project_v3_v3v3(proj, mvec, axis);
sub_v3_v3v3(axis, mvec, proj);
len[i] = normalize_v3(axis);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 25a3498403b..54f3b703784 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -3882,7 +3882,7 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
}
}
#endif
-
+
/* for extend we need to do some tricks */
if (t->mode == TFM_TIME_EXTEND) {
@@ -4948,10 +4948,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
*/
if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) {
if (t->mode == TFM_TIME_TRANSLATE) {
- if (ELEM(t->frame_side, 'L', 'R')) /* TFM_TIME_EXTEND */
+#if 0
+ if (ELEM(t->frame_side, 'L', 'R')) { /* TFM_TIME_EXTEND */
+ /* same as below */
ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
+ }
else /* TFM_TIME_TRANSLATE */
+#endif
+ {
ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
+ }
}
else if (t->mode == TFM_TIME_SCALE) {
ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index efff37c74ea..9a19f1f3205 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -967,7 +967,22 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->options |= CTX_EDGE;
}
- t->spacetype = sa ? sa->spacetype : SPACE_EMPTY; /* background mode */
+
+ /* Assign the space type, some exceptions for running in different mode */
+ if(sa == NULL) {
+ /* background mode */
+ t->spacetype= SPACE_EMPTY;
+ }
+ else if ((ar == NULL) && (sa->spacetype == SPACE_VIEW3D)) {
+ /* running in the text editor */
+ t->spacetype= SPACE_EMPTY;
+ }
+ else {
+ /* normal operation */
+ t->spacetype= sa->spacetype;
+ }
+
+
if(t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = sa->spacedata.first;
@@ -1006,12 +1021,18 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
}
}
- else if(t->spacetype==SPACE_IMAGE || t->spacetype==SPACE_NODE)
+ else if(t->spacetype==SPACE_IMAGE)
{
SpaceImage *sima = sa->spacedata.first;
- // XXX for now, get View2D from the active region
+ // XXX for now, get View2D from the active region
+ t->view = &ar->v2d;
+ t->around = sima->around;
+ }
+ else if(t->spacetype==SPACE_NODE)
+ {
+ // XXX for now, get View2D from the active region
t->view = &ar->v2d;
- t->around = (sima ? sima->around : 0);
+ t->around = V3D_CENTER;
}
else if(t->spacetype==SPACE_IPO)
{
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 45ed983fce5..b6c4deffe0a 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -43,7 +43,7 @@
/* ************************** INPUT FROM MOUSE *************************** */
-static void InputVector(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
+static void InputVector(TransInfo *t, MouseInput *mi, const short mval[2], float output[3])
{
float vec[3], dvec[3];
if(mi->precision)
@@ -61,7 +61,7 @@ static void InputVector(TransInfo *t, MouseInput *mi, short mval[2], float outpu
}
-static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3])
+static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3])
{
float ratio, precise_ratio, dx, dy;
if(mi->precision)
@@ -87,7 +87,7 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], flo
output[0] = ratio;
}
-static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
+static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], float output[3])
{
InputSpring(t, mi, mval, output);
@@ -100,7 +100,7 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float o
}
}
-static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3])
+static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3])
{
if(mi->precision)
@@ -118,7 +118,7 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, short mval[2],
output[1] *= mi->factor;
}
-static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) {
+static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) {
float x, pad;
pad = t->ar->winx / 10;
@@ -135,7 +135,7 @@ static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, short mval[2], fl
output[0] = (x - pad) / (t->ar->winx - 2 * pad);
}
-static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) {
+static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) {
float vec[3];
InputVector(t, mi, mval, vec);
@@ -144,7 +144,7 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, short mval[2],
output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f;
}
-static void InputVerticalRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) {
+static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) {
float y, pad;
pad = t->ar->winy / 10;
@@ -160,7 +160,7 @@ static void InputVerticalRatio(TransInfo *t, MouseInput *mi, short mval[2], floa
output[0] = (y - pad) / (t->ar->winy - 2 * pad);
}
-static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) {
+static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) {
float vec[3];
InputVector(t, mi, mval, vec);
@@ -185,7 +185,7 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short
data[3] = end[1];
}
-static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3])
+static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3])
{
float length;
float distance;
@@ -218,7 +218,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, short mval[2]
}
}
-static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3])
+static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3])
{
double dx2 = mval[0] - mi->center[0];
double dy2 = mval[1] - mi->center[1];
@@ -235,8 +235,8 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], floa
/* 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));
- /* (A*B?A*B:1.0f) this takes care of potential divide by zero errors */
+ / (2.0 * ((A*B)?(A*B):1.0));
+ /* ((A*B)?(A*B):1.0) this takes care of potential divide by zero errors */
float dphi;
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 607fd59e0ec..8cd6785b6c4 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1490,7 +1490,7 @@ void BIF_draw_manipulator(const bContext *C)
}
}
-static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float hotspot)
+static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const short mval[2], float hotspot)
{
View3D *v3d= sa->spacedata.first;
RegionView3D *rv3d= ar->regiondata;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 16c2856ff8b..c9927aef262 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1688,7 +1688,7 @@ static void removeDoublesPeel(ListBase *depth_peels)
{
DepthPeel *next_peel = peel->next;
- if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f)
+ if (next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f)
{
peel->next = next_peel->next;