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; } }