--- ray/src/rt/source.c 2020/12/17 03:30:37 2.74 +++ ray/src/rt/source.c 2021/11/24 19:08:51 2.77 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: source.c,v 2.74 2020/12/17 03:30:37 greg Exp $"; +static const char RCSid[] = "$Id: source.c,v 2.77 2021/11/24 19:08:51 greg Exp $"; #endif /* * source.c - routines dealing with illumination sources. @@ -60,7 +60,7 @@ marksources(void) /* find and mark source objects */ if (!issurface(o->otype) || o->omod == OVOID) continue; /* find material */ - m = findmaterial(objptr(o->omod)); + m = findmaterial(o); if (m == NULL) continue; if (m->otype == MAT_CLIP) { @@ -154,7 +154,7 @@ distantsources(void) /* only mark distant sources */ if ((o->otype != OBJ_SOURCE) | (o->omod == OVOID)) continue; /* find material */ - m = findmaterial(objptr(o->omod)); + m = findmaterial(o); if (m == NULL) continue; if (!islight(m->otype)) @@ -294,11 +294,10 @@ nomat: static int transillum( /* check if material is transparent illum */ - OBJECT obj + OBJREC *m ) { - OBJREC *m = findmaterial(objptr(obj)); - + m = findmaterial(m); if (m == NULL) return(1); if (m->otype != MAT_ILLUM) @@ -331,8 +330,8 @@ sourcehit( /* check to see if ray hit distant source */ if (2.*PI*(1. - DOT(source[i].sloc,r->rdir)) > source[i].ss2) continue; - /* is it the only possibility? */ - if (first == last) { + /* is it what we aimed for? */ + if (i == r->rsrc) { r->ro = source[i].so; break; } @@ -344,7 +343,7 @@ sourcehit( /* check to see if ray hit distant source glowsrc = i; continue; } - if (transillum(source[i].so->omod)) { + if (transillum(source[i].so)) { if (transrc < 0) transrc = i; continue; @@ -364,15 +363,9 @@ sourcehit( /* check to see if ray hit distant source return(0); /* nothing usable */ } /* - * Make assignments. + * Assign object index */ r->robj = objndx(r->ro); - for (i = 0; i < 3; i++) - r->ron[i] = -r->rdir[i]; - r->rod = 1.0; - r->pert[0] = r->pert[1] = r->pert[2] = 0.0; - r->uv[0] = r->uv[1] = 0.0; - r->rox = NULL; return(1); } @@ -670,17 +663,16 @@ srcscatter( /* compute source scattering into ray */ */ static int -weaksrcmat(OBJECT obj) /* identify material */ +weaksrcmat(OBJREC *m) /* identify material */ { - OBJREC *m = findmaterial(objptr(obj)); - + m = findmaterial(m); if (m == NULL) return(0); return((m->otype==MAT_ILLUM) | (m->otype==MAT_GLOW)); } #define illumblock(m, r) (!(source[r->rsrc].sflags&SVIRTUAL) && \ r->rod > 0.0 && \ - weaksrcmat(source[r->rsrc].so->omod)) + weaksrcmat(source[r->rsrc].so)) /* wrongsource * *