diff options
author | Ton Roosendaal <ton@blender.org> | 2003-10-16 13:39:19 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-10-16 13:39:19 +0400 |
commit | 5d1438ad96c9d819f815f97ed5bed7de5d48e8d9 (patch) | |
tree | 1f1c237cb0624dd1ba5f6159ddde01d9c259a571 /source/blender | |
parent | c7618783fbfd7636adbd8df14ddc0feb563fa58e (diff) |
- fixed editing vertices again!
I had to clean up very old calls to switch matrices for 3d windows.
To make it more clear, I've introduced defines for the infamous persp()
function:
persp(PERSP_WIN); sets matrices at pixel level window
persp(PERSP_VIEW); restores matrices back to 3d drawing
persp(PERSP_STORE); only called once, to store correct matrices
I will now check on frontbuffer drawing of vertices... it's very doubtful
if it's used still correctly, was only meant for visual speed in the
early nineties you know. :)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/include/BSE_view.h | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 4 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 6 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 9 | ||||
-rw-r--r-- | source/blender/src/edit.c | 16 | ||||
-rw-r--r-- | source/blender/src/editcurve.c | 4 | ||||
-rw-r--r-- | source/blender/src/editmesh.c | 8 | ||||
-rw-r--r-- | source/blender/src/editview.c | 5 | ||||
-rw-r--r-- | source/blender/src/view.c | 36 |
9 files changed, 48 insertions, 46 deletions
diff --git a/source/blender/include/BSE_view.h b/source/blender/include/BSE_view.h index f46de2ba3ff..49a41e26ab1 100644 --- a/source/blender/include/BSE_view.h +++ b/source/blender/include/BSE_view.h @@ -39,9 +39,13 @@ struct BoundBox; struct View3D; struct ScrArea; -void persp3d(struct View3D *v3d, int a); +#define PERSP_WIN 0 +#define PERSP_VIEW 1 +#define PERSP_STORE 2 + void persp_general(int a); void persp(int a); + void initgrabz(float x, float y, float z); void window_to_3d(float *vec, short mx, short my); void project_short(float *vec, short *adr); diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index cf19e79f3a3..fbba5d674dd 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -71,6 +71,10 @@ typedef struct View3D { float viewinv[4][4]; float persmat[4][4]; float persinv[4][4]; + + float winmat1[4][4]; // persp(1) storage, for swap matrices + float viewmat1[4][4]; + float viewquat[4], dist; /** diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 03e63a6a4b1..4313ae52274 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -258,7 +258,7 @@ void helpline(float *vec) getmouseco_areawin(mval); project_short_noclip(vecrot, mval1); - persp(0); + persp(PERSP_WIN); glDrawBuffer(GL_FRONT); @@ -271,7 +271,7 @@ void helpline(float *vec) glEnd(); setlinestyle(0); - persp(1); + persp(PERSP_VIEW); glFinish(); // flush display for frontbuffer glDrawBuffer(GL_BACK); } @@ -944,6 +944,8 @@ void calc_meshverts_ext(void) { areawinset(curarea->win); + persp(PERSP_VIEW); + mymultmatrix(G.obedit->obmat); calc_meshverts(); myloadmatrix(G.vd->viewmat); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 8043a09b5af..b5113ab7e02 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -446,7 +446,7 @@ static void drawgrid(void) } } - persp(0); + persp(PERSP_WIN); cpack(0x606060); @@ -480,7 +480,7 @@ static void drawgrid(void) fdrawline(x, 0.0, x, (float)curarea->winy); - persp(1); + persp(PERSP_VIEW); setlinestyle(0); } @@ -1081,7 +1081,6 @@ void drawview3dspace(ScrArea *sa, void *spacedata) Object *ob; setwinmatrixview3d(0); /* 0= no pick rect */ - setviewmatrixview3d(); Mat4MulMat4(G.vd->persmat, G.vd->viewmat, curarea->winmat); @@ -1107,6 +1106,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } myloadmatrix(G.vd->viewmat); + persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls if(G.vd->view==0 || G.vd->persp!=0) { drawfloor(); @@ -1260,7 +1260,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) glDisable(GL_DEPTH_TEST); } - persp(0); + persp(PERSP_WIN); // set ortho if(G.vd->persp>1) drawviewborder(); drawcursor(); @@ -1276,6 +1276,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) bwin_scalematrix(sa->win, G.vd->blockscale, G.vd->blockscale, G.vd->blockscale); view3d_blockhandlers(sa); + curarea->win_swap= WIN_BACK_OK; if(G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index ac3ea078c32..81dedcf0aeb 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -138,7 +138,7 @@ int get_border(rcti *rect, short col) mywinset(curarea->win); glDrawBuffer(GL_FRONT); - persp(0); + persp(PERSP_WIN); initgrabz(0.0, 0.0, 0.0); getmouseco_areawin(mvalo); @@ -150,9 +150,9 @@ int get_border(rcti *rect, short col) while(TRUE) { /* for when a renderwindow is open, and a mouse cursor activates it */ - persp(1); + persp(PERSP_VIEW); mywinset(curarea->win); - persp(0); + persp(PERSP_WIN); /* selection loop while mouse pressed */ getmouseco_areawin(mval); @@ -218,9 +218,9 @@ int get_border(rcti *rect, short col) event= extern_qread(&val); /* still because of the renderwindow... */ - persp(1); + persp(PERSP_VIEW); mywinset(curarea->win); - persp(0); + persp(PERSP_WIN); if(val==0) { if(event==ESCKEY) { @@ -307,7 +307,7 @@ int get_border(rcti *rect, short col) glReadBuffer(GL_BACK); glDrawBuffer(GL_BACK); - persp(1); + persp(PERSP_VIEW); /* pressed B again ? -> brush select */ if(event==BKEY) { @@ -335,7 +335,7 @@ void draw_sel_circle(short *mval, short *mvalo, float rad, float rado, int selec return; } - persp(0); + persp(PERSP_WIN); glDrawBuffer(GL_FRONT); /* draw circle */ @@ -349,7 +349,7 @@ void draw_sel_circle(short *mval, short *mvalo, float rad, float rado, int selec } glFlush(); - persp(1); + persp(PERSP_VIEW); glDrawBuffer(GL_BACK); no_mvalo= 0; diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index 476901586c6..467f550e198 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -191,7 +191,7 @@ static void printweightsNurb(void) if(G.obedit==0) return; - persp(0); + persp(PERSP_WIN); glDrawBuffer(GL_FRONT); @@ -224,7 +224,7 @@ static void printweightsNurb(void) } glDrawBuffer(GL_BACK); - persp(1); + persp(PERSP_VIEW); } #endif diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c index 9ea3fe6fa1d..c1c937875ae 100644 --- a/source/blender/src/editmesh.c +++ b/source/blender/src/editmesh.c @@ -6623,7 +6623,9 @@ CutCurve *get_mouse_trail(int *len){ } mywinset(curarea->win); glDrawBuffer(GL_FRONT); - persp(0); + + persp(PERSP_WIN); + event=extern_qread(&val); while((event != RETKEY ) && (event != RIGHTMOUSE) ){ event=extern_qread(&val); /* Enter or RMB indicates finish */ @@ -6708,8 +6710,12 @@ CutCurve *get_mouse_trail(int *len){ for(j=1;j<i;j++) { sdrawXORline(curve[j-1].x, curve[j-1].y, curve[j].x, curve[j].y ); } + glFlush(); + persp(PERSP_VIEW); + *len=i; + return(curve); } diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 8f21df450bd..81813f7f837 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -674,7 +674,7 @@ void borderselect(void) calc_meshverts_ext(); /* drawobject.c */ eve= G.edve.first; - while(eve) { + while(eve) { if(eve->h==0 && eve->xs>rect.xmin && eve->xs<rect.xmax) { if(eve->ys>rect.ymin && eve->ys<rect.ymax) { if(val==LEFTMOUSE) eve->f|= 1; @@ -683,8 +683,7 @@ void borderselect(void) } eve= eve->next; } - if(val!=LEFTMOUSE) tekenvertices_ext(0); - tekenvertices_ext(1); + allqueue(REDRAWVIEW3D, 0); } else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { diff --git a/source/blender/src/view.c b/source/blender/src/view.c index 8025d7663e3..0d4550d8d84 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -84,25 +84,6 @@ #define TRACKBALLSIZE (1.1) -void persp3d(View3D *v3d, int a) -{ - ScrArea *area= v3d->area; - - /* only 3D windows */ - if(a== 0) { - bwin_get_winmatrix(area->win, area->winmat); - glMatrixMode(GL_MODELVIEW); - bwin_ortho2(area->win, -0.5, (float)(area->winx)-.05, -0.5, (float)(area->winy)-0.5); - glLoadIdentity(); - } - else if(a== 1) { - glMatrixMode(GL_PROJECTION); - bwin_load_winmatrix(area->win, area->winmat); - glMatrixMode(GL_MODELVIEW); - bwin_load_viewmatrix(area->win, v3d->viewmat); - } -} - void persp_general(int a) { /* for all window types, not 3D */ @@ -129,18 +110,23 @@ void persp(int a) /* only 3D windows */ if(curarea->spacetype!=SPACE_VIEW3D) persp_general(a); - else if(a== 0) { + else if(a == PERSP_STORE) { // only store glMatrixMode(GL_PROJECTION); - mygetmatrix(curarea->winmat); + mygetmatrix(G.vd->winmat1); glMatrixMode(GL_MODELVIEW); + mygetmatrix(G.vd->viewmat1); + } + else if(a== PERSP_WIN) { // only set myortho2(-0.5, (float)(curarea->winx)-.05, -0.5, (float)(curarea->winy)-0.5); glLoadIdentity(); } - else if(a== 1) { + else if(a== PERSP_VIEW) { glMatrixMode(GL_PROJECTION); - myloadmatrix(curarea->winmat); - glMatrixMode(GL_MODELVIEW); - myloadmatrix(G.vd->viewmat); + myloadmatrix(G.vd->winmat1); // put back + Mat4CpyMat4(curarea->winmat, G.vd->winmat1); // to be sure? + glMatrixMode(GL_MODELVIEW); + myloadmatrix(G.vd->viewmat); // put back + } } |