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:
authorMartin Poirier <theeth@yahoo.com>2005-06-05 17:50:21 +0400
committerMartin Poirier <theeth@yahoo.com>2005-06-05 17:50:21 +0400
commitc00adc5ff8045db65fd15576b0addfd9e5c0eece (patch)
treeb7540ce13ea2da2308337c716701a7b945e81afa /source/blender/src
parent38202abff8e625b313f81abffb4b90ef53f464d9 (diff)
Transform 2D center was using short. Not good enough when it's it's way off screen. Switched to ints, that fixed the bug in the tracker.
Switching to floats would probably be safer in the long term, but too many things to test to do that now.
Diffstat (limited to 'source/blender/src')
-rwxr-xr-xsource/blender/src/transform_constraints.c8
-rwxr-xr-xsource/blender/src/transform_generics.c16
-rw-r--r--source/blender/src/view.c24
3 files changed, 36 insertions, 12 deletions
diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c
index 9f45410ab7b..063f4ed6b57 100755
--- a/source/blender/src/transform_constraints.c
+++ b/source/blender/src/transform_constraints.c
@@ -842,8 +842,8 @@ void setNearestAxis(TransInfo *t)
float zfac;
float mvec[3], axis[3], proj[3];
float len[3];
+ int i, icoord[2];
short coord[2];
- int i;
t->con.mode &= ~CON_AXIS0;
t->con.mode &= ~CON_AXIS1;
@@ -871,10 +871,10 @@ void setNearestAxis(TransInfo *t)
VecMulf(axis, zfac);
/* now we can project to get window coordinate */
VecAddf(axis, axis, t->con.center);
- project_short_noclip(axis, coord);
+ project_int(axis, icoord);
- axis[0] = (float)(coord[0] - t->center2d[0]);
- axis[1] = (float)(coord[1] - t->center2d[1]);
+ axis[0] = (float)(icoord[0] - t->center2d[0]);
+ axis[1] = (float)(icoord[1] - t->center2d[1]);
axis[2] = 0.0f;
if (Normalise(axis) != 0.0f) {
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index 2171978e336..438f7864cf3 100755
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -608,10 +608,10 @@ void calculateCenterCursor(TransInfo *t)
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
- project_short_noclip(vec, t->center2d);
+ project_int(vec, t->center2d);
}
else {
- project_short_noclip(t->center, t->center2d);
+ project_int(t->center, t->center2d);
}
}
@@ -640,10 +640,10 @@ void calculateCenterMedian(TransInfo *t)
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
- project_short_noclip(vec, t->center2d);
+ project_int(vec, t->center2d);
}
else {
- project_short_noclip(t->center, t->center2d);
+ project_int(t->center, t->center2d);
}
}
@@ -679,10 +679,10 @@ void calculateCenterBound(TransInfo *t)
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
- project_short_noclip(vec, t->center2d);
+ project_int(vec, t->center2d);
}
else {
- project_short_noclip(t->center, t->center2d);
+ project_int(t->center, t->center2d);
}
}
@@ -709,7 +709,7 @@ void calculateCenter(TransInfo *t)
Object *ob= OBACT;
if(ob) {
VECCOPY(t->center, ob->obmat[3]);
- project_short_noclip(t->center, t->center2d);
+ project_int(t->center, t->center2d);
}
}
@@ -735,7 +735,7 @@ void calculateCenter(TransInfo *t)
axis[1]= t->center[1]- 6.0f*axis[1];
axis[2]= t->center[2]- 6.0f*axis[2];
- project_short_noclip(axis, t->center2d);
+ project_int(axis, t->center2d);
/* rotate only needs correct 2d center, grab needs initgrabz() value */
if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis);
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index ce0803d24cc..9f30306d398 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -192,6 +192,30 @@ void project_short(float *vec, short *adr) /* clips */
}
}
+void project_int(float *vec, int *adr)
+{
+ float fx, fy, vec4[4];
+
+ adr[0]= 2140000000.0f;
+ VECCOPY(vec4, vec);
+ vec4[3]= 1.0;
+
+ Mat4MulVec4fl(G.vd->persmat, vec4);
+
+ if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
+ fx= (curarea->winx/2)*(1 + vec4[0]/vec4[3]);
+
+ if( fx>-2140000000.0f && fx<2140000000.0f) {
+ fy= (curarea->winy/2)*(1 + vec4[1]/vec4[3]);
+
+ if(fy>-2140000000.0f && fy<2140000000.0f) {
+ adr[0]= floor(fx);
+ adr[1]= floor(fy);
+ }
+ }
+ }
+}
+
void project_short_noclip(float *vec, short *adr)
{
float fx, fy, vec4[4];