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 */ |
203 |
|
ondx += (int)(2*SHADCACHE*srcp->obscache->p.d.e2 * |
204 |
|
(r->rorg[ax2] + t*srcp->sloc[ax2] - |
205 |
|
srcp->obscache->p.d.o[ax2])); |
206 |
< |
if (ondx < 0 | ondx >= 4*SHADCACHE*SHADCACHE) |
206 |
> |
if ((ondx < 0) | (ondx >= 4*SHADCACHE*SHADCACHE)) |
207 |
|
return(&noobs); /* could happen if ray is outside */ |
208 |
|
} else if (srcp->sflags & SFLAT) { |
209 |
|
FVECT sd; |
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 |
|
|
287 |
|
m = findmaterial(r->ro); |
288 |
|
if (m == NULL) |
289 |
|
return; /* no material?! */ |
290 |
< |
if (!(ofun[m->otype].flags & T_OPAQUE)) |
290 |
> |
if (!isopaque(m->otype)) |
291 |
|
return; /* material not a reliable blocker */ |
292 |
|
*srcobstructp(r) = r->robj; /* else record obstructor */ |
293 |
|
} |