--- ray/src/rt/srcsupp.c 1991/07/16 15:56:48 1.9 +++ ray/src/rt/srcsupp.c 1991/09/13 13:44:10 1.13 @@ -49,17 +49,19 @@ initstypes() /* initialize source dispatch table */ int newsource() /* allocate new source in our array */ { +#define SRCINC 4 if (nsources == 0) - source = (SRCREC *)malloc(sizeof(SRCREC)); - else + source = (SRCREC *)malloc(SRCINC*sizeof(SRCREC)); + else if (nsources%SRCINC == 0) source = (SRCREC *)realloc((char *)source, - (unsigned)(nsources+1)*sizeof(SRCREC)); + (unsigned)(nsources+SRCINC)*sizeof(SRCREC)); if (source == NULL) return(-1); source[nsources].sflags = 0; source[nsources].nhits = 1; source[nsources].ntests = 2; /* initial hit probability = 1/2 */ return(nsources++); +#undef SRCINC } @@ -392,7 +394,7 @@ register RAY *r; first = 0; last = nsources-1; } for (i = first; i <= last; i++) - if (source[i].sflags & SDISTANT) + if ((source[i].sflags & (SDISTANT|SVIRTUAL)) == SDISTANT) /* * Check to see if ray is within * solid angle of source. @@ -415,17 +417,24 @@ register RAY *r; } -#define wrongsource(m, r) (m->otype!=MAT_ILLUM && \ - r->rsrc>=0 && \ - source[r->rsrc].so!=r->ro) +#define wrongsource(m, r) (r->rsrc>=0 && \ + source[r->rsrc].so!=r->ro && \ + (m->otype!=MAT_ILLUM || \ + objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM)) +#define distglow(m, r) (m->otype==MAT_GLOW && \ + r->rot > m->oargs.farg[3]) + #define badambient(m, r) ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \ - !(m->otype==MAT_GLOW&&r->rot>m->oargs.farg[3])) + !distglow(m, r)) #define passillum(m, r) (m->otype==MAT_ILLUM && \ !(r->rsrc>=0&&source[r->rsrc].so==r->ro)) +#define srcignore(m, r) (directinvis && !(r->crtype&SHADOW) && \ + !distglow(m, r)) + m_light(m, r) /* ray hit a light source */ register OBJREC *m; register RAY *r; @@ -435,24 +444,25 @@ register RAY *r; return; /* check for passed illum */ if (passillum(m, r)) { - if (m->oargs.nsargs < 1 || !strcmp(m->oargs.sarg[0], VOIDID)) raytrans(r); else rayshade(r, modifier(m->oargs.sarg[0])); - - /* otherwise treat as source */ - } else { + return; + } + /* otherwise treat as source */ /* check for behind */ - if (r->rod < 0.0) - return; + if (r->rod < 0.0) + return; + /* check for invisibility */ + if (srcignore(m, r)) + return; /* get distribution pattern */ - raytexture(r, m->omod); + raytexture(r, m->omod); /* get source color */ - setcolor(r->rcol, m->oargs.farg[0], - m->oargs.farg[1], - m->oargs.farg[2]); + setcolor(r->rcol, m->oargs.farg[0], + m->oargs.farg[1], + m->oargs.farg[2]); /* modify value */ - multcolor(r->rcol, r->pcol); - } + multcolor(r->rcol, r->pcol); }