--- ray/src/rt/source.c 1991/10/22 15:45:13 1.47 +++ ray/src/rt/source.c 1992/04/12 10:05:32 2.3 @@ -41,6 +41,7 @@ static int maxcntr = 0; /* size of contribution arra marksources() /* find and mark source objects */ { + int foundsource = 0; int i; register OBJREC *o, *m; register int ns; @@ -93,17 +94,19 @@ marksources() /* find and mark source objects */ source[ns].sflags |= SSKIP; } } + if (!(source[ns].sflags & SSKIP)) + foundsource++; } - if (nsources <= 0) { + if (!foundsource) { error(WARNING, "no light sources found"); return; } 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: @@ -228,7 +231,7 @@ 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; @@ -261,6 +264,8 @@ char *p; /* data for f */ l = m; } } + if (ncnts == 0) + return; /* no contributions! */ /* accumulate tail */ for (sn = ncnts-1; sn > 0; sn--) cntord[sn-1].brt += cntord[sn].brt;