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.27 by gwlarson, Thu Jan 7 22:04:49 1999 UTC vs.
Revision 3.29 by gwlarson, Sat Jan 9 19:48:28 1999 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   */
10  
11   #include "rholo.h"
12 + #include <sys/types.h>
13  
14   #ifndef NFRAG2CHUNK
15   #define NFRAG2CHUNK     4096    /* number of fragments to start chunking */
# Line 23 | Line 24 | static char SCCSid[] = "$SunId$ SGI";
24  
25   #define rchunk(n)       (((n)+(RPACKSIZ/2))/RPACKSIZ)
26  
27 + extern time_t   time();
28 +
29   static PACKHEAD *complist=NULL; /* list of beams to compute */
30   static int      complen=0;      /* length of complist */
31   static int      listpos=0;      /* current list position for next_packet */
# Line 38 | Line 41 | register PACKHEAD      *b0, *b1;
41          register long   c;
42                                          /* first check desired quantities */
43          if (chunky)
44 <                c = rchunk(b1->nr)*(rchunk(b0->nc)+1) -
45 <                                rchunk(b0->nr)*(rchunk(b1->nc)+1);
44 >                c = rchunk(b1->nr)*(rchunk(b0->nc)+1L) -
45 >                                rchunk(b0->nr)*(rchunk(b1->nc)+1L);
46          else
47 <                c = b1->nr*(b0->nc+1) - b0->nr*(b1->nc+1);
48 <        if (c) return(c);
47 >                c = b1->nr*(b0->nc+1L) - b0->nr*(b1->nc+1L);
48 >        if (c > 0) return(1);
49 >        if (c < 0) return(-1);
50                                  /* only one file, so skip the following: */
51   #if 0
52                                          /* next, check file descriptors */
# Line 98 | Line 102 | register HDBEAMI       *hb;
102                          error(CONSISTENCY, "unregistered holodeck in dispbeam");
103          p->bi = hb->b;
104          disp_packet(p);                 /* display it */
105 +        if (n >= 1024) {                /* free ridiculous packets */
106 +                free((char *)p);
107 +                p = NULL; n = 0;
108 +        }
109   }
110  
111  
# Line 258 | Line 266 | init_global()                  /* initialize global ray computation *
266                  free((char *)complist);
267                  done_packets(flush_queue());
268          }
269 +                                        /* reseed random number generator */
270 +        srandom(time(NULL));
271                                          /* allocate beam list */
272          complen = 0;
273          for (j = 0; hdlist[j] != NULL; j++)
# Line 336 | Line 346 | sortcomplist()                 /* fix our list order */
346                          chunky++;       /* use "chunky" comparison */
347                          lastin = -1;    /* need to re-sort list */
348                  }
349 + #ifdef DEBUG
350 +                        else
351 +                                fprintf(stderr, "sortcomplist: %d fragments\n",
352 +                                                listlen);
353 + #endif
354          if (lastin < 0 || listpos*4 >= complen*3)
355                  qsort((char *)complist, complen, sizeof(PACKHEAD), beamcmp);
356          else if (listpos) {     /* else sort and merge sublist */
# Line 391 | Line 406 | int    n;
406          p->nr = complist[listpos].nr - p->nc;
407          if (p->nr <= 0)
408                  return(0);
409 < #ifdef DEBUG
410 <        if (n < 1 | n > RPACKSIZ)
396 <                error(CONSISTENCY, "next_packet called with bad n value");
397 < #endif
409 >        DCHECK(n < 1 | n > RPACKSIZ,
410 >                        CONSISTENCY, "next_packet called with bad n value");
411          if (p->nr > n)
412                  p->nr = n;
413          complist[listpos].nc += p->nr;  /* find where this one would go */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines