--- ray/src/rt/virtuals.c 1991/10/22 11:23:51 1.29 +++ ray/src/rt/virtuals.c 1994/12/20 20:18:43 2.3 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1994 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -41,7 +41,7 @@ markvirtuals() /* find and mark virtual sources */ o = objptr(i); if (!issurface(o->otype) || o->omod == OVOID) continue; - if (!isvlight(objptr(o->omod)->otype)) + if (!isvlight(vsmaterial(o)->otype)) continue; if (sfun[o->otype].of == NULL || sfun[o->otype].of->getpleq == NULL) { @@ -101,7 +101,7 @@ int n; if (o == source[sn].so) /* objects cannot project themselves */ return; /* get virtual source material */ - vsmat = sfun[objptr(o->omod)->otype].mf; + vsmat = sfun[vsmaterial(o)->otype].mf; /* project virtual sources */ for (i = 0; i < vsmat->nproj; i++) if ((*vsmat->vproj)(proj, o, &source[sn], i)) @@ -115,6 +115,23 @@ int n; } +OBJREC * +vsmaterial(o) /* get virtual source material pointer */ +OBJREC *o; +{ + register int i; + register OBJREC *m; + + i = o->omod; + m = objptr(i); + if (m->otype != MAT_ILLUM || m->oargs.nsargs < 1 || + !strcmp(m->oargs.sarg[0], VOIDID) || + (i = modifier(m->oargs.sarg[0])) == OVOID) + return(m); /* direct modifier */ + return(objptr(i)); /* illum alternate */ +} + + int makevsrc(op, sn, pm) /* make virtual source if reasonable */ OBJREC *op; @@ -334,6 +351,7 @@ register int sn; /* target source number */ for (i = 0; i < 3; i++) sr.rorg[i] = oc[i] + offsdir[i]; d = DOT(offsdir,onorm); + sr.rmax = 0.0; if (infront) for (i = 0; i < 3; i++) { sr.rorg[i] -= (d-.0001)*onorm[i]; @@ -349,7 +367,7 @@ register int sn; /* target source number */ /* check against source */ initsrcindex(&si); si.sn = sn; - nopart(&si, sr.rorg); + nopart(&si, &sr); samplendx++; if (!srcray(&sr, NULL, &si) || sr.rsrc != sn) continue;