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

Comparing ray/src/hd/rhcopy.c (file contents):
Revision 3.3 by gregl, Tue Jan 6 05:57:07 1998 UTC vs.
Revision 3.4 by gregl, Tue Jan 6 22:02:22 1998 UTC

# Line 159 | Line 159 | char   *hdf;
159          int     fd;
160          register HOLO   *hp;
161          register BEAM   *bp;
162 +        register HDBEAMI        *hbl;
163          GCOORD  gc[2];
164          FVECT   ro, rd;
165          double  d;
166          int     i, j;
167          register int    k;
168 <
169 <        openholo(hdf, 0);               /* open the holodeck for reading */
168 >                                        /* open the holodeck for reading */
169 >        openholo(hdf, 0);
170          fd = hdlist[noutsects]->fd;     /* remember the file handle */
171          while ((hp = hdlist[noutsects]) != NULL) {      /* load each section */
172 <                for (j = nbeams(hp); j > 0; j--)        /* load each beam */
173 <                        if ((bp = hdgetbeam(hp, j)) != NULL) {
174 <                                hdbcoord(gc, hp, j);
172 >                hbl = (HDBEAMI *)malloc(nbeams(hp)*sizeof(HDBEAMI));
173 >                if (hbl == NULL)
174 >                        error(SYSTEM, "out of memory in addholo");
175 >                for (j = nbeams(hp); j > 0; j--) {      /* sort the beams */
176 >                        hbl[j].h = hp;
177 >                        hbl[j].b = j;
178 >                }
179 >                qsort((char *)hbl, nbeams(hp), sizeof(HDBEAMI), hdfilord);
180 >                for (j = 0; j < nbeams(hp); j++)        /* load each beam */
181 >                        if ((bp = hdgetbeam(hp, hbl[j].b)) != NULL) {
182 >                                hdbcoord(gc, hp, hbl[j].b);
183                                  for (k = bp->nrm; k--; ) {
184                                          d = hdray(ro, rd,
185                                                  hp, gc, hdbray(bp)[k].r);
# Line 181 | Line 190 | char   *hdf;
190                                          d = hddepth(hp, hdbray(bp)[k].d) - d;
191                                          addray(ro, rd, d, hdbray(bp)[k].v);
192                                  }
193 <                                hdfreebeam(hp, j);      /* free the beam */
193 >                                hdfreebeam(hp, hbl[j].b);       /* free beam */
194                          }
195 +                free((char *)hbl);                      /* free beam list */
196                  hddone(hp);                             /* free the section */
197          }
198          close(fd);                      /* close the file */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines