--- ray/src/rt/source.c 1991/10/21 12:58:06 1.45 +++ ray/src/rt/source.c 1991/11/12 17:08:57 2.1 @@ -100,10 +100,10 @@ marksources() /* find and mark source objects */ } markvirtuals(); /* find and add virtual sources */ /* allocate our contribution arrays */ - maxcntr = nsources + MAXSPART*2; /* start with this many */ + maxcntr = nsources + MAXSPART; /* start with this many */ srccnt = (CONTRIB *)malloc(maxcntr*sizeof(CONTRIB)); cntord = (CNTPTR *)malloc(maxcntr*sizeof(CNTPTR)); - if (srccnt == NULL || cntord == NULL) + if (srccnt == NULL | cntord == NULL) goto memerr; return; memerr: @@ -123,7 +123,7 @@ SRCINDEX *si; /* source sample index */ rayorigin(sr, r, SHADOW, 1.0); /* ignore limits */ - while ((d = nextssamp(sr->rorg, sr->rdir, si)) != 0.0) { + while ((d = nextssamp(sr, si)) != 0.0) { sr->rsrc = si->sn; /* remember source */ srcp = source + si->sn; if (srcp->sflags & SDISTANT) { @@ -228,13 +228,13 @@ char *p; /* data for f */ maxcntr*sizeof(CONTRIB)); cntord = (CNTPTR *)realloc((char *)cntord, maxcntr*sizeof(CNTPTR)); - if (srccnt == NULL || cntord == NULL) + if (srccnt == NULL | cntord == NULL) error(SYSTEM, "out of memory in direct"); } cntord[sn].sndx = sn; - cntord[sn].brt = 0.0; + srccnt[sn].sno = sr.rsrc; /* compute coefficient */ - (*f)(srccnt[sn].coef, p, srccnt[sn].dir, si.dom); + (*f)(srccnt[sn].coef, p, sr.rdir, si.dom); cntord[sn].brt = bright(srccnt[sn].coef); if (cntord[sn].brt <= 0.0) continue;