| 41 |
|
|
| 42 |
|
marksources() /* find and mark source objects */ |
| 43 |
|
{ |
| 44 |
+ |
int foundsource = 0; |
| 45 |
|
int i; |
| 46 |
|
register OBJREC *o, *m; |
| 47 |
|
register int ns; |
| 94 |
|
source[ns].sflags |= SSKIP; |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
+ |
if (!(source[ns].sflags & SSKIP)) |
| 98 |
+ |
foundsource++; |
| 99 |
|
} |
| 100 |
< |
if (nsources <= 0) { |
| 100 |
> |
if (!foundsource) { |
| 101 |
|
error(WARNING, "no light sources found"); |
| 102 |
|
return; |
| 103 |
|
} |
| 104 |
|
markvirtuals(); /* find and add virtual sources */ |
| 105 |
|
/* allocate our contribution arrays */ |
| 106 |
< |
maxcntr = nsources + MAXSPART*2; /* start with this many */ |
| 106 |
> |
maxcntr = nsources + MAXSPART; /* start with this many */ |
| 107 |
|
srccnt = (CONTRIB *)malloc(maxcntr*sizeof(CONTRIB)); |
| 108 |
|
cntord = (CNTPTR *)malloc(maxcntr*sizeof(CNTPTR)); |
| 109 |
< |
if (srccnt == NULL || cntord == NULL) |
| 109 |
> |
if (srccnt == NULL | cntord == NULL) |
| 110 |
|
goto memerr; |
| 111 |
|
return; |
| 112 |
|
memerr: |
| 126 |
|
|
| 127 |
|
rayorigin(sr, r, SHADOW, 1.0); /* ignore limits */ |
| 128 |
|
|
| 129 |
< |
while ((d = nextssamp(sr->rorg, sr->rdir, si)) != 0.0) { |
| 129 |
> |
while ((d = nextssamp(sr, si)) != 0.0) { |
| 130 |
|
sr->rsrc = si->sn; /* remember source */ |
| 131 |
|
srcp = source + si->sn; |
| 132 |
|
if (srcp->sflags & SDISTANT) { |
| 231 |
|
maxcntr*sizeof(CONTRIB)); |
| 232 |
|
cntord = (CNTPTR *)realloc((char *)cntord, |
| 233 |
|
maxcntr*sizeof(CNTPTR)); |
| 234 |
< |
if (srccnt == NULL || cntord == NULL) |
| 234 |
> |
if (srccnt == NULL | cntord == NULL) |
| 235 |
|
error(SYSTEM, "out of memory in direct"); |
| 236 |
|
} |
| 237 |
|
cntord[sn].sndx = sn; |
| 238 |
< |
cntord[sn].brt = 0.0; |
| 238 |
> |
srccnt[sn].sno = sr.rsrc; |
| 239 |
|
/* compute coefficient */ |
| 240 |
< |
(*f)(srccnt[sn].coef, p, srccnt[sn].dir, si.dom); |
| 240 |
> |
(*f)(srccnt[sn].coef, p, sr.rdir, si.dom); |
| 241 |
|
cntord[sn].brt = bright(srccnt[sn].coef); |
| 242 |
|
if (cntord[sn].brt <= 0.0) |
| 243 |
|
continue; |
| 264 |
|
l = m; |
| 265 |
|
} |
| 266 |
|
} |
| 267 |
+ |
if (ncnts == 0) |
| 268 |
+ |
return; /* no contributions! */ |
| 269 |
|
/* accumulate tail */ |
| 270 |
|
for (sn = ncnts-1; sn > 0; sn--) |
| 271 |
|
cntord[sn-1].brt += cntord[sn].brt; |