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.2 by gregl, Mon Nov 3 18:33:13 1997 UTC vs.
Revision 3.4 by gregl, Tue Nov 4 11:52:21 1997 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ SGI";
15   #define sgn(x)          ((x) > 0 ? 1 : (x) < 0 ? -1 : 0)
16  
17  
18 < static PACKHEAD *complist;      /* list of beams to compute */
19 < static int      complen;        /* length of complist */
20 < static int      listpos;        /* current list position for next_packet */
21 < static int      lastin = -1;    /* last ordered position in list */
18 > static PACKHEAD *complist=NULL; /* list of beams to compute */
19 > static int      complen=0;      /* length of complist */
20 > static int      listpos=0;      /* current list position for next_packet */
21 > static int      lastin= -1;     /* last ordered position in list */
22  
23  
24   int
# Line 110 | Line 110 | int    nents;
110                                          lastin = -1;    /* flag full sort */
111                                          break;
112                                  }
113 <                                        /* sort updated list */
114 <                sortcomplist();
113 >                if (lastin < 0)         /* sort updated list */
114 >                        sortcomplist();
115                  return;                 /* no display */
116          default:
117                  error(CONSISTENCY, "bundle_set called with unknown operation");
# Line 121 | Line 121 | int    nents;
121                  if (clist[i].nr > n)
122                          n = clist[i].nr;
123          p = (PACKHEAD *)malloc(sizeof(PACKHEAD) + n*sizeof(RAYVAL));
124 <                                        /* now, display what we can */
124 >        if (p == NULL)
125 >                goto memerr;
126 >                                        /* display what we have */
127          for (i = 0; i < nents; i++)
128 <                if (clist[i].nr > 0 &&
127 <                (b = hdgetbeam(hdlist[clist[i].hd], clist[i].bi)) != NULL) {
128 >                if ((b = hdgetbeam(hdlist[clist[i].hd], clist[i].bi)) != NULL) {
129                          bcopy((char *)hdbray(b), (char *)(p+1),
130                                          (p->nr=b->nrm)*sizeof(RAYVAL));
131                          disp_packet((PACKET *)p);
# Line 204 | Line 205 | init_global()                  /* initialize global ray computation *
205          int     lseg[2][3];
206          double  frac;
207          register int    k;
208 +                                        /* free old list */
209 +        if (complen > 0)
210 +                free((char *)complist);
211                                          /* allocate beam list */
212          complen = 0;
213          for (j = 0; hdlist[j] != NULL; j++)
# Line 232 | Line 236 | init_global()                  /* initialize global ray computation *
236                          while (k--)
237                                  complist[k].nr = frac * complist[k].nr;
238          }
239 <        listpos = 0; lastin = -1;
239 >        listpos = 0; lastin = -1;       /* flag initial sort */
240   }
241  
242  
# Line 266 | Line 270 | sortcomplist()                 /* fix our list order */
270  
271                                  /* empty queue */
272          done_packets(flush_queue());
273 <        if (complen <= 0)       /* check to see if there even is a list */
273 >        if (complen <= 0)       /* check to see if there is even a list */
274                  return;
275          if (lastin < 0)         /* flag to sort entire list */
276                  qsort((char *)complist, complen, sizeof(PACKHEAD), beamcmp);
# Line 290 | Line 294 | sortcomplist()                 /* fix our list order */
294          for (i = complen; i-- && complist[i].nr <=
295                          bnrays(hdlist[complist[i].hd],complist[i].bi); )
296                  ;
297 <        if (i < complen-1) {
297 >        if (i < 0) {
298 >                free((char *)complist);
299 >                complist = NULL;
300 >                complen = 0;
301 >        } else if (i < complen-1) {
302                  list2 = (PACKHEAD *)realloc((char *)complist,
303                                  (i+1)*sizeof(PACKHEAD));
304                  if (list2 != NULL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines