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.31 by gwlarson, Thu Mar 4 10:29:23 1999 UTC vs.
Revision 3.34 by greg, Sat Feb 22 02:07:25 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for tracking beam compuatations
6   */
7  
8   #include "rholo.h"
9   #include "view.h"
13 #include <sys/types.h>
10  
11   #ifndef NFRAG2CHUNK
12   #define NFRAG2CHUNK     4096    /* number of fragments to start chunking */
# Line 104 | Line 100 | register HDBEAMI       *hb;
100          p->bi = hb->b;
101          disp_packet(p);                 /* display it */
102          if (n >= 1024) {                /* free ridiculous packets */
103 <                free((char *)p);
103 >                free((void *)p);
104                  p = NULL; n = 0;
105          }
106   }
# Line 163 | Line 159 | int    nents;
159          case BS_NEW:                    /* new computation set */
160                  listpos = 0; lastin = -1;
161                  if (complen)            /* free old list */
162 <                        free((char *)complist);
162 >                        free((void *)complist);
163                  complist = NULL;
164                  if (!(complen = nents))
165                          return;
# Line 197 | Line 193 | int    nents;
193                                                  /* merge lists */
194                          mergeclists(newlist, clist, n, complist, complen);
195                          if (complen)
196 <                                free((char *)complist);
196 >                                free((void *)complist);
197                          complist = newlist;
198                          complen += n;
199                  }
# Line 218 | Line 214 | int    nents;
214                  hbarr[i].b = clist[i].bi;
215          }
216          hdloadbeams(hbarr, nents, dispbeam);
217 <        free((char *)hbarr);
217 >        free((void *)hbarr);
218          if (hdfragflags&FF_READ) {
219                  listpos = 0;
220                  lastin = -1;            /* need to re-sort list */
# Line 264 | Line 260 | int    bi;
260  
261   ambient_list()                  /* compute ambient beam list */
262   {
263 <        long    wtotal = 0;
263 >        int4    wtotal, minrt;
264          double  frac;
265          int     i;
266          register int    j, k;
# Line 275 | Line 271 | ambient_list()                 /* compute ambient beam list */
271          complist = (PACKHEAD *)malloc(complen*sizeof(PACKHEAD));
272          CHECK(complist==NULL, SYSTEM, "out of memory in ambient_list");
273                                          /* compute beam weights */
274 <        k = 0;
274 >        k = 0; wtotal = 0;
275          for (j = 0; hdlist[j] != NULL; j++) {
276                  frac = 512. * VLEN(hdlist[j]->wg[0]) *
277                                  VLEN(hdlist[j]->wg[1]) *
# Line 290 | Line 286 | ambient_list()                 /* compute ambient beam list */
286          }
287                                          /* adjust sample weights */
288          if (vdef(DISKSPACE))
289 <                frac = 1024.*1024.*vflt(DISKSPACE) /
294 <                                (wtotal*sizeof(RAYVAL));
289 >                frac = 1024.*1024.*vflt(DISKSPACE) / (wtotal*sizeof(RAYVAL));
290          else
291 <                frac = 1024.*1024.*16384. / (wtotal*sizeof(RAYVAL));
292 <        if (frac > 1.11 || frac < 0.9)
293 <                for (k = complen; k--; )
294 <                        complist[k].nr = frac*complist[k].nr + 0.5;
291 >                frac = 1024.*1024.*2048. / (wtotal*sizeof(RAYVAL));
292 >        minrt = .02*frac*wtotal/complen + .5;   /* heuristic mimimum */
293 >        if (minrt > RPACKSIZ)
294 >                minrt = RPACKSIZ;
295 >        for (k = complen; k--; )
296 >                if ((complist[k].nr = frac*complist[k].nr + 0.5) < minrt)
297 >                        complist[k].nr = minrt;
298          listpos = 0; lastin = -1;       /* flag initial sort */
299   }
300  
# Line 320 | Line 318 | FILE   *fp;
318                  normaspect(viewaspect(&curview), &pa, &xr, &yr);
319                  viewbeams(&curview, xr, yr, &blist);
320                  bundle_set(BS_MAX, blist.bl, blist.nb);
321 <                free((char *)blist.bl);
321 >                free((void *)blist.bl);
322          }
323   }
324  
# Line 330 | Line 328 | init_global()                  /* initialize global ray computation *
328          register int    k;
329                                          /* free old list and empty queue */
330          if (complen > 0) {
331 <                free((char *)complist);
331 >                free((void *)complist);
332                  done_packets(flush_queue());
333          }
334                                          /* reseed random number generator */
# Line 397 | Line 395 | sortcomplist()                 /* fix our list order */
395                  qsort((char *)list2, listpos, sizeof(PACKHEAD), beamcmp);
396                  mergeclists(complist, list2, listpos,
397                                  complist+listpos, complen-listpos);
398 <                free((char *)list2);
398 >                free((void *)list2);
399          }
400                                          /* drop satisfied requests */
401          for (i = complen; i-- && complist[i].nr <= complist[i].nc; )
402                  ;
403          if (i < 0) {
404 <                free((char *)complist);
404 >                free((void *)complist);
405                  complist = NULL;
406                  complen = 0;
407          } else if (i < complen-1) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines