--- ray/src/hd/rholo3.c 1998/01/22 11:25:51 3.20 +++ ray/src/hd/rholo3.c 1998/07/08 17:59:58 3.22 @@ -1,9 +1,3 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - -#ifndef lint -static char SCCSid[] = "$SunId$ SGI"; -#endif - /* * Routines for tracking beam compuatations */ @@ -62,6 +56,7 @@ register PACKHEAD *clist; int nents; { int oldnr; + register HDBEAMI *hb; register int i, n; /* look for common members */ for (n = 0; n < nents; n++) { @@ -97,8 +92,7 @@ int nents; /* complete list operations */ switch (op) { case BS_NEW: /* new computation set */ - listpos = 0; - lastin = -1; + listpos = 0; lastin = -1; if (complen) /* free old list */ free((char *)complist); complist = NULL; @@ -118,8 +112,11 @@ int nents; /* what can't we satisfy? */ for (n = 0; n < nents && clist[n].nr > clist[n].nc; n++) ; - if (op == BS_ADJ) - nents = n; + if (op == BS_ADJ) { /* don't regenerate adjusted beams */ + for (i = n; i < nents && clist[i].nr > 0; i++) + ; + nents = i; + } if (n) { /* allocate space for merged list */ PACKHEAD *newlist; newlist = (PACKHEAD *)malloc( @@ -141,17 +138,16 @@ int nents; default: error(CONSISTENCY, "bundle_set called with unknown operation"); } - if (outdev != NULL) { /* load and display beams we have */ - register HDBEAMI *hb; - - hb = (HDBEAMI *)malloc(nents*sizeof(HDBEAMI)); - for (i = 0; i < nents; i++) { - hb[i].h = hdlist[clist[i].hd]; - hb[i].b = clist[i].bi; - } - hdloadbeams(hb, nents, dispbeam); - free((char *)hb); + if (outdev == NULL) /* nothing to display? */ + return; + /* load and display beams we have */ + hb = (HDBEAMI *)malloc(nents*sizeof(HDBEAMI)); + for (i = 0; i < nents; i++) { + hb[i].h = hdlist[clist[i].hd]; + hb[i].b = clist[i].bi; } + hdloadbeams(hb, nents, dispbeam); + free((char *)hb); return; memerr: error(SYSTEM, "out of memory in bundle_set"); @@ -230,7 +226,8 @@ init_global() /* initialize global ray computation * frac = 1024.*1024.*16384. / (wtotal*sizeof(RAYVAL)); while (k--) complist[k].nr = frac * complist[k].nr; - listpos = 0; lastin = -1; /* flag initial sort */ + listpos = 0; lastin = -1; /* perform initial sort */ + sortcomplist(); }