--- ray/src/rt/source.c 2003/05/14 20:43:46 2.33 +++ ray/src/rt/source.c 2003/08/26 16:09:44 2.36 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: source.c,v 2.33 2003/05/14 20:43:46 greg Exp $"; +static const char RCSid[] = "$Id: source.c,v 2.36 2003/08/26 16:09:44 greg Exp $"; #endif /* * source.c - routines dealing with illumination sources. @@ -60,11 +60,16 @@ marksources() /* find and mark source objects */ if (!issurface(o->otype) || o->omod == OVOID) continue; - + /* find material */ m = objptr(o->omod); - - if (!islight(m->otype)) - continue; + while (!ismaterial(m->otype)) + if (ismixture(m->otype) || m->omod == OVOID) { + m = NULL; + break; + } else + m = objptr(m->omod); + if (m == NULL || !islight(m->otype)) + continue; /* not source modifier */ if (m->oargs.nfargs != (m->otype == MAT_GLOW ? 4 : m->otype == MAT_SPOT ? 7 : 3)) @@ -115,7 +120,7 @@ marksources() /* find and mark source objects */ 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: @@ -297,7 +302,7 @@ char *p; /* data for f */ maxcntr*sizeof(CONTRIB)); cntord = (CNTPTR *)realloc((void *)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; @@ -355,7 +360,11 @@ char *p; /* data for f */ rayorigin(&sr, r, SHADOW, 1.0); VCOPY(sr.rdir, scp->dir); sr.rsrc = scp->sno; - source[scp->sno].ntests++; /* keep statistics */ + /* keep statistics */ + if (source[scp->sno].ntests++ > 0xfffffff0) { + source[scp->sno].ntests >>= 1; + source[scp->sno].nhits >>= 1; + } if (localhit(&sr, &thescene) && ( sr.ro != source[scp->sno].so || source[scp->sno].sflags & SFOLLOW )) { @@ -489,7 +498,7 @@ register RAY *r; static int weaksrcmod(obj) int obj; /* efficiency booster function */ {register OBJREC *o = objptr(obj); -return(o->otype==MAT_ILLUM|o->otype==MAT_GLOW);} +return((o->otype==MAT_ILLUM)|(o->otype==MAT_GLOW));} #define illumblock(m, r) (!(source[r->rsrc].sflags&SVIRTUAL) && \ r->rod > 0.0 && \