--- ray/src/rt/rv3.c 2005/01/18 00:33:16 2.14 +++ ray/src/rt/rv3.c 2005/09/19 02:23:58 2.19 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv3.c,v 2.14 2005/01/18 00:33:16 greg Exp $"; +static const char RCSid[] = "$Id: rv3.c,v 2.19 2005/09/19 02:23:58 greg Exp $"; #endif /* * rv3.c - miscellaneous routines for rview. @@ -16,12 +16,8 @@ static const char RCSid[] = "$Id: rv3.c,v 2.14 2005/01 #include "random.h" #ifndef WFLUSH -#ifdef SPEED -#define WFLUSH (5*SPEED) -#else -#define WFLUSH 100 /* flush after this many rays */ +#define WFLUSH 2048 /* flush after this many rays */ #endif -#endif #ifdef SMLFLT #define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) @@ -108,7 +104,7 @@ double *mp; return(-1); } if (!direc || ourview.type == VT_PAR) { - rayorigin(&thisray, NULL, PRIMARY, 1.0); + rayorigin(&thisray, PRIMARY, NULL, NULL); if (!localhit(&thisray, &thescene)) { error(COMMAND, "not a local object"); return(-1); @@ -122,11 +118,14 @@ double *mp; VCOPY(vec, thisray.rdir); else VCOPY(vec, thisray.rop); - } else if (direc) - for (i = 0; i < 3; i++) - vec[i] -= ourview.vp[i]; - if (normalize(vec) == 0.0) - return(-1); + } else if (direc) { + for (i = 0; i < 3; i++) + vec[i] -= ourview.vp[i]; + if (normalize(vec) == 0.0) { + error(COMMAND, "point at view origin"); + return(-1); + } + } return(0); } @@ -167,8 +166,8 @@ int xmin, ymin, xmax, ymax; h/hresolu, v/vresolu)) < -FTINY) { setcolor(thisray.rcol, 0.0, 0.0, 0.0); } else { - rayorigin(&thisray, NULL, PRIMARY, 1.0); - samplendx++; + rayorigin(&thisray, PRIMARY, NULL, NULL); + samplendx = rand_samp ? random() : samplendx+1; rayvalue(&thisray); } @@ -397,22 +396,23 @@ FVECT vc; normalize(v1); spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); } - if ((nv.type = ourview.type) == VT_PAR) { - nv.horiz = ourview.horiz / mag; - nv.vert = ourview.vert / mag; + if (nv.type == VT_PAR) { + nv.horiz /= mag; + nv.vert /= mag; d = 0.0; /* don't move closer */ for (i = 0; i < 3; i++) d += (vc[i] - ourview.vp[i])*ourview.vdir[i]; } else { d = sqrt(dist2(ourview.vp, vc)) / mag; - if ((nv.vfore = ourview.vfore) > FTINY) { + if (nv.vfore > FTINY) { nv.vfore += d - d*mag; if (nv.vfore < 0.0) nv.vfore = 0.0; } - if ((nv.vaft = ourview.vaft) > FTINY) { + if (nv.vaft > FTINY) { nv.vaft += d - d*mag; if (nv.vaft <= nv.vfore) nv.vaft = 0.0; } + nv.vdist /= mag; } for (i = 0; i < 3; i++) nv.vp[i] = vc[i] - d*nv.vdir[i];