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

Comparing ray/src/hd/rholo2.c (file contents):
Revision 3.14 by gwlarson, Mon Nov 23 17:50:26 1998 UTC vs.
Revision 3.15 by gwlarson, Mon Nov 23 18:17:53 1998 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14  
15  
16   packrays(rod, p)                /* pack ray origins and directions */
17 < float   *rod;
17 > register float  *rod;
18   register PACKET *p;
19   {
20 <        static int      nmh = 0;
21 <        static int      *mhtab;
22 <        FVECT   ro, rd;
23 <        register BEAM   *bp;
20 >        static FVECT    ro, rd;
21          GCOORD  gc[2];
22 <        int     ila[4], offset;
22 >        int     ila[2], hsh;
23          double  d, sl[4];
24 <        register int    i, j, k;
24 >        register int    i;
25  
26          if (!hdbcoord(gc, hdlist[p->hd], p->bi))
27                  error(CONSISTENCY, "bad beam index in packrays");
31                                                        /* uniqueness hash */
32        if ((bp = hdgetbeam(hdlist[p->hd], p->bi)) != NULL) {
33                if (2*bp->nrm > nmh) {
34                        if (nmh) free((char *)mhtab);
35                        nmh = 2*bp->nrm + 1;
36                        mhtab = (int *)malloc(nmh*sizeof(int));
37                        if (mhtab == NULL)
38                                error(SYSTEM, "out of memory in packrays");
39                }
40                for (k = nmh; k--; )
41                        mhtab[k] = -1;
42                for (i = bp->nrm; i--; ) {
43                        ila[0] = hdbray(bp)[i].r[0][0];
44                        ila[1] = hdbray(bp)[i].r[0][1];
45                        ila[2] = hdbray(bp)[i].r[1][0];
46                        ila[3] = hdbray(bp)[i].r[1][1];
47                        for (k = ilhash(ila,4); mhtab[k%nmh] >= 0; k++)
48                                ;
49                        mhtab[k%nmh] = i;
50                }
51        }
52                                                        /* init each ray */
28          ila[0] = p->hd; ila[1] = p->bi;
29 <        offset = ilhash(ila,2) + p->nc;
29 >        hsh = ilhash(ila,2) + p->nc;
30          for (i = 0; i < p->nr; i++) {
31 <                do {                                    /* next unique ray */
32 <                        multisamp(sl, 4, urand(offset+i));
33 <                        p->ra[i].r[0][0] = ila[0] = sl[0] * 256.;
34 <                        p->ra[i].r[0][1] = ila[1] = sl[1] * 256.;
35 <                        p->ra[i].r[1][0] = ila[2] = sl[2] * 256.;
61 <                        p->ra[i].r[1][1] = ila[3] = sl[3] * 256.;
62 <                        if (bp == NULL)
63 <                                break;
64 <                        for (k = ilhash(ila,4); (j = mhtab[k%nmh]) >= 0; k++)
65 <                                if (hdbray(bp)[j].r[0][0] ==
66 <                                                        p->ra[i].r[0][0] &&
67 <                                                hdbray(bp)[j].r[0][1] ==
68 <                                                        p->ra[i].r[0][1] &&
69 <                                                hdbray(bp)[j].r[1][0] ==
70 <                                                        p->ra[i].r[1][0] &&
71 <                                                hdbray(bp)[j].r[1][1] ==
72 <                                                        p->ra[i].r[1][1]) {
73 <                                        offset += bp->nrm - j;
74 <                                        break;
75 <                                }
76 <                } while (j >= 0);
31 >                multisamp(sl, 4, urand(hsh+i));
32 >                p->ra[i].r[0][0] = sl[0] * 256.;
33 >                p->ra[i].r[0][1] = sl[1] * 256.;
34 >                p->ra[i].r[1][0] = sl[2] * 256.;
35 >                p->ra[i].r[1][1] = sl[3] * 256.;
36                  d = hdray(ro, rd, hdlist[p->hd], gc, p->ra[i].r);
37                  if (!vdef(OBSTRUCTIONS))
38                          d *= frandom();                 /* random offset */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines