--- ray/src/rt/virtuals.c 1991/07/16 15:56:51 1.17 +++ ray/src/rt/virtuals.c 1991/08/05 09:02:42 1.21 @@ -44,8 +44,10 @@ markvirtuals() /* find and mark virtual sources */ if (!isvlight(objptr(o->omod)->otype)) continue; if (sfun[o->otype].of == NULL || - sfun[o->otype].of->getpleq == NULL) - objerror(o, USER, "illegal material"); + sfun[o->otype].of->getpleq == NULL) { + objerror(o,WARNING,"secondary sources not supported"); + continue; + } if (nvobjects == 0) vobject = (OBJECT *)malloc(sizeof(OBJECT)); else @@ -140,8 +142,11 @@ MAT4 pm; ourspot.siz = PI*maxrad2; ourspot.flen = 0.; if (source[sn].sflags & SSPOT) { - copystruct(&theirspot, source[sn].sl.s); multp3(theirspot.aim, source[sn].sl.s->aim, pm); + d = sqrt(dist2(ourspot.aim, theirspot.aim)); + d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].ss; + theirspot.siz = PI*d*d; + ourspot.flen = theirspot.flen = source[sn].sl.s->flen; d = ourspot.siz; if (!commonbeam(&ourspot, &theirspot, nsloc)) return(-1); /* no overlap */ @@ -164,8 +169,9 @@ MAT4 pm; if (source[sn].sflags & SPROX && d > source[sn].sl.prox) return(-1); /* too far away */ ourspot.flen = 0.; - if (d*d > maxrad2) - ourspot.siz = 2.*PI*(1. - sqrt(1.-maxrad2/(d*d))); + d = (sqrt(maxrad2) + source[sn].ss) / d; + if (d < 1.-FTINY) + ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d)); else nsflags &= ~SSPOT; if (source[sn].sflags & SSPOT) { @@ -195,7 +201,7 @@ MAT4 pm; if (source[sn].sflags & SFLAT) { /* behind source? */ multv3(nsnorm, source[sn].snorm, pm); normalize(nsnorm); - if (!checkspot(&ourspot, nsnorm)) + if (nsflags & SSPOT && !checkspot(&ourspot, nsnorm)) return(-1); } } @@ -287,7 +293,11 @@ register int sn; /* target source number */ } else { for (i = 0; i < 3; i++) offsdir[i] = source[sn].sloc[i] - oc[i]; - n = or2/DOT(offsdir,offsdir)*vspretest + .5; + d = DOT(offsdir,offsdir); + if (d <= FTINY) + n = 2.*PI * vspretest + .5; + else + n = 2.*PI * (1.-sqrt(1./(1.+or2/d)))*vspretest + .5; infront = DOT(onorm, offsdir) > 0.; } if (n < MINSAMPLES) n = MINSAMPLES; @@ -338,7 +348,8 @@ register int sn; /* target source number */ continue; nok++; /* check against obstructions */ - srcray(&sr, NULL, sn); + rayclear(&sr); + sr.revf = raytrace; rayvalue(&sr); if (bright(sr.rcol) > FTINY) nhit++;