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>2008-06-05 18:49:12 +0400
committerMartin Poirier <theeth@yahoo.com>2008-06-05 18:49:12 +0400
commit172fe6ed2f963b952833f39729e1bac52b479a2f (patch)
treecd3755fd7ccdf8d3214eb647cce545f79cc78b13
parent6757b759ea29f8b59d92b2772efd2d0d1dac2c8a (diff)
Bugfix: [#13619] Transform Rotate and Scale Strange
view: noclip version of int and float projection. Also project from behind the view's position and return coherent values for near clipping transform: use the above functions for 2d center and helpline drawing NOTE: the result for centers behind the camera (in perspective) isn't 100% perfect in the case of rotations because they always use the centered view vector as rotation axis and not the one aligned with the 2d center. Changing this would not be desirable anyway. At least it's predictible now.
-rw-r--r--source/blender/include/BSE_view.h2
-rw-r--r--source/blender/src/transform.c45
-rw-r--r--source/blender/src/view.c47
3 files changed, 70 insertions, 24 deletions
diff --git a/source/blender/include/BSE_view.h b/source/blender/include/BSE_view.h
index 236f35f17c6..4b334fdd959 100644
--- a/source/blender/include/BSE_view.h
+++ b/source/blender/include/BSE_view.h
@@ -63,7 +63,9 @@ void window_to_3d(float *vec, short mx, short my);
void project_short(float *vec, short *adr);
void project_short_noclip(float *vec, short *adr);
void project_int(float *vec, int *adr);
+void project_int_noclip(float *vec, int *adr);
void project_float(float *vec, float *adr);
+void project_float_noclip(float *vec, float *adr);
int boundbox_clip(float obmat[][4], struct BoundBox *bb);
void fdrawline(float x1, float y1, float x2, float y2);
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index 10035c61651..4f6c33b0a64 100644
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -135,24 +135,23 @@ static void helpline(TransInfo *t, float *vec)
getmouseco_areawin(mval);
projectFloatView(t, vecrot, cent); // no overflow in extreme cases
- if(cent[0]!=IS_CLIPPED) {
- persp(PERSP_WIN);
-
- glDrawBuffer(GL_FRONT);
-
- BIF_ThemeColor(TH_WIRE);
-
- setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(mval);
- glVertex2fv(cent);
- glEnd();
- setlinestyle(0);
-
- persp(PERSP_VIEW);
- bglFlush(); // flush display for frontbuffer
- glDrawBuffer(GL_BACK);
- }
+
+ persp(PERSP_WIN);
+
+ glDrawBuffer(GL_FRONT);
+
+ BIF_ThemeColor(TH_WIRE);
+
+ setlinestyle(3);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(mval);
+ glVertex2fv(cent);
+ glEnd();
+ setlinestyle(0);
+
+ persp(PERSP_VIEW);
+ bglFlush(); // flush display for frontbuffer
+ glDrawBuffer(GL_BACK);
}
@@ -354,8 +353,9 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
void projectIntView(TransInfo *t, float *vec, int *adr)
{
- if (t->spacetype==SPACE_VIEW3D)
- project_int(vec, adr);
+ if (t->spacetype==SPACE_VIEW3D) {
+ project_int_noclip(vec, adr);
+ }
else if(t->spacetype==SPACE_IMAGE) {
float aspx, aspy, v[2];
@@ -376,8 +376,9 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
void projectFloatView(TransInfo *t, float *vec, float *adr)
{
- if (t->spacetype==SPACE_VIEW3D)
- project_float(vec, adr);
+ if (t->spacetype==SPACE_VIEW3D) {
+ project_float_noclip(vec, adr);
+ }
else if(t->spacetype==SPACE_IMAGE) {
int a[2];
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index 1e45f2bf3e0..f53bcb3a9f7 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -228,6 +228,29 @@ void project_int(float *vec, int *adr)
}
}
+void project_int_noclip(float *vec, int *adr)
+{
+ float fx, fy, vec4[4];
+
+ VECCOPY(vec4, vec);
+ vec4[3]= 1.0;
+
+ Mat4MulVec4fl(G.vd->persmat, vec4);
+
+ if( fabs(vec4[3]) > BL_NEAR_CLIP ) {
+ fx = (curarea->winx/2)*(1 + vec4[0]/vec4[3]);
+ fy = (curarea->winy/2)*(1 + vec4[1]/vec4[3]);
+
+ adr[0] = floor(fx);
+ adr[1] = floor(fy);
+ }
+ else
+ {
+ adr[0] = curarea->winx / 2;
+ adr[1] = curarea->winy / 2;
+ }
+}
+
void project_short_noclip(float *vec, short *adr)
{
float fx, fy, vec4[4];
@@ -264,8 +287,28 @@ void project_float(float *vec, float *adr)
Mat4MulVec4fl(G.vd->persmat, vec4);
if( vec4[3]>BL_NEAR_CLIP ) {
- adr[0]= (curarea->winx/2.0)+(curarea->winx/2.0)*vec4[0]/vec4[3];
- adr[1]= (curarea->winy/2.0)+(curarea->winy/2.0)*vec4[1]/vec4[3];
+ adr[0] = (curarea->winx/2.0)+(curarea->winx/2.0)*vec4[0]/vec4[3];
+ adr[1] = (curarea->winy/2.0)+(curarea->winy/2.0)*vec4[1]/vec4[3];
+ }
+}
+
+void project_float_noclip(float *vec, float *adr)
+{
+ float vec4[4];
+
+ VECCOPY(vec4, vec);
+ vec4[3]= 1.0;
+
+ Mat4MulVec4fl(G.vd->persmat, vec4);
+
+ if( fabs(vec4[3]) > BL_NEAR_CLIP ) {
+ adr[0] = (curarea->winx/2.0)+(curarea->winx/2.0)*vec4[0]/vec4[3];
+ adr[1] = (curarea->winy/2.0)+(curarea->winy/2.0)*vec4[1]/vec4[3];
+ }
+ else
+ {
+ adr[0] = curarea->winx / 2.0f;
+ adr[1] = curarea->winy / 2.0f;
}
}