ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/aniso.c
(Generate patch)

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.2 by greg, Sat Jan 4 23:36:40 1992 UTC vs.
Revision 2.3 by greg, Mon Jan 6 18:01:41 1992 UTC

# Line 320 | Line 320 | register ANISODAT  *np;
320          FVECT  h;
321          double  rv[2];
322          double  d, sinp, cosp;
323 <        int  confuse;
323 >        int  ntries;
324          register int  i;
325                                          /* compute reflection */
326          if (np->specfl & SP_REFL &&
327                          rayorigin(&sr, r, SPECULAR, np->rspec) == 0) {
328                confuse = 0;
328                  dimlist[ndims++] = (int)np->mp;
329 <        refagain:
330 <                dimlist[ndims] = confuse += 3601;
331 <                d = urand(ilhash(dimlist,ndims+1)+samplendx);
332 <                multisamp(rv, 2, d);
333 <                d = 2.0*PI * rv[0];
334 <                cosp = np->u_alpha * cos(d);
335 <                sinp = np->v_alpha * sin(d);
336 <                d = sqrt(cosp*cosp + sinp*sinp);
337 <                cosp /= d;
338 <                sinp /= d;
339 <                if (rv[1] <= FTINY)
340 <                        d = 1.0;
341 <                else
342 <                        d = sqrt( -log(rv[1]) /
343 <                                (cosp*cosp/(np->u_alpha*np->u_alpha) +
344 <                                 sinp*sinp/(np->v_alpha*np->v_alpha)) );
345 <                for (i = 0; i < 3; i++)
346 <                        h[i] = np->pnorm[i] +
329 >                for (ntries = 0; ntries < 10; ntries++) {
330 >                        dimlist[ndims] = ntries * 3601;
331 >                        d = urand(ilhash(dimlist,ndims+1)+samplendx);
332 >                        multisamp(rv, 2, d);
333 >                        d = 2.0*PI * rv[0];
334 >                        cosp = np->u_alpha * cos(d);
335 >                        sinp = np->v_alpha * sin(d);
336 >                        d = sqrt(cosp*cosp + sinp*sinp);
337 >                        cosp /= d;
338 >                        sinp /= d;
339 >                        if (rv[1] <= FTINY)
340 >                                d = 1.0;
341 >                        else
342 >                                d = sqrt(-log(rv[1]) /
343 >                                        (cosp*cosp/(np->u_alpha*np->u_alpha) +
344 >                                         sinp*sinp/(np->v_alpha*np->v_alpha)));
345 >                        for (i = 0; i < 3; i++)
346 >                                h[i] = np->pnorm[i] +
347                                          d*(cosp*np->u[i] + sinp*np->v[i]);
348 <                d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
349 <                for (i = 0; i < 3; i++)
350 <                        sr.rdir[i] = r->rdir[i] + d*h[i];
351 <                if (DOT(sr.rdir, r->ron) <= FTINY)      /* oops! */
352 <                        goto refagain;
353 <                rayvalue(&sr);
354 <                multcolor(sr.rcol, np->scolor);
355 <                addcolor(r->rcol, sr.rcol);
348 >                        d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
349 >                        for (i = 0; i < 3; i++)
350 >                                sr.rdir[i] = r->rdir[i] + d*h[i];
351 >                        if (DOT(sr.rdir, r->ron) > FTINY) {
352 >                                rayvalue(&sr);
353 >                                multcolor(sr.rcol, np->scolor);
354 >                                addcolor(r->rcol, sr.rcol);
355 >                                break;
356 >                        }
357 >                }
358                  ndims--;
359          }
360                                          /* compute transmission */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines