| 100 |
|
} |
| 101 |
|
markvirtuals(); /* find and add virtual sources */ |
| 102 |
|
/* allocate our contribution arrays */ |
| 103 |
< |
maxcntr = nsources + MAXSPART*2; /* start with this many */ |
| 103 |
> |
maxcntr = nsources + MAXSPART; /* start with this many */ |
| 104 |
|
srccnt = (CONTRIB *)malloc(maxcntr*sizeof(CONTRIB)); |
| 105 |
|
cntord = (CNTPTR *)malloc(maxcntr*sizeof(CNTPTR)); |
| 106 |
< |
if (srccnt == NULL || cntord == NULL) |
| 106 |
> |
if (srccnt == NULL | cntord == NULL) |
| 107 |
|
goto memerr; |
| 108 |
|
return; |
| 109 |
|
memerr: |
| 123 |
|
|
| 124 |
|
rayorigin(sr, r, SHADOW, 1.0); /* ignore limits */ |
| 125 |
|
|
| 126 |
< |
while ((d = nextssamp(sr->rorg, sr->rdir, si)) != 0.0) { |
| 126 |
> |
while ((d = nextssamp(sr, si)) != 0.0) { |
| 127 |
|
sr->rsrc = si->sn; /* remember source */ |
| 128 |
|
srcp = source + si->sn; |
| 129 |
|
if (srcp->sflags & SDISTANT) { |
| 228 |
|
maxcntr*sizeof(CONTRIB)); |
| 229 |
|
cntord = (CNTPTR *)realloc((char *)cntord, |
| 230 |
|
maxcntr*sizeof(CNTPTR)); |
| 231 |
< |
if (srccnt == NULL || cntord == NULL) |
| 231 |
> |
if (srccnt == NULL | cntord == NULL) |
| 232 |
|
error(SYSTEM, "out of memory in direct"); |
| 233 |
|
} |
| 234 |
|
cntord[sn].sndx = sn; |
| 235 |
< |
cntord[sn].brt = 0.0; |
| 235 |
> |
srccnt[sn].sno = sr.rsrc; |
| 236 |
|
/* compute coefficient */ |
| 237 |
< |
(*f)(srccnt[sn].coef, p, srccnt[sn].dir, si.dom); |
| 237 |
> |
(*f)(srccnt[sn].coef, p, sr.rdir, si.dom); |
| 238 |
|
cntord[sn].brt = bright(srccnt[sn].coef); |
| 239 |
|
if (cntord[sn].brt <= 0.0) |
| 240 |
|
continue; |
| 261 |
|
l = m; |
| 262 |
|
} |
| 263 |
|
} |
| 264 |
+ |
if (ncnts == 0) |
| 265 |
+ |
return; /* no contributions! */ |
| 266 |
|
/* accumulate tail */ |
| 267 |
|
for (sn = ncnts-1; sn > 0; sn--) |
| 268 |
|
cntord[sn-1].brt += cntord[sn].brt; |