| 20 |  | #define NVSAMPS         16384   /* number of ray samples per view */ | 
| 21 |  | #endif | 
| 22 |  | #ifndef MEYERNG | 
| 23 | < | #define MEYERNG         0.1     /* target mean eye range (rel. to grid) */ | 
| 23 | > | #define MEYERNG         0.2     /* target mean eye range (rel. to grid) */ | 
| 24 |  | #endif | 
| 25 |  | #ifndef MAXTODO | 
| 26 |  | #define MAXTODO         3       /* maximum sections to look at */ | 
| 178 |  | } | 
| 179 |  |  | 
| 180 |  |  | 
| 181 | < | int | 
| 181 | > | static int | 
| 182 |  | comptodo(tdl, vw)               /* compute holodeck sections in view */ | 
| 183 |  | int     tdl[MAXTODO+1]; | 
| 184 |  | VIEW    *vw; | 
| 221 |  | } | 
| 222 |  |  | 
| 223 |  |  | 
| 224 | < | addview(hd, vw, hres, vres)     /* add view for section */ | 
| 224 | > | int | 
| 225 | > | addview(hd, vw, rad, hres, vres)        /* add view for section */ | 
| 226 |  | int     hd; | 
| 227 |  | VIEW    *vw; | 
| 228 | + | double  rad; | 
| 229 |  | int     hres, vres; | 
| 230 |  | { | 
| 231 | < | int     sampquant; | 
| 231 | > | int     sampquant, samptot = 0; | 
| 232 |  | int     h, v, shr, svr; | 
| 233 |  | GCOORD  gc[2]; | 
| 234 |  | FVECT   rorg, rdir; | 
| 244 |  | /* intersect sample rays with section */ | 
| 245 |  | for (v = svr; v--; ) | 
| 246 |  | for (h = shr; h--; ) { | 
| 247 | < | if (viewray(rorg, rdir, vw, (v+frandom())/svr, | 
| 248 | < | (h+frandom())/shr) < -FTINY) | 
| 247 | > | if (viewray(rorg, rdir, vw, (h+frandom())/shr, | 
| 248 | > | (v+frandom())/svr) < -FTINY) | 
| 249 |  | continue; | 
| 250 | + | if (rad > FTINY) { | 
| 251 | + | rorg[0] += (1.-2.*frandom())*rad; | 
| 252 | + | rorg[1] += (1.-2.*frandom())*rad; | 
| 253 | + | rorg[2] += (1.-2.*frandom())*rad; | 
| 254 | + | } | 
| 255 |  | if (hdinter(gc, NULL, NULL, hdlist[hd], rorg, rdir) | 
| 256 | < | >= FHUGE) | 
| 256 | > | >= 0.99*FHUGE) | 
| 257 |  | continue; | 
| 258 |  | cbeam[getcbeam(hd,hdbindex(hdlist[hd],gc))].nr += | 
| 259 |  | sampquant; | 
| 260 | + | samptot += sampquant; | 
| 261 |  | } | 
| 262 | + | return(samptot); | 
| 263 |  | } | 
| 264 |  |  | 
| 265 |  |  | 
| 277 |  | } | 
| 278 |  |  | 
| 279 |  |  | 
| 280 | + | int * | 
| 281 |  | beam_view(vn, hr, vr)           /* add beam view (if advisable) */ | 
| 282 |  | VIEW    *vn; | 
| 283 |  | int     hr, vr; | 
| 284 |  | { | 
| 285 | < | int     todo[MAXTODO+1], n; | 
| 286 | < | double  hdgsiz, d; | 
| 285 | > | static int      todo[MAXTODO+1]; | 
| 286 | > | int     n; | 
| 287 | > | double  er, eravg, d; | 
| 288 |  | register HOLO   *hp; | 
| 289 |  | register int    i; | 
| 290 | < | /* sort our list */ | 
| 290 | > | /* find nearby sections */ | 
| 291 | > | if (!(n = comptodo(todo, vn))) | 
| 292 | > | return(NULL); | 
| 293 | > | /* sort current beam list */ | 
| 294 |  | cbeamsort(1); | 
| 295 |  | /* add view to nearby sections */ | 
| 296 | < | if (!(n = comptodo(todo, vn))) | 
| 283 | < | return(0); | 
| 284 | < | for (i = 0; i < n; i++) | 
| 285 | < | addview(todo[i], vn, hr, vr); | 
| 286 | < | if (MEYERNG <= FTINY || vn->type == VT_PAR) | 
| 287 | < | return(1); | 
| 288 | < | hdgsiz = 0.;                    /* compute mean grid size */ | 
| 296 | > | eravg = 0.; | 
| 297 |  | for (i = 0; i < n; i++) { | 
| 298 |  | hp = hdlist[todo[i]]; | 
| 299 | < | hdgsiz +=       1./3. / VLEN(hp->wg[0]) + | 
| 300 | < | 1./3. / VLEN(hp->wg[1]) + | 
| 301 | < | 1./3. / VLEN(hp->wg[2]) ; | 
| 299 | > | if (MEYERNG > FTINY) | 
| 300 | > | er =    MEYERNG/3. / VLEN(hp->wg[0]) + | 
| 301 | > | MEYERNG/3. / VLEN(hp->wg[1]) + | 
| 302 | > | MEYERNG/3. / VLEN(hp->wg[2]) ; | 
| 303 | > | else | 
| 304 | > | er = 0.; | 
| 305 | > | if (!addview(todo[i], vn, 0.25*er, hr, vr)) { | 
| 306 | > | register int    j;              /* whoops! */ | 
| 307 | > | n--;                            /* delete from list */ | 
| 308 | > | for (j = i--; j <= n; j++) | 
| 309 | > | todo[j] = todo[j+1]; | 
| 310 | > | } else | 
| 311 | > | eravg += er; | 
| 312 |  | } | 
| 313 | < | hdgsiz /= (double)n; | 
| 313 | > | if (eravg <= FTINY) | 
| 314 | > | return(todo); | 
| 315 | > | /* compute average eye range */ | 
| 316 | > | eravg /= (double)n; | 
| 317 |  | /* add to current eye position */ | 
| 318 |  | if (cureye.rng <= FTINY) { | 
| 319 |  | VCOPY(cureye.vpt, vn->vp); | 
| 320 | < | cureye.rng = MEYERNG * hdgsiz; | 
| 321 | < | } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + MEYERNG*hdgsiz > | 
| 301 | < | cureye.rng) { | 
| 320 | > | cureye.rng = eravg; | 
| 321 | > | } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + eravg > cureye.rng) { | 
| 322 |  | for (i = 3; i--; ) | 
| 323 |  | cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]); | 
| 324 | < | cureye.rng = 0.5*(cureye.rng + MEYERNG*hdgsiz + d); | 
| 324 | > | cureye.rng = 0.5*(cureye.rng + eravg + d); | 
| 325 |  | } | 
| 326 | < | return(1); | 
| 326 | > | return(todo); | 
| 327 |  | } | 
| 328 |  |  | 
| 329 |  |  |