--- ray/src/rt/source.c 1991/07/11 16:39:03 1.39 +++ ray/src/rt/source.c 1991/08/12 08:20:49 1.42 @@ -1,4 +1,4 @@ -/* Copyright (c) 1990 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -128,14 +128,6 @@ register int sn; /* source number */ sr->rsrc = sn; /* remember source */ /* get source direction */ if (source[sn].sflags & SDISTANT) { - if (source[sn].sflags & SSPOT) { /* check location */ - for (i = 0; i < 3; i++) - vd[i] = sr->rorg[i] - source[sn].sl.s->aim[i]; - d = DOT(source[sn].sloc,vd); - d = DOT(vd,vd) - d*d; - if (PI*d > source[sn].sl.s->siz) - return(0.0); - } /* constant direction */ VCOPY(sr->rdir, source[sn].sloc); } else { /* compute direction */ @@ -162,19 +154,29 @@ register int sn; /* source number */ } for (i = 0; i < 3; i++) /* offset source direction */ sr->rdir[i] += vd[i]; + /* normalize */ + d = normalize(sr->rdir); - } else if (source[sn].sflags & SDISTANT) - /* already normalized */ - return(source[sn].ss2); + } else if (!(source[sn].sflags & SDISTANT)) + /* normalize direction */ + d = normalize(sr->rdir); - if ((d = normalize(sr->rdir)) == 0.0) - /* at source! */ + if (source[sn].sflags & SDISTANT) { + if (source[sn].sflags & SSPOT) { /* check location */ + for (i = 0; i < 3; i++) + vd[i] = source[sn].sl.s->aim[i] - sr->rorg[i]; + d = DOT(sr->rdir,vd); + if (d <= FTINY) + return(0.0); + d = DOT(vd,vd) - d*d; + if (PI*d > source[sn].sl.s->siz) + return(0.0); + } + return(source[sn].ss2); /* domega constant */ + } + /* check direction */ + if (d == 0.0) return(0.0); - - if (source[sn].sflags & SDISTANT) - /* domega constant */ - return(source[sn].ss2); - /* check proximity */ if (source[sn].sflags & SPROX && d > source[sn].sl.prox) @@ -245,6 +247,7 @@ RAY *r; /* ray that hit surface */ int (*f)(); /* direct component coefficient function */ char *p; /* data for f */ { + extern int (*trace)(); extern double pow(); register int sn; int nshadcheck, ncnts; @@ -314,6 +317,8 @@ char *p; /* data for f */ source[cntord[sn].sno].sflags & SFOLLOW )) { /* follow entire path */ raycont(&sr); + if (trace != NULL) + (*trace)(&sr); /* trace execution */ if (bright(sr.rcol) <= FTINY) continue; /* missed! */ copycolor(srccnt[cntord[sn].sno].val, sr.rcol);