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

Comparing ray/src/rt/source.c (file contents):
Revision 1.12 by greg, Tue Jun 13 10:57:52 1989 UTC vs.
Revision 1.22 by greg, Tue Nov 13 14:32:30 1990 UTC

# Line 310 | Line 310 | char  *p;                      /* data for f */
310          double  prob, ourthresh, hwt, test2, hit2;
311          RAY  sr;
312  
313 +        if (nsources <= 0)
314 +                return;
315          srccnt = (CONTRIB *)malloc(nsources*sizeof(CONTRIB));
316          cntord = (CNTPTR *)malloc(nsources*sizeof(CNTPTR));
317          if (srccnt == NULL || cntord == NULL)
# Line 329 | Line 331 | char  *p;                      /* data for f */
331                                                  /* compute coefficient */
332                  (*f)(srccnt[sn].val, p, srccnt[sn].dir, srccnt[sn].dom);
333                  cntord[sn].brt = bright(srccnt[sn].val);
334 <                if (cntord[sn].brt <= FTINY)
334 >                if (cntord[sn].brt <= 0.0)
335                          continue;
336                                                  /* compute intersection */
337                  if (!( source[sn].sflags & SDISTANT ?
# Line 338 | Line 340 | char  *p;                      /* data for f */
340                                  (source[sn].so, &sr) ))
341                          continue;
342                                                  /* compute contribution */
343 <                rayshade(&sr, sr.ro->omod);
343 >                raycont(&sr);
344                  multcolor(srccnt[sn].val, sr.rcol);
345                  cntord[sn].brt = bright(srccnt[sn].val);
346          }
347                                                  /* sort contributions */
348          qsort(cntord, nsources, sizeof(CNTPTR), cntcmp);
349 <                                                /* find last */
350 <        sn = 0; ncnts = nsources;
351 <        while (sn < ncnts-1) {
352 <                register int  m;
353 <                m = (sn + ncnts) >> 1;
354 <                if (cntord[m].brt > 0.0)
355 <                        sn = m;
356 <                else
357 <                        ncnts = m;
358 <        }
349 >        {                                       /* find last */
350 >                register int  l, m;
351 >
352 >                sn = 0; ncnts = l = nsources;
353 >                while ((m = (sn + ncnts) >> 1) != l) {
354 >                        if (cntord[m].brt > 0.0)
355 >                                sn = m;
356 >                        else
357 >                                ncnts = m;
358 >                        l = m;
359 >                }
360 >        }
361                                                  /* accumulate tail */
362          for (sn = ncnts-1; sn > 0; sn--)
363                  cntord[sn-1].brt += cntord[sn].brt;
# Line 374 | Line 378 | char  *p;                      /* data for f */
378                                                  /* test for hit */
379                  rayorigin(&sr, r, SHADOW, 1.0);
380                  VCOPY(sr.rdir, srccnt[cntord[sn].sno].dir);
381 +                sr.rsrc = cntord[sn].sno;
382                  if (localhit(&sr, &thescene) &&
383                                  sr.ro != source[cntord[sn].sno].so) {
384                                                  /* check for transmission */
385 <                        if (sr.clipset != NULL && inset(sr.clipset,sr.ro->omod))
381 <                                raytrans(&sr);          /* object is clipped */
382 <                        else
383 <                                rayshade(&sr, sr.ro->omod);
385 >                        raycont(&sr);
386                          if (bright(sr.rcol) <= FTINY)
387                                  continue;       /* missed! */
388                          (*f)(srccnt[cntord[sn].sno].val, p,
# Line 429 | Line 431 | m_light(m, r)                  /* ray hit a light source */
431   register OBJREC  *m;
432   register RAY  *r;
433   {
432                                                /* check for behind */
433        if (r->rod < 0.0)
434                return;
434                                                  /* check for over-counting */
435          if (wrongsource(m, r) || badambient(m, r))
436                  return;
# Line 445 | Line 444 | register RAY  *r;
444  
445                                                  /* otherwise treat as source */
446          } else {
447 +                                                /* check for behind */
448 +                if (r->rod < 0.0)
449 +                        return;
450                                                  /* get distribution pattern */
451                  raytexture(r, m->omod);
452                                                  /* get source color */
# Line 453 | Line 455 | register RAY  *r;
455                                    m->oargs.farg[2]);
456                                                  /* modify value */
457                  multcolor(r->rcol, r->pcol);
458 +                                                /* assign distance */
459 +                r->rt = r->rot;
460          }
461   }
462  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines