19 |
|
#if SHADCACHE /* preemptive shadow checking */ |
20 |
|
|
21 |
|
|
22 |
+ |
OBJECT * antimodlist = NULL; /* set of clipped materials */ |
23 |
+ |
|
24 |
+ |
|
25 |
|
static int /* cast source ray to first blocker */ |
26 |
|
castshadow(int sn, FVECT rorg, FVECT rdir) |
27 |
|
{ |
30 |
|
VCOPY(rt.rorg, rorg); |
31 |
|
VCOPY(rt.rdir, rdir); |
32 |
|
rt.rmax = 0; |
33 |
< |
rayorigin(&rt, NULL, PRIMARY, 1.0); |
33 |
> |
rayorigin(&rt, PRIMARY, NULL, NULL); |
34 |
|
/* check for intersection */ |
35 |
|
while (localhit(&rt, &thescene)) { |
36 |
|
RAY rt1 = rt; /* pretend we were aimed at source */ |
293 |
|
if (r->robj == OVOID || objptr(r->robj) != r->ro || |
294 |
|
isvolume(r->ro->otype)) |
295 |
|
return(0); /* don't record complex blockers */ |
296 |
+ |
if (r->rsrc < 0 || source[r->rsrc].so == r->ro) |
297 |
+ |
return(0); /* just a mistake, that's all */ |
298 |
+ |
if (antimodlist != NULL && inset(antimodlist, r->ro->omod)) |
299 |
+ |
return(0); /* could be clipped */ |
300 |
|
m = findmaterial(r->ro); |
301 |
|
if (m == NULL) |
302 |
|
return(0); /* no material?! */ |
315 |
|
|
316 |
|
if (obs == OVOID) |
317 |
|
return(0); |
318 |
< |
op = objptr(obs); /* check for intersection */ |
319 |
< |
return((*ofun[op->otype].funp)(op, r)); |
318 |
> |
op = objptr(obs); /* check blocker intersection */ |
319 |
> |
if (!(*ofun[op->otype].funp)(op, r)) |
320 |
> |
return(0); |
321 |
> |
if (source[r->rsrc].sflags & SDISTANT) |
322 |
> |
return(1); |
323 |
> |
op = source[r->rsrc].so; /* check source intersection */ |
324 |
> |
if (!(*ofun[op->otype].funp)(op, r)) |
325 |
> |
return(1); |
326 |
> |
rayclear(r); |
327 |
> |
return(0); /* source in front */ |
328 |
> |
} |
329 |
> |
|
330 |
> |
|
331 |
> |
void /* record potentially clipped materials */ |
332 |
> |
markclip(OBJREC *m) |
333 |
> |
{ |
334 |
> |
OBJECT *set2add, *oldset; |
335 |
> |
|
336 |
> |
m_clip(m, NULL); /* initialize modifier list */ |
337 |
> |
if ((set2add = (OBJECT *)m->os) == NULL || !set2add[0]) |
338 |
> |
return; |
339 |
> |
|
340 |
> |
if (antimodlist == NULL) { /* start of list */ |
341 |
> |
antimodlist = setsave(set2add); |
342 |
> |
return; |
343 |
> |
} |
344 |
> |
/* else add to previous list */ |
345 |
> |
oldset = antimodlist; |
346 |
> |
antimodlist = (OBJECT *)malloc((oldset[0]+set2add[0]+1)*sizeof(OBJECT)); |
347 |
> |
if (antimodlist == NULL) |
348 |
> |
error(SYSTEM, "out of memory in markclip"); |
349 |
> |
setunion(antimodlist, oldset, set2add); |
350 |
> |
free((void *)oldset); |
351 |
> |
} |
352 |
> |
|
353 |
> |
|
354 |
> |
#else /* SHADCACHE */ |
355 |
> |
|
356 |
> |
|
357 |
> |
void /* no-op also avoids linker warning */ |
358 |
> |
markclip(OBJREC *m) |
359 |
> |
{ |
360 |
> |
(void)m; |
361 |
|
} |
362 |
|
|
363 |
|
|