| 49 |
|
int |
| 50 |
|
newsource() /* allocate new source in our array */ |
| 51 |
|
{ |
| 52 |
+ |
#define SRCINC 4 |
| 53 |
|
if (nsources == 0) |
| 54 |
< |
source = (SRCREC *)malloc(sizeof(SRCREC)); |
| 55 |
< |
else |
| 54 |
> |
source = (SRCREC *)malloc(SRCINC*sizeof(SRCREC)); |
| 55 |
> |
else if (nsources%SRCINC == 0) |
| 56 |
|
source = (SRCREC *)realloc((char *)source, |
| 57 |
< |
(unsigned)(nsources+1)*sizeof(SRCREC)); |
| 57 |
> |
(unsigned)(nsources+SRCINC)*sizeof(SRCREC)); |
| 58 |
|
if (source == NULL) |
| 59 |
|
return(-1); |
| 60 |
|
source[nsources].sflags = 0; |
| 61 |
|
source[nsources].nhits = 1; |
| 62 |
|
source[nsources].ntests = 2; /* initial hit probability = 1/2 */ |
| 63 |
|
return(nsources++); |
| 64 |
+ |
#undef SRCINC |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 394 |
|
first = 0; last = nsources-1; |
| 395 |
|
} |
| 396 |
|
for (i = first; i <= last; i++) |
| 397 |
< |
if (source[i].sflags & SDISTANT) |
| 397 |
> |
if ((source[i].sflags & (SDISTANT|SVIRTUAL)) == SDISTANT) |
| 398 |
|
/* |
| 399 |
|
* Check to see if ray is within |
| 400 |
|
* solid angle of source. |
| 417 |
|
} |
| 418 |
|
|
| 419 |
|
|
| 420 |
< |
#define wrongsource(m, r) (m->otype!=MAT_ILLUM && \ |
| 421 |
< |
r->rsrc>=0 && \ |
| 422 |
< |
source[r->rsrc].so!=r->ro) |
| 420 |
> |
#define wrongsource(m, r) (r->rsrc>=0 && \ |
| 421 |
> |
source[r->rsrc].so!=r->ro && \ |
| 422 |
> |
(m->otype!=MAT_ILLUM || \ |
| 423 |
> |
objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM)) |
| 424 |
|
|
| 425 |
+ |
#define distglow(m, r) (m->otype==MAT_GLOW && \ |
| 426 |
+ |
r->rot > m->oargs.farg[3]) |
| 427 |
+ |
|
| 428 |
|
#define badambient(m, r) ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \ |
| 429 |
< |
!(m->otype==MAT_GLOW&&r->rot>m->oargs.farg[3])) |
| 429 |
> |
!distglow(m, r)) |
| 430 |
|
|
| 431 |
|
#define passillum(m, r) (m->otype==MAT_ILLUM && \ |
| 432 |
|
!(r->rsrc>=0&&source[r->rsrc].so==r->ro)) |
| 433 |
|
|
| 434 |
+ |
#define srcignore(m, r) (directinvis && !(r->crtype&SHADOW) && \ |
| 435 |
+ |
!distglow(m, r)) |
| 436 |
|
|
| 437 |
+ |
|
| 438 |
|
m_light(m, r) /* ray hit a light source */ |
| 439 |
|
register OBJREC *m; |
| 440 |
|
register RAY *r; |
| 444 |
|
return; |
| 445 |
|
/* check for passed illum */ |
| 446 |
|
if (passillum(m, r)) { |
| 438 |
– |
|
| 447 |
|
if (m->oargs.nsargs < 1 || !strcmp(m->oargs.sarg[0], VOIDID)) |
| 448 |
|
raytrans(r); |
| 449 |
|
else |
| 450 |
|
rayshade(r, modifier(m->oargs.sarg[0])); |
| 451 |
< |
|
| 452 |
< |
/* otherwise treat as source */ |
| 453 |
< |
} else { |
| 451 |
> |
return; |
| 452 |
> |
} |
| 453 |
> |
/* otherwise treat as source */ |
| 454 |
|
/* check for behind */ |
| 455 |
< |
if (r->rod < 0.0) |
| 456 |
< |
return; |
| 455 |
> |
if (r->rod < 0.0) |
| 456 |
> |
return; |
| 457 |
> |
/* check for invisibility */ |
| 458 |
> |
if (srcignore(m, r)) |
| 459 |
> |
return; |
| 460 |
|
/* get distribution pattern */ |
| 461 |
< |
raytexture(r, m->omod); |
| 461 |
> |
raytexture(r, m->omod); |
| 462 |
|
/* get source color */ |
| 463 |
< |
setcolor(r->rcol, m->oargs.farg[0], |
| 464 |
< |
m->oargs.farg[1], |
| 465 |
< |
m->oargs.farg[2]); |
| 463 |
> |
setcolor(r->rcol, m->oargs.farg[0], |
| 464 |
> |
m->oargs.farg[1], |
| 465 |
> |
m->oargs.farg[2]); |
| 466 |
|
/* modify value */ |
| 467 |
< |
multcolor(r->rcol, r->pcol); |
| 457 |
< |
} |
| 467 |
> |
multcolor(r->rcol, r->pcol); |
| 468 |
|
} |