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

Comparing ray/src/hd/rholo3.c (file contents):
Revision 3.13 by gregl, Mon Dec 15 20:44:28 1997 UTC vs.
Revision 3.15 by gregl, Fri Dec 19 09:55:36 1997 UTC

# Line 27 | Line 27 | register PACKHEAD      *b0, *b1;
27   }
28  
29  
30 + int
31 + dispbeam(b, hp, bi)                     /* display a holodeck beam */
32 + register BEAM   *b;
33 + HOLO    *hp;
34 + int     bi;
35 + {
36 +        static int      n = 0;
37 +        static PACKHEAD *p = NULL;
38 +
39 +        if (b == NULL)
40 +                return;
41 +        if (b->nrm > n) {               /* (re)allocate packet holder */
42 +                n = b->nrm;
43 +                if (p == NULL) p = (PACKHEAD *)malloc(packsiz(n));
44 +                else p = (PACKHEAD *)realloc((char *)p, packsiz(n));
45 +                if (p == NULL)
46 +                        error(SYSTEM, "out of memory in dispbeam");
47 +        }
48 +                                        /* assign packet fields */
49 +        bcopy((char *)hdbray(b), (char *)packra(p), b->nrm*sizeof(RAYVAL));
50 +        p->nr = p->nc = b->nrm;
51 +        for (p->hd = 0; hdlist[p->hd] != hp; p->hd++)
52 +                if (hdlist[p->hd] == NULL)
53 +                        error(CONSISTENCY, "unregistered holodeck in dispbeam");
54 +        p->bi = bi;
55 +        disp_packet(p);                 /* display it */
56 + }
57 +
58 +
59   bundle_set(op, clist, nents)    /* bundle set operation */
60   int     op;
61 < PACKHEAD        *clist;
61 > register PACKHEAD       *clist;
62   int     nents;
63   {
35        BEAM    *b;
36        PACKHEAD        *p;
64          register int    i, n;
65  
66          switch (op) {
# Line 121 | Line 148 | int    nents;
148          default:
149                  error(CONSISTENCY, "bundle_set called with unknown operation");
150          }
151 <        if (outdev == NULL)
152 <                return;
153 <        n = 32*RPACKSIZ;                /* allocate packet holder */
154 <        p = (PACKHEAD *)malloc(packsiz(n));
155 <        if (p == NULL)
156 <                goto memerr;
157 <                                        /* display what we have */
131 <        for (i = 0; i < nents; i++)
132 <                if ((b = hdgetbeam(hdlist[clist[i].hd], clist[i].bi)) != NULL) {
133 <                        if (b->nrm > n) {
134 <                                n = b->nrm;
135 <                                p = (PACKHEAD *)realloc((char *)p, packsiz(n));
136 <                                if (p == NULL)
137 <                                        goto memerr;
138 <                        }
139 <                        bcopy((char *)hdbray(b), (char *)packra(p),
140 <                                        b->nrm*sizeof(RAYVAL));
141 <                        p->hd = clist[i].hd;
142 <                        p->bi = clist[i].bi;
143 <                        p->nr = p->nc = b->nrm;
144 <                        disp_packet(p);
151 >        if (outdev != NULL) {           /* load and display beams we have */
152 >                register HDBEAMI        *hb;
153 >
154 >                hb = (HDBEAMI *)malloc(nents*sizeof(HDBEAMI));
155 >                for (i = 0; i < nents; i++) {
156 >                        hb[i].h = hdlist[clist[i].hd];
157 >                        hb[i].b = clist[i].bi;
158                  }
159 <        free((char *)p);                /* clean up */
159 >                hdloadbeams(hb, nents, dispbeam);
160 >                free((char *)hb);
161 >        }
162          if (op == BS_NEW) {
163                  done_packets(flush_queue());    /* empty queue, so we can... */
164                  for (i = 0; i < complen; i++)   /* ...get number computed */
# Line 176 | Line 191 | int    bi;
191                  VSUM(edgeA, cp[1], cp[0], -1.0);
192                  VSUM(edgeB, cp[3], cp[1], -1.0);
193                  fcross(crossp[i], edgeA, edgeB);
179                VSUM(edgeA, cp[2], cp[3], -1.0);
180                VSUM(edgeB, cp[0], cp[2], -1.0);
181                fcross(v, edgeA, edgeB);
182                VSUM(crossp[i], crossp[i], v, 1.0);
194                                          /* compute center */
195                  cent[i][0] = 0.5*(cp[0][0] + cp[2][0]);
196                  cent[i][1] = 0.5*(cp[0][1] + cp[2][1]);
# Line 188 | Line 199 | int    bi;
199                                          /* compute difference vector */
200          VSUM(diffv, cent[1], cent[0], -1.0);
201          for (i = 0; i < 2; i++) {       /* compute volume contributions */
202 <                vol[i] = 0.25*DOT(crossp[i], diffv);
202 >                vol[i] = 0.5*DOT(crossp[i], diffv);
203                  if (vol[i] < 0.) vol[i] = -vol[i];
204          }
205          return(vol[0] + vol[1]);        /* return total volume */
# Line 216 | Line 227 | init_global()                  /* initialize global ray computation *
227          for (j = 0; hdlist[j] != NULL; j++) {
228                  frac = 512. * hdlist[j]->wg[0] *
229                                  hdlist[j]->wg[1] * hdlist[j]->wg[2];
230 +                if (frac < 0.) frac = -frac;
231                  for (i = nbeams(hdlist[j]); i > 0; i--) {
232                          complist[k].hd = j;
233                          complist[k].bi = i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines