--- ray/src/hd/rhd_x11.c 1997/12/12 11:13:15 3.15 +++ ray/src/hd/rhd_x11.c 1998/01/01 13:00:15 3.20 @@ -18,6 +18,10 @@ static char SCCSid[] = "$SunId$ SGI"; #include "x11icon.h" +#ifndef RAYQLEN +#define RAYQLEN 50000 /* max. rays to queue before flush */ +#endif + #ifndef FEQ #define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) #endif @@ -81,9 +85,9 @@ mytmflags() /* figure out tone mapping flags */ for (cp = tail; *cp && *cp != '.'; cp++) ; if (cp-tail == 3 && !strncmp(tail, "x11", 3)) - return(TM_F_CAMERA); + return(TM_F_CAMERA|TM_F_NOSTDERR); if (cp-tail == 4 && !strncmp(tail, "x11h", 4)) - return(TM_F_HUMAN); + return(TM_F_HUMAN|TM_F_NOSTDERR); error(USER, "illegal driver name"); } @@ -158,25 +162,22 @@ char *id; oursizhints.min_height = MINHEIGHT; oursizhints.flags = PMinSize; XSetNormalHints(ourdisplay, gwind, &oursizhints); + /* figure out sensible view */ + pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / + DisplayWidth(ourdisplay, ourscreen); + pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / + DisplayHeight(ourdisplay, ourscreen); + copystruct(&odev.v, &stdview); + odev.v.type = VT_PER; /* map the window and get its size */ XMapWindow(ourdisplay, gwind); - dev_input(); + dev_input(); /* sets size and view angles */ /* allocate our leaf pile */ if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * DisplayHeight(ourdisplay,ourscreen) / (qtMinNodesiz*qtMinNodesiz))) error(SYSTEM, "insufficient memory for leaf storage"); - - /* figure out sensible view */ - pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / - DisplayWidth(ourdisplay, ourscreen); - pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / - DisplayHeight(ourdisplay, ourscreen); - copystruct(&odev.v, &stdview); odev.name = id; - odev.v.type = VT_PER; - odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); - odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); odev.ifd = ConnectionNumber(ourdisplay); } @@ -203,7 +204,7 @@ dev_view(nv) /* assign new driver view */ VIEW *nv; { if (nv->type == VT_PAR || /* check view legality */ - nv->horiz > 160. || nv->vert > 160.) { + nv->horiz > 160. || nv->vert > 160.) { error(COMMAND, "illegal view type/angle"); nv->type = VT_PER; nv->horiz = odev.v.horiz; @@ -222,7 +223,7 @@ VIEW *nv; int dh = DisplayHeight(ourdisplay,ourscreen); dw -= 25; /* for window frame */ - dh -= 100; + dh -= 50; odev.hres = 2.*VIEWDIST/pwidth * tan(PI/180./2.*nv->horiz); odev.vres = 2.*VIEWDIST/pheight * @@ -236,6 +237,7 @@ VIEW *nv; odev.vres = dh; } XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); + dev_input(); /* wait for resize event */ } copystruct(&odev.v, nv); } @@ -280,6 +282,7 @@ int dev_flush() /* flush output */ { qtUpdate(); + rayqleft = RAYQLEN; return(XPending(ourdisplay)); } @@ -455,7 +458,7 @@ draw_grids() /* draw holodeck section grids */ static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; unsigned long pixel; - if (!mapped || odev.v.type != VT_PER) + if (!mapped) return; if (ncolors > 0) pixel = pixval[get_pixel(gridrgb, xnewcolr)]; @@ -472,7 +475,7 @@ moveview(dx, dy, mov, orb) /* move our view */ int dx, dy, mov, orb; { VIEW nv; - FVECT v1; + FVECT odir, v1; double d; register int li; /* start with old view */ @@ -481,24 +484,26 @@ int dx, dy, mov, orb; if (mov | orb) { if ((li = qtFindLeaf(dx, dy)) < 0) return(0); /* not on window */ - VSUM(nv.vdir, qtL.wp[li], nv.vp, -1.); + VSUM(odir, qtL.wp[li], nv.vp, -1.); } else { if (viewray(nv.vp, nv.vdir, &odev.v, (dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) return(0); /* outside view */ } if (orb && mov) { /* orbit left/right */ - spinvector(nv.vdir, nv.vdir, nv.vup, MOVDEG*PI/180.*mov); - VSUM(nv.vp, qtL.wp[li], nv.vdir, -1.); + spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov); + VSUM(nv.vp, qtL.wp[li], odir, -1.); + spinvector(nv.vdir, nv.vdir, nv.vup, d); } else if (orb) { /* orbit up/down */ - fcross(v1, nv.vdir, nv.vup); + fcross(v1, odir, nv.vup); if (normalize(v1) == 0.) return(0); - spinvector(nv.vdir, nv.vdir, v1, MOVDEG*PI/180.*orb); - VSUM(nv.vp, qtL.wp[li], nv.vdir, -1.); + spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); + VSUM(nv.vp, qtL.wp[li], odir, -1.); + spinvector(nv.vdir, nv.vdir, v1, d); } else if (mov) { /* move forward/backward */ d = MOVPCT/100. * mov; - VSUM(nv.vp, nv.vp, nv.vdir, d); + VSUM(nv.vp, nv.vp, odir, d); } if (!mov ^ !orb && headlocked) { /* restore head height */ VSUM(v1, odev.v.vp, nv.vp, -1.);