| 11 |
|
|
| 12 |
|
#include "otspecial.h" |
| 13 |
|
|
| 14 |
+ |
#include "rtotypes.h" |
| 15 |
+ |
|
| 16 |
|
#include "source.h" |
| 17 |
|
|
| 18 |
|
#define ABS(x) ((x)>0 ? (x) : -(x)) |
| 21 |
|
#if SHADCACHE /* preemptive shadow checking */ |
| 22 |
|
|
| 23 |
|
|
| 24 |
+ |
OBJECT * antimodlist = NULL; /* set of clipped materials */ |
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
|
static int /* cast source ray to first blocker */ |
| 28 |
|
castshadow(int sn, FVECT rorg, FVECT rdir) |
| 29 |
|
{ |
| 32 |
|
VCOPY(rt.rorg, rorg); |
| 33 |
|
VCOPY(rt.rdir, rdir); |
| 34 |
|
rt.rmax = 0; |
| 35 |
< |
rayorigin(&rt, NULL, PRIMARY, 1.0); |
| 35 |
> |
rayorigin(&rt, PRIMARY, NULL, NULL); |
| 36 |
|
/* check for intersection */ |
| 37 |
|
while (localhit(&rt, &thescene)) { |
| 38 |
|
RAY rt1 = rt; /* pretend we were aimed at source */ |
| 63 |
|
FVECT rorg, rdir; |
| 64 |
|
RREAL d; |
| 65 |
|
int i, j, k; |
| 66 |
< |
int ax, ax1, ax2; |
| 66 |
> |
int ax=0, ax1=1, ax2=2; |
| 67 |
|
|
| 68 |
|
if (srcp->sflags & (SSKIP|SPROX|SSPOT|SVIRTUAL)) |
| 69 |
|
return; /* don't cache these */ |
| 180 |
|
static OBJECT * /* return occluder cache entry */ |
| 181 |
|
srcobstructp(register RAY *r) |
| 182 |
|
{ |
| 183 |
< |
static unsigned long lastrno = ~0; |
| 183 |
> |
static RNUMBER lastrno = ~0; |
| 184 |
|
static OBJECT noobs; |
| 185 |
|
static OBJECT *lastobjp; |
| 186 |
|
SRCREC *srcp; |
| 200 |
|
initobscache(r->rsrc); |
| 201 |
|
/* compute cache index */ |
| 202 |
|
if (srcp->sflags & SDISTANT) { |
| 203 |
< |
int ax, ax1, ax2; |
| 203 |
> |
int ax=0, ax1=1, ax2=2; |
| 204 |
|
double t; |
| 205 |
|
ax = srcp->obscache->p.d.ax; |
| 206 |
|
if ((ax1 = ax+1) >= 3) ax1 -= 3; |
| 295 |
|
if (r->robj == OVOID || objptr(r->robj) != r->ro || |
| 296 |
|
isvolume(r->ro->otype)) |
| 297 |
|
return(0); /* don't record complex blockers */ |
| 298 |
+ |
if (r->rsrc < 0 || source[r->rsrc].so == r->ro) |
| 299 |
+ |
return(0); /* just a mistake, that's all */ |
| 300 |
+ |
if (antimodlist != NULL && inset(antimodlist, r->ro->omod)) |
| 301 |
+ |
return(0); /* could be clipped */ |
| 302 |
|
m = findmaterial(r->ro); |
| 303 |
|
if (m == NULL) |
| 304 |
|
return(0); /* no material?! */ |
| 327 |
|
return(1); |
| 328 |
|
rayclear(r); |
| 329 |
|
return(0); /* source in front */ |
| 330 |
+ |
} |
| 331 |
+ |
|
| 332 |
+ |
|
| 333 |
+ |
void /* record potentially clipped materials */ |
| 334 |
+ |
markclip(OBJREC *m) |
| 335 |
+ |
{ |
| 336 |
+ |
OBJECT *set2add, *oldset; |
| 337 |
+ |
|
| 338 |
+ |
if (m == NULL) { /* starting over */ |
| 339 |
+ |
if (antimodlist != NULL) |
| 340 |
+ |
free((void *)antimodlist); |
| 341 |
+ |
antimodlist = NULL; |
| 342 |
+ |
return; |
| 343 |
+ |
} |
| 344 |
+ |
m_clip(m, NULL); /* initialize modifier list */ |
| 345 |
+ |
if ((set2add = (OBJECT *)m->os) == NULL || !set2add[0]) |
| 346 |
+ |
return; |
| 347 |
+ |
|
| 348 |
+ |
if (antimodlist == NULL) { /* start of list */ |
| 349 |
+ |
antimodlist = setsave(set2add); |
| 350 |
+ |
return; |
| 351 |
+ |
} |
| 352 |
+ |
/* else add to previous list */ |
| 353 |
+ |
oldset = antimodlist; |
| 354 |
+ |
antimodlist = (OBJECT *)malloc((oldset[0]+set2add[0]+1)*sizeof(OBJECT)); |
| 355 |
+ |
if (antimodlist == NULL) |
| 356 |
+ |
error(SYSTEM, "out of memory in markclip"); |
| 357 |
+ |
setunion(antimodlist, oldset, set2add); |
| 358 |
+ |
free((void *)oldset); |
| 359 |
+ |
} |
| 360 |
+ |
|
| 361 |
+ |
|
| 362 |
+ |
#else /* SHADCACHE */ |
| 363 |
+ |
|
| 364 |
+ |
|
| 365 |
+ |
void /* no-op also avoids linker warning */ |
| 366 |
+ |
markclip(OBJREC *m) |
| 367 |
+ |
{ |
| 368 |
+ |
(void)m; |
| 369 |
|
} |
| 370 |
|
|
| 371 |
|
|