--- ray/src/rt/srcobstr.c 2004/09/08 06:07:52 2.7 +++ ray/src/rt/srcobstr.c 2004/09/10 17:08:36 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: srcobstr.c,v 2.7 2004/09/08 06:07:52 greg Exp $"; +static const char RCSid[] = "$Id: srcobstr.c,v 2.10 2004/09/10 17:08:36 greg Exp $"; #endif /* * Source occlusion caching routines @@ -50,7 +50,7 @@ castshadow(int sn, FVECT rorg, FVECT rdir) } -static void /* initialize occlusion cache */ +void /* initialize occlusion cache */ initobscache(int sn) { register SRCREC *srcp = &source[sn]; @@ -60,6 +60,8 @@ initobscache(int sn) int i, j, k; int ax, ax1, ax2; + if (srcp->sflags & (SSKIP|SPROX|SSPOT|SVIRTUAL)) + return; /* don't cache these */ if (srcp->sflags & SDISTANT) cachelen = 4*SHADCACHE*SHADCACHE; else if (srcp->sflags & SFLAT) @@ -67,8 +69,6 @@ initobscache(int sn) else /* spherical distribution */ cachelen = SHADCACHE*SHADCACHE*6; /* allocate cache */ - DCHECK(srcp->obscache != NULL, - CONSISTENCY, "initobscache() called twice"); srcp->obscache = (OBSCACHE *)malloc(sizeof(OBSCACHE) + sizeof(OBJECT)*(cachelen-1)); if (srcp->obscache == NULL) @@ -308,8 +308,16 @@ srcblocked(RAY *r) if (obs == OVOID) return(0); - op = objptr(obs); /* check for intersection */ - return((*ofun[op->otype].funp)(op, r)); + op = objptr(obs); /* check blocker intersection */ + if (!(*ofun[op->otype].funp)(op, r)) + return(0); + if (source[r->rsrc].sflags & SDISTANT) + return(1); + op = source[r->rsrc].so; /* check source intersection */ + if (!(*ofun[op->otype].funp)(op, r)) + return(1); + rayclear(r); + return(0); /* source in front */ }