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.6 by gregl, Wed Jan 7 10:49:12 1998 UTC vs.
Revision 3.7 by gregl, Wed Jan 7 17:46:18 1998 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ SGI";
12   #include "view.h"
13   #include "resolu.h"
14  
15 + #ifndef BLOADSIZE
16 + #define BLOADSIZE       1024    /* number of input beams to load at a time */
17 + #endif
18 +
19   int     checkdepth = 1;         /* check depth (!-f option)? */
20   int     checkrepeats = 0;       /* check for repeats (-c option)? */
21   int     frompicz;               /* input from pictures & depth-buffers? */
# Line 187 | Line 191 | COLR   cv;
191   addholo(hdf)                    /* add a holodeck file */
192   char    *hdf;
193   {
194 +        HDBEAMI hbl[BLOADSIZE];
195          int     fd;
196          register HOLO   *hp;
197          register BEAM   *bp;
193        register HDBEAMI        *hbl;
198          GCOORD  gc[2];
199          FVECT   ro, rd;
200          double  d;
201 <        int     i, j;
201 >        int     i, j, n, li;
202          register int    k;
203                                          /* open the holodeck for reading */
204          openholo(hdf, 0);
205          fd = hdlist[noutsects]->fd;     /* remember the file handle */
206          while ((hp = hdlist[noutsects]) != NULL) {      /* load each section */
207 <                hbl = (HDBEAMI *)malloc(nbeams(hp)*sizeof(HDBEAMI));
208 <                if (hbl == NULL)
209 <                        error(SYSTEM, "out of memory in addholo");
210 <                for (j = nbeams(hp); j--; ) {   /* sort the beams */
211 <                        hbl[j].h = hp;
212 <                        hbl[j].b = j+1;
213 <                }
214 <                qsort((char *)hbl, nbeams(hp), sizeof(HDBEAMI), hdfilord);
215 <                for (j = 0; j < nbeams(hp); j++)        /* load each beam */
216 <                        if ((bp = hdgetbeam(hp, hbl[j].b)) != NULL) {
217 <                                hdbcoord(gc, hp, hbl[j].b);
207 >                for (j = 0; j < nbeams(hp); j++) {      /* load each beam */
208 >                        if (!(li = j % BLOADSIZE)) {    /* optimize order */
209 >                                if (j+BLOADSIZE > nbeams(hp))
210 >                                        k = n = nbeams(hp) - j;
211 >                                else
212 >                                        k = n = BLOADSIZE;
213 >                                while (k--) {
214 >                                        hbl[k].h = hp;
215 >                                        hbl[k].b = j+k+1;
216 >                                }
217 >                                qsort((char *)hbl, n,
218 >                                                sizeof(HDBEAMI), hdfilord);
219 >                        }
220 >                        if ((bp = hdgetbeam(hp, hbl[li].b)) != NULL) {
221 >                                hdbcoord(gc, hp, hbl[li].b);
222                                  for (k = bp->nrm; k--; ) {
223                                          d = hdray(ro, rd,
224                                                  hp, gc, hdbray(bp)[k].r);
# Line 221 | Line 229 | char   *hdf;
229                                          d = hddepth(hp, hdbray(bp)[k].d) - d;
230                                          addray(ro, rd, d, hdbray(bp)[k].v);
231                                  }
232 <                                hdfreebeam(hp, hbl[j].b);       /* free beam */
232 >                                hdfreebeam(hp, hbl[li].b);      /* free beam */
233                          }
234 <                free((char *)hbl);                      /* free beam list */
234 >                }
235                  hddone(hp);                             /* free the section */
236          }
237          close(fd);                      /* close the file */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines