- 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. :)
This commit is contained in:
parent
c7618783fb
commit
5d1438ad96
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue