--- ray/src/hd/rholo3.c 1997/12/18 14:46:00 3.14 +++ ray/src/hd/rholo3.c 1997/12/31 20:24:11 3.17 @@ -191,10 +191,6 @@ int bi; VSUM(edgeA, cp[1], cp[0], -1.0); VSUM(edgeB, cp[3], cp[1], -1.0); fcross(crossp[i], edgeA, edgeB); - VSUM(edgeA, cp[2], cp[3], -1.0); - VSUM(edgeB, cp[0], cp[2], -1.0); - fcross(v, edgeA, edgeB); - VSUM(crossp[i], crossp[i], v, 1.0); /* compute center */ cent[i][0] = 0.5*(cp[0][0] + cp[2][0]); cent[i][1] = 0.5*(cp[0][1] + cp[2][1]); @@ -203,7 +199,7 @@ int bi; /* compute difference vector */ VSUM(diffv, cent[1], cent[0], -1.0); for (i = 0; i < 2; i++) { /* compute volume contributions */ - vol[i] = 0.25*DOT(crossp[i], diffv); + vol[i] = 0.5*DOT(crossp[i], diffv); if (vol[i] < 0.) vol[i] = -vol[i]; } return(vol[0] + vol[1]); /* return total volume */ @@ -231,6 +227,7 @@ init_global() /* initialize global ray computation * for (j = 0; hdlist[j] != NULL; j++) { frac = 512. * hdlist[j]->wg[0] * hdlist[j]->wg[1] * hdlist[j]->wg[2]; + if (frac < 0.) frac = -frac; for (i = nbeams(hdlist[j]); i > 0; i--) { complist[k].hd = j; complist[k].bi = i; @@ -250,11 +247,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; @@ -319,8 +316,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; @@ -334,8 +332,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)