--- ray/src/hd/rholo3.c 1997/12/19 09:55:36 3.15 +++ ray/src/hd/rholo3.c 1998/01/05 16:46:34 3.18 @@ -1,4 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -212,9 +212,11 @@ init_global() /* initialize global ray computation * double frac; int i; register int j, k; - /* free old list */ - if (complen > 0) + /* free old list and empty queue */ + if (complen > 0) { free((char *)complist); + done_packets(flush_queue()); + } /* allocate beam list */ complen = 0; for (j = 0; hdlist[j] != NULL; j++) @@ -232,6 +234,7 @@ init_global() /* initialize global ray computation * complist[k].hd = j; complist[k].bi = i; complist[k].nr = frac*beamvolume(hdlist[j], i) + 0.5; + complist[k].nc = bnrays(hdlist[j], i); wtotal += complist[k++].nr; } } @@ -247,11 +250,11 @@ init_global() /* initialize global ray computation * mergeclists(cdest, cl1, n1, cl2, n2) /* merge two sorted lists */ -PACKHEAD *cdest; -PACKHEAD *cl1, *cl2; +register PACKHEAD *cdest; +register PACKHEAD *cl1, *cl2; int n1, n2; { - int cmp; + register int cmp; while (n1 | n2) { if (!n1) cmp = 1; @@ -316,8 +319,9 @@ sortcomplist() /* fix our list order */ * list and start again from the beginning. Since * a merge sort is used, the sorting costs are minimal. */ -next_packet(p) /* prepare packet for computation */ +next_packet(p, n) /* prepare packet for computation */ register PACKET *p; +int n; { register int i; @@ -331,8 +335,12 @@ register PACKET *p; p->nr = complist[listpos].nr - p->nc; if (p->nr <= 0) return(0); - if (p->nr > RPACKSIZ) - p->nr = RPACKSIZ; +#ifdef DEBUG + if (n < 1 | n > RPACKSIZ) + error(CONSISTENCY, "next_packet called with bad n value"); +#endif + if (p->nr > n) + p->nr = n; complist[listpos].nc += p->nr; /* find where this one would go */ while (lastin > listpos && beamcmp(complist+lastin, complist+listpos) > 0)