ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/virtuals.c
(Generate patch)

Comparing ray/src/rt/virtuals.c (file contents):
Revision 1.1 by greg, Wed Jun 19 16:36:14 1991 UTC vs.
Revision 1.7 by greg, Mon Jun 24 16:10:59 1991 UTC

# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11  
12   #include  "ray.h"
13  
14 < #include  "source.h"
14 > #include  "octree.h"
15  
16   #include  "otypes.h"
17  
18 < #include  "cone.h"
18 > #include  "source.h"
19  
20 < #include  "face.h"
20 > #include  "random.h"
21  
22 extern int  directrelay;                /* maximum number of source relays */
22  
23 < double  getplaneq();
25 < double  getmaxdisk();
26 < double  intercircle();
27 < SRCREC  *makevsrc();
23 > #define  DISKTFRAC      0.25            /* disk area pretest fraction */
24  
25 + double  getdisk();
26 +
27   static OBJECT  *vobject;                /* virtual source objects */
28   static int  nvobjects = 0;              /* number of virtual source objects */
29  
# Line 40 | Line 38 | markvirtuals()                 /* find and mark virtual sources */
38                                          /* find virtual source objects */
39          for (i = 0; i < nobjects; i++) {
40                  o = objptr(i);
41 <                if (o->omod == OVOID)
41 >                if (!issurface(o->otype) || o->omod == OVOID)
42                          continue;
43                  if (!isvlight(objptr(o->omod)->otype))
44                          continue;
45 +                if (sfun[o->otype].of == NULL ||
46 +                                sfun[o->otype].of->getpleq == NULL)
47 +                        objerror(o, USER, "illegal material");
48                  if (nvobjects == 0)
49                          vobject = (OBJECT *)malloc(sizeof(OBJECT));
50                  else
# Line 55 | Line 56 | markvirtuals()                 /* find and mark virtual sources */
56          }
57          if (nvobjects == 0)
58                  return;
59 + #ifdef DEBUG
60 +        fprintf(stderr, "found %d virtual source objects\n", nvobjects);
61 + #endif
62                                          /* append virtual sources */
63          for (i = nsources; i-- > 0; )
64 <                if (!(source[i].sflags & SSKIP))
61 <                        addvirtuals(&source[i], directrelay);
64 >                addvirtuals(i, directrelay);
65                                          /* done with our object list */
66          free((char *)vobject);
67          nvobjects = 0;
68   }
69  
70  
71 < addvirtuals(sr, nr)             /* add virtual sources associated with sr */
72 < SRCREC  *sr;
71 > addvirtuals(sn, nr)             /* add virtuals associated with source */
72 > int  sn;
73   int  nr;
74   {
75          register int  i;
76                                  /* check relay limit first */
77          if (nr <= 0)
78                  return;
79 +        if (source[sn].sflags & SSKIP)
80 +                return;
81                                  /* check each virtual object for projection */
82          for (i = 0; i < nvobjects; i++)
83 <                vproject(objptr(i), sr, nr-1);  /* calls us recursively */
83 >                                        /* vproject() calls us recursively */
84 >                vproject(objptr(vobject[i]), sn, nr-1);
85   }
86  
87  
88 < SRCREC *
89 < makevsrc(op, sp, pm)            /* make virtual source if reasonable */
88 > vproject(o, sn, n)              /* create projected source(s) if they exist */
89 > OBJREC  *o;
90 > int  sn;
91 > int  n;
92 > {
93 >        register int  i;
94 >        register VSMATERIAL  *vsmat;
95 >        MAT4  proj;
96 >        int  ns;
97 >
98 >        if (o == source[sn].so) /* objects cannot project themselves */
99 >                return;
100 >                                /* get virtual source material */
101 >        vsmat = sfun[objptr(o->omod)->otype].mf;
102 >                                /* project virtual sources */
103 >        for (i = 0; i < vsmat->nproj; i++)
104 >                if ((*vsmat->vproj)(proj, o, &source[sn], i))
105 >                        if ((ns = makevsrc(o, sn, proj)) >= 0) {
106 > #ifdef DEBUG
107 >                                virtverb(ns, stderr);
108 > #endif
109 >                                addvirtuals(ns, n);
110 >                        }
111 > }
112 >
113 >
114 > int
115 > makevsrc(op, sn, pm)            /* make virtual source if reasonable */
116   OBJREC  *op;
117 < register SRCREC  *sp;
117 > register int  sn;
118   MAT4  pm;
119   {
120 <        register SRCREC  *newsrc;
89 <        FVECT  nsloc, ocent, nsnorm;
120 >        FVECT  nsloc, nsnorm, ocent;
121          double  maxrad2;
122 <        double  d1, d2;
122 >        int  nsflags;
123 >        double  d1;
124          SPOT  theirspot, ourspot;
125          register int  i;
126 +
127 +        nsflags = source[sn].sflags | (SVIRTUAL|SSPOT|SFOLLOW);
128                                          /* get object center and max. radius */
129 <        maxrad2 = getmaxdisk(ocent, op);
129 >        maxrad2 = getdisk(ocent, op, sn);
130          if (maxrad2 <= FTINY)                   /* too small? */
131 <                return(NULL);
131 >                return(-1);
132                                          /* get location and spot */
133 <        if (sp->sflags & SDISTANT) {            /* distant source */
134 <                if (sp->sflags & SPROX)
135 <                        return(NULL);           /* should never get here! */
136 <                multv3(nsloc, sp->sloc, pm);
133 >        if (source[sn].sflags & SDISTANT) {             /* distant source */
134 >                if (source[sn].sflags & SPROX)
135 >                        return(-1);             /* should never get here! */
136 >                multv3(nsloc, source[sn].sloc, pm);
137                  VCOPY(ourspot.aim, ocent);
138                  ourspot.siz = PI*maxrad2;
139                  ourspot.flen = 0.;
140 <                if (sp->sflags & SSPOT) {
141 <                        copystruct(&theirspot, sp->sl.s);
142 <                        multp3(theirspot.aim, sp->sl.s->aim, pm);
140 >                if (source[sn].sflags & SSPOT) {
141 >                        copystruct(&theirspot, source[sn].sl.s);
142 >                        multp3(theirspot.aim, source[sn].sl.s->aim, pm);
143                          if (!commonbeam(&ourspot, &theirspot, nsloc))
144 <                                return(NULL);           /* no overlap */
144 >                                return(-1);             /* no overlap */
145                  }
146          } else {                                /* local source */
147 <                multp3(nsloc, sp->sloc, pm);
114 <                if (sp->sflags & SPROX) {
115 <                        d2 = 0.;
116 <                        for (i = 0; i < 3; i++) {
117 <                                d1 = ocent[i] - nsloc[i];
118 <                                d2 += d1*d1;
119 <                        }
120 <                        if (d2 > sp->sl.prox*sp->sl.prox)
121 <                                return(NULL);   /* too far away */
122 <                }
147 >                multp3(nsloc, source[sn].sloc, pm);
148                  for (i = 0; i < 3; i++)
149                          ourspot.aim[i] = ocent[i] - nsloc[i];
150                  if ((d1 = normalize(ourspot.aim)) == 0.)
151 <                        return(NULL);           /* at source!! */
151 >                        return(-1);             /* at source!! */
152 >                if (source[sn].sflags & SPROX && d1 > source[sn].sl.prox)
153 >                        return(-1);             /* too far away */
154                  ourspot.siz = 2.*PI*(1. - d1/sqrt(d1*d1+maxrad2));
155                  ourspot.flen = 0.;
156 <                if (sp->sflags & SSPOT) {
157 <                        copystruct(&theirspot, sp->sl.s);
158 <                        multv3(theirspot.aim, sp->sl.s->aim, pm);
156 >                if (source[sn].sflags & SSPOT) {
157 >                        copystruct(&theirspot, source[sn].sl.s);
158 >                        multv3(theirspot.aim, source[sn].sl.s->aim, pm);
159                          if (!commonspot(&ourspot, &theirspot, nsloc))
160 <                                return(NULL);           /* no overlap */
160 >                                return(-1);     /* no overlap */
161                          ourspot.flen = theirspot.flen;
162                  }
163 <                if (sp->sflags & SFLAT) {       /* check for behind source */
164 <                        multv3(nsnorm, sp->snorm, pm);
163 >                if (source[sn].sflags & SFLAT) {        /* behind source? */
164 >                        multv3(nsnorm, source[sn].snorm, pm);
165                          if (checkspot(&ourspot, nsnorm) < 0)
166 <                                return(NULL);
166 >                                return(-1);
167                  }
168          }
169 <                                        /* everything is OK, make source */
170 <        if ((newsrc = newsource()) == NULL)
169 >                                        /* pretest visibility */
170 >        nsflags = vstestvis(nsflags, op, ocent, maxrad2, sn);
171 >        if (nsflags & SSKIP)
172 >                return(-1);     /* obstructed */
173 >                                        /* it all checks out, so make it */
174 >        if ((i = newsource()) < 0)
175                  goto memerr;
176 <        newsrc->sflags = sp->sflags | (SVIRTUAL|SSPOT|SFOLLOW);
177 <        VCOPY(newsrc->sloc, nsloc);
178 <        if (newsrc->sflags & SFLAT)
179 <                VCOPY(newsrc->snorm, nsnorm);
180 <        newsrc->ss = sp->ss; newsrc->ss2 = sp->ss2;
181 <        if ((newsrc->sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL)
176 >        source[i].sflags = nsflags;
177 >        VCOPY(source[i].sloc, nsloc);
178 >        if (nsflags & SFLAT)
179 >                VCOPY(source[i].snorm, nsnorm);
180 >        source[i].ss = source[sn].ss; source[i].ss2 = source[sn].ss2;
181 >        if ((source[i].sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL)
182                  goto memerr;
183 <        copystruct(newsrc->sl.s, &ourspot);
184 <        if (newsrc->sflags & SPROX)
185 <                newsrc->sl.prox = sp->sl.prox;
186 <        newsrc->sa.svnext = sp - source;
187 <        return(newsrc);
183 >        copystruct(source[i].sl.s, &ourspot);
184 >        if (nsflags & SPROX)
185 >                source[i].sl.prox = source[sn].sl.prox;
186 >        source[i].sa.svnext = sn;
187 >        source[i].so = op;
188 >        return(i);
189   memerr:
190          error(SYSTEM, "out of memory in makevsrc");
191   }
192  
193  
162 commonspot(sp1, sp2, org)       /* set sp1 to intersection of sp1 and sp2 */
163 register SPOT  *sp1, *sp2;
164 FVECT  org;
165 {
166        FVECT  cent;
167        double  rad2, d1r2, d2r2;
168
169        d1r2 = 1. - sp1->siz/(2.*PI);
170        d2r2 = 1. - sp2->siz/(2.*PI);
171        if (sp2->siz >= 2.*PI-FTINY)            /* BIG, just check overlap */
172                return(DOT(sp1->aim,sp2->aim) >= d1r2*d2r2 -
173                                        sqrt((1.-d1r2*d1r2)*(1.-d2r2*d2r2)));
174                                /* compute and check disks */
175        d1r2 = 1./(d1r2*d1r2) - 1.;
176        d2r2 = 1./(d2r2*d2r2) - 1.;
177        rad2 = intercircle(cent, sp1->aim, sp2->aim, d1r2, d2r2);
178        if (rad2 <= FTINY || normalize(cent) == 0.)
179                return(0);
180        VCOPY(sp1->aim, cent);
181        sp1->siz = 2.*PI*(1. - 1./sqrt(1.+rad2));
182        return(1);
183 }
184
185
186 commonbeam(sp1, sp2, dir)       /* set sp1 to intersection of sp1 and sp2 */
187 register SPOT  *sp1, *sp2;
188 FVECT  dir;
189 {
190        FVECT  cent, c1, c2;
191        double  rad2, d;
192        register int  i;
193                                        /* move centers to common plane */
194        d = DOT(sp1->aim, dir);
195        for (i = 0; i < 3; i++)
196                c1[i] = sp2->aim[i] - d*dir[i];
197        d = DOT(sp2->aim, dir);
198        for (i = 0; i < 3; i++)
199                c2[i] = sp2->aim[i] - d*dir[i];
200                                        /* compute overlap */
201        rad2 = intercircle(cent, c1, c2, sp1->siz/PI, sp2->siz/PI);
202        if (rad2 <= FTINY)
203                return(0);
204        VCOPY(sp1->aim, cent);
205        sp1->siz = PI*rad2;
206        return(1);
207 }
208
209
210 checkspot(sp, nrm)              /* check spotlight for behind source */
211 register SPOT  *sp;
212 FVECT  nrm;
213 {
214        double  d, d1;
215
216        d = DOT(sp->aim, nrm);
217        if (d > FTINY)                  /* center in front? */
218                return(0);
219                                        /* else check horizon */
220        d1 = 1. - sp->siz/(2.*PI);
221        return(1.-FTINY-d*d > d1*d1);
222 }
223
224
225 mirrorproj(m, nv, offs)         /* get mirror projection for surface */
226 register MAT4  m;
227 FVECT  nv;
228 double  offs;
229 {
230        register int  i, j;
231                                        /* assign matrix */
232        setident4(m);
233        for (i = 0; i < 3; i++)
234                for (j = 0; j < 3; j++)
235                        m[i][j] -= 2.*nv[i]*nv[j];
236        for (j = 0; j < 3; j++)
237                m[3][j] = 2.*offs*nv[j];
238 }
239
240
194   double
195 < intercircle(cc, c1, c2, r1s, r2s)       /* intersect two circles */
196 < FVECT  cc;                      /* midpoint (return value) */
244 < FVECT  c1, c2;                  /* circle centers */
245 < double  r1s, r2s;               /* radii squared */
246 < {
247 <        double  a2, d2, l;
248 <        FVECT  disp;
249 <        register int  i;
250 <
251 <        for (i = 0; i < 3; i++)
252 <                disp[i] = c2[i] - c1[i];
253 <        d2 = DOT(disp,disp);
254 <                                        /* circle within overlap? */
255 <        if (r1s < r2s) {
256 <                if (r2s >= r1s + d2) {
257 <                        VCOPY(cc, c1);
258 <                        return(r1s);
259 <                }
260 <        } else {
261 <                if (r1s >= r2s + d2) {
262 <                        VCOPY(cc, c2);
263 <                        return(r2s);
264 <                }
265 <        }
266 <        a2 = .25*(2.*(r1s+r2s) - d2 - (r2s-r1s)*(r2s-r1s)/d2);
267 <                                        /* no overlap? */
268 <        if (a2 <= 0.)
269 <                return(0.);
270 <        l = sqrt((r1s - a2)/d2);
271 <        for (i = 0; i < 3; i++)
272 <                cc[i] = c1[i] + l*disp[i];
273 <        return(a2);
274 < }
275 <
276 <
277 < /*
278 < * The following routines depend on the supported OBJECTS:
279 < */
280 <
281 <
282 < double
283 < getmaxdisk(ocent, op)           /* get object center and squared radius */
284 < FVECT  ocent;
285 < register OBJREC  *op;
286 < {
287 <        double  maxrad2;
288 <
289 <        switch (op->otype) {
290 <        case OBJ_FACE:
291 <                {
292 <                        double  d1, d2;
293 <                        register int  i, j;
294 <                        register FACE  *f = getface(op);
295 <
296 <                        for (i = 0; i < 3; i++) {
297 <                                ocent[i] = 0.;
298 <                                for (j = 0; j < f->nv; j++)
299 <                                        ocent[i] += VERTEX(f,j)[i];
300 <                                ocent[i] /= (double)f->nv;
301 <                        }
302 <                        maxrad2 = 0.;
303 <                        for (j = 0; j < f->nv; j++) {
304 <                                d2 = 0.;
305 <                                for (i = 0; i < 3; i++) {
306 <                                        d1 = VERTEX(f,j)[i] - ocent[i];
307 <                                        d2 += d1*d1;
308 <                                }
309 <                                if (d2 > maxrad2)
310 <                                        maxrad2 = d2;
311 <                        }
312 <                }
313 <                return(maxrad2);
314 <        case OBJ_RING:
315 <                {
316 <                        register CONE  *co = getcone(op, 0);
317 <
318 <                        VCOPY(ocent, CO_P0(co));
319 <                        maxrad2 = CO_R1(co);
320 <                        maxrad2 *= maxrad2;
321 <                }
322 <                return(maxrad2);
323 <        }
324 <        objerror(op, USER, "illegal material");
325 < }
326 <
327 <
328 < double
329 < getplaneq(nvec, op)                     /* get plane equation for object */
330 < FVECT  nvec;
195 > getdisk(oc, op, sn)             /* get visible object disk */
196 > FVECT  oc;
197   OBJREC  *op;
198 + register int  sn;
199   {
200 <        register FACE  *fo;
201 <        register CONE  *co;
202 <
203 <        switch (op->otype) {
204 <        case OBJ_FACE:
205 <                fo = getface(op);
206 <                VCOPY(nvec, fo->norm);
207 <                return(fo->offset);
208 <        case OBJ_RING:
209 <                co = getcone(op, 0);
210 <                VCOPY(nvec, co->ad);
211 <                return(DOT(nvec, CO_P0(co)));
212 <        }
213 <        objerror(op, USER, "illegal material");
200 >        double  rad2, roffs, offs, d, rd, rdoto;
201 >        FVECT  rnrm, nrm;
202 >                                /* first, use object getdisk function */
203 >        rad2 = (*sfun[op->otype].of->getdisk)(oc, op);
204 >        if (!(source[sn].sflags & SVIRTUAL))
205 >                return(rad2);           /* all done for normal source */
206 >                                /* check for correct side of relay surface */
207 >        roffs = (*sfun[source[sn].so->otype].of->getpleq)(rnrm, source[sn].so);
208 >        rd = DOT(rnrm, source[sn].sloc);        /* source projection */
209 >        if (!(source[sn].sflags & SDISTANT))
210 >                rd -= roffs;
211 >        d = DOT(rnrm, oc) - roffs;      /* disk distance to relay plane */
212 >        if ((d > 0.) ^ (rd > 0.))
213 >                return(rad2);           /* OK if opposite sides */
214 >        if (d*d >= rad2)
215 >                return(.0);             /* no relay is possible */
216 >                                /* we need a closer look */
217 >        offs = (*sfun[op->otype].of->getpleq)(nrm, op);
218 >        rdoto = DOT(rnrm, nrm);
219 >        if (d*d >= rad2*(1.-rdoto*rdoto))
220 >                return(0.);             /* disk entirely on projection side */
221 >                                /* should shrink disk but I'm lazy */
222 >        return(rad2);
223   }
224  
225  
226 < /*
227 < * The following routines depend on the supported MATERIALS:
228 < */
229 <
230 <
231 < vproject(o, s, n)               /* create projected source(s) if they exist */
232 < OBJREC  *o;
357 < SRCREC  *s;
358 < int  n;
226 > int
227 > vstestvis(f, o, oc, or2, sn)            /* pretest source visibility */
228 > int  f;                 /* virtual source flags */
229 > OBJREC  *o;             /* relay object */
230 > FVECT  oc;              /* relay object center */
231 > double  or2;            /* relay object radius squared */
232 > register int  sn;       /* target source number */
233   {
234 <        SRCREC  *ns;
235 <        FVECT  norm;
236 <        double  offset;
237 <        MAT4  proj;
238 <                                /* get surface normal and offset */
239 <        offset = getplaneq(norm, o);
240 <        switch (objptr(o->omod)->otype) {
241 <        case MAT_MIRROR:                        /* mirror source */
242 <                if (DOT(s->sloc, norm) <= (s->sflags & SDISTANT ?
243 <                                        FTINY : offset+FTINY))
244 <                        return;                 /* behind mirror */
245 <                mirrorproj(proj, norm, offset);
246 <                if ((ns = makevsrc(o, s, proj)) != NULL)
247 <                        addvirtuals(ns, n);
248 <                break;
249 <        }
250 < }
251 <
252 <
253 < vsrcrelay(rn, rv)               /* relay virtual source ray */
254 < register RAY  *rn, *rv;
255 < {
256 <        int  snext;
257 <        register int  i;
258 <                                        /* source we're aiming for here */
259 <        snext = source[rv->rsrc].sa.svnext;
260 <                                        /* compute relayed ray direction */
387 <        switch (objptr(rv->ro->omod)->otype) {
388 <        case MAT_MIRROR:                /* mirror: singular reflection */
389 <                rayorigin(rn, rv, REFLECTED, 1.);
390 <                                        /* ignore textures */
234 >        RAY  sr;
235 >        FVECT  onorm;
236 >        FVECT  offsdir;
237 >        double  or, d;
238 >        int  nok, nhit;
239 >        register int  i, n;
240 >                                /* return if pretesting disabled */
241 >        if (vspretest <= 0)
242 >                return(f);
243 >                                /* get surface normal */
244 >        (*sfun[o->otype].of->getpleq)(onorm, o);
245 >                                /* set number of rays to sample */
246 >        if (source[sn].sflags & SDISTANT)
247 >                n = (2./3.*PI*PI)*or2/(thescene.cusize*thescene.cusize)*
248 >                                vspretest + .5;
249 >        else
250 >                n = or2/dist2(oc,source[sn].sloc)*vspretest + .5;
251 >        if (n < 1) n = 1;
252 >                                /* limit tests to central region */
253 >        or = DISKTFRAC*sqrt(or2);
254 >                                /* sample */
255 >        nhit = nok = 0;
256 >        while (n-- > 0) {
257 >                samplendx++;
258 >                /*
259 >                 * We're being real sloppy with our sample locations here.
260 >                 */
261                  for (i = 0; i < 3; i++)
262 <                        rn->rdir[i] = rv->rdir[i] + 2.*rv->rod*rv->ron[i];
263 <                break;
264 < #ifdef DEBUG
265 <        default:
266 <                error(CONSISTENCY, "inappropriate material in vsrcrelay");
267 < #endif
262 >                        offsdir[i] = or*(1. - 2.*urand(931*i+5821+n));
263 >                d = DOT(offsdir,onorm);
264 >                for (i = 0; i < 3; i++)
265 >                        sr.rorg[i] = oc[i] + (1.-d)*offsdir[i];
266 >                                        /* check against source */
267 >                if (srcray(&sr, NULL, sn) == 0.0)
268 >                        continue;
269 >                sr.revf = srcvalue;
270 >                rayvalue(&sr);
271 >                if (bright(sr.rcol) <= FTINY)
272 >                        continue;
273 >                nok++;
274 >                                        /* check against obstructions */
275 >                srcray(&sr, NULL, sn);
276 >                rayvalue(&sr);
277 >                if (bright(sr.rcol) <= FTINY)
278 >                        continue;
279 >                nhit++;
280          }
281 <        rn->rsrc = snext;
281 >                                /* interpret results */
282 >        if (nhit == 0)
283 >                return(f | SSKIP);      /* 0% hit rate:  totally occluded */
284 >        if (nhit == nok)
285 >                return(f & ~SFOLLOW);   /* 100% hit rate:  no occlusion */
286 >        return(f);              /* no comment */
287   }
288 +        
289  
290 <
291 < m_mirror(m, r)                  /* shade mirrored ray */
292 < register OBJREC  *m;
293 < register RAY  *r;
290 > #ifdef DEBUG
291 > virtverb(sn, fp)        /* print verbose description of virtual source */
292 > register int  sn;
293 > FILE  *fp;
294   {
407        COLOR  mcolor;
408        RAY  nr;
295          register int  i;
296  
297 <        if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1)
298 <                objerror(m, USER, "bad number of arguments");
299 <        if (r->rsrc >= 0) {                     /* aiming for somebody */
300 <                if (source[r->rsrc].so != r->ro)
301 <                        return;                         /* but not us */
302 <        } else if (m->oargs.nsargs > 0) {       /* else call substitute? */
303 <                rayshade(r, modifier(m->oargs.sarg[0]));
297 >        fprintf(fp, "%s virtual source %d in %s %s\n",
298 >                        source[sn].sflags & SDISTANT ? "distant" : "local",
299 >                        sn, ofun[source[sn].so->otype].funame,
300 >                        source[sn].so->oname);
301 >        fprintf(fp, "\tat (%f,%f,%f)\n",
302 >                source[sn].sloc[0], source[sn].sloc[1], source[sn].sloc[2]);
303 >        fprintf(fp, "\tlinked to source %d (%s)\n",
304 >                source[sn].sa.svnext, source[source[sn].sa.svnext].so->oname);
305 >        if (source[sn].sflags & SFOLLOW)
306 >                fprintf(fp, "\talways followed\n");
307 >        else
308 >                fprintf(fp, "\tnever followed\n");
309 >        if (!(source[sn].sflags & SSPOT))
310                  return;
311 <        }
312 <        if (r->rod < 0.)                        /* back is black */
313 <                return;
422 <                                        /* get modifiers */
423 <        raytexture(r, m->omod);
424 <                                        /* assign material color */
425 <        setcolor(mcolor, m->oargs.farg[0],
426 <                        m->oargs.farg[1],
427 <                        m->oargs.farg[2]);
428 <        multcolor(mcolor, r->pcol);
429 <                                        /* compute reflected ray */
430 <        if (r->rsrc >= 0)                       /* relayed light source */
431 <                vsrcrelay(&nr, r);
432 <        else {                                  /* ordinary reflection */
433 <                FVECT  pnorm;
434 <                double  pdot;
435 <
436 <                if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0)
437 <                        return;
438 <                pdot = raynormal(pnorm, r);     /* use textures */
439 <                for (i = 0; i < 3; i++)
440 <                        nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i];
441 <        }
442 <        rayvalue(&nr);
443 <        multcolor(nr.rcol, mcolor);
444 <        addcolor(r->rcol, nr.rcol);
311 >        fprintf(fp, "\twith spot aim (%f,%f,%f) and size %f\n",
312 >                        source[sn].sl.s->aim[0], source[sn].sl.s->aim[1],
313 >                        source[sn].sl.s->aim[2], source[sn].sl.s->siz);
314   }
315 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines