| 169 |
|
static OBJECT * /* return occluder cache entry */ |
| 170 |
|
srcobstructp(register RAY *r) |
| 171 |
|
{ |
| 172 |
+ |
static unsigned long lastrno = ~0; |
| 173 |
|
static OBJECT noobs; |
| 174 |
+ |
static OBJECT *lastobjp; |
| 175 |
|
SRCREC *srcp; |
| 176 |
|
int ondx; |
| 177 |
|
|
| 178 |
+ |
noobs = OVOID; |
| 179 |
+ |
if (r->rno == lastrno) |
| 180 |
+ |
return lastobjp; /* just recall last pointer */ |
| 181 |
|
DCHECK(r->rsrc < 0, CONSISTENCY, |
| 182 |
|
"srcobstructp() called with unaimed ray"); |
| 183 |
< |
noobs = OVOID; |
| 183 |
> |
lastrno = r->rno; |
| 184 |
> |
lastobjp = &noobs; |
| 185 |
|
srcp = &source[r->rsrc]; |
| 186 |
|
if (srcp->sflags & (SSKIP|SPROX|SSPOT|SVIRTUAL)) |
| 187 |
|
return(&noobs); /* don't cache these */ |
| 238 |
|
ondx += (int)(SHADCACHE*(.5-FTINY) * |
| 239 |
|
(1. + sd[0]/sd1m)); |
| 240 |
|
} |
| 241 |
< |
DCHECK(ondx < 0 | ondx >= SHADCACHE*SHADCACHE*3 + |
| 242 |
< |
(SHADCACHE&1)*SHADCACHE*4, CONSISTENCY, |
| 241 |
> |
DCHECK((ondx < 0) | (ondx >= SHADCACHE*SHADCACHE*3 + |
| 242 |
> |
(SHADCACHE&1)*SHADCACHE*4), CONSISTENCY, |
| 243 |
|
"flat source cache index out of bounds"); |
| 244 |
|
} else /* spherical distribution */ { |
| 245 |
|
int ax, ax1, ax2; |
| 258 |
|
(1. + r->rdir[ax1]/amax)); |
| 259 |
|
ondx += (int)(SHADCACHE*(.5-FTINY) * |
| 260 |
|
(1. + r->rdir[ax2]/amax)); |
| 261 |
< |
DCHECK(ondx < 0 | ondx >= SHADCACHE*SHADCACHE*6, CONSISTENCY, |
| 261 |
> |
DCHECK((ondx < 0) | (ondx >= SHADCACHE*SHADCACHE*6), CONSISTENCY, |
| 262 |
|
"radial source cache index out of bounds"); |
| 263 |
|
} |
| 264 |
|
/* return cache pointer */ |
| 265 |
< |
return(&srcp->obscache->obs[ondx]); |
| 265 |
> |
return(lastobjp = &srcp->obscache->obs[ondx]); |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
|