136 |
|
else |
137 |
|
VSUM(rdir, srcp->obscache->p.f.v, |
138 |
|
srcp->obscache->p.f.u, d); |
139 |
< |
d = 2./SHADCACHE*(j+.5); |
139 |
> |
d = 1. - 2./SHADCACHE*(j+.5); |
140 |
|
VSUM(rdir, rdir, srcp->snorm, d); |
141 |
|
normalize(rdir); |
142 |
|
castshadow(sn, rorg, rdir); |
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; |
225 |
|
if (sd[0] < 0) |
226 |
|
ondx += ((SHADCACHE+1)>>1)*SHADCACHE; |
227 |
|
ondx += SHADCACHE*(int)(SHADCACHE*(.5-FTINY) * |
228 |
< |
sd[2]/sd0m); |
228 |
> |
(1. - sd[2]/sd0m)); |
229 |
|
ondx += (int)(SHADCACHE*(.5-FTINY) * |
230 |
|
(1. + sd[1]/sd0m)); |
231 |
|
} else /* sd1m > sd0m */ { |
234 |
|
if (sd[1] < 0) |
235 |
|
ondx += ((SHADCACHE+1)>>1)*SHADCACHE; |
236 |
|
ondx += SHADCACHE*(int)(SHADCACHE*(.5-FTINY) * |
237 |
< |
sd[2]/sd1m); |
237 |
> |
(1. - sd[2]/sd1m)); |
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, |
243 |
+ |
"flat source cache index out of bounds"); |
244 |
|
} else /* spherical distribution */ { |
245 |
|
int ax, ax1, ax2; |
246 |
|
RREAL amax = 0; |
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, |
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 |
|
} |
302 |
|
if (obs == OVOID) |
303 |
|
return(0); |
304 |
|
op = objptr(obs); /* check for intersection */ |
305 |
< |
return ((*ofun[op->otype].funp)(op, r)); |
305 |
> |
return((*ofun[op->otype].funp)(op, r)); |
306 |
|
} |
307 |
|
|
308 |
|
|