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 2.32 by greg, Wed Apr 23 00:52:34 2003 UTC vs.
Revision 2.37 by greg, Fri Sep 12 22:35:54 2003 UTC

# Line 54 | Line 54 | marksources()                  /* find and mark source objects */
54                                          /* initialize dispatch table */
55          initstypes();
56                                          /* find direct sources */
57 <        for (i = 0; i < nobjects; i++) {
57 >        for (i = 0; i < nsceneobjs; i++) {
58          
59                  o = objptr(i);
60  
61                  if (!issurface(o->otype) || o->omod == OVOID)
62                          continue;
63 <
63 >                                        /* find material */
64                  m = objptr(o->omod);
65 <
66 <                if (!islight(m->otype))
67 <                        continue;
65 >                while (!ismaterial(m->otype))
66 >                        if (ismixture(m->otype) || m->omod == OVOID) {
67 >                                m = NULL;
68 >                                break;
69 >                        } else
70 >                                m = objptr(m->omod);
71 >                if (m == NULL || !islight(m->otype))
72 >                        continue;       /* not source modifier */
73          
74                  if (m->oargs.nfargs != (m->otype == MAT_GLOW ? 4 :
75                                  m->otype == MAT_SPOT ? 7 : 3))
# Line 115 | Line 120 | marksources()                  /* find and mark source objects */
120          maxcntr = nsources + MAXSPART;  /* start with this many */
121          srccnt = (CONTRIB *)malloc(maxcntr*sizeof(CONTRIB));
122          cntord = (CNTPTR *)malloc(maxcntr*sizeof(CNTPTR));
123 <        if (srccnt == NULL | cntord == NULL)
123 >        if ((srccnt == NULL) | (cntord == NULL))
124                  goto memerr;
125          return;
126   memerr:
# Line 297 | Line 302 | char  *p;                      /* data for f */
302                                          maxcntr*sizeof(CONTRIB));
303                          cntord = (CNTPTR *)realloc((void *)cntord,
304                                          maxcntr*sizeof(CNTPTR));
305 <                        if (srccnt == NULL | cntord == NULL)
305 >                        if ((srccnt == NULL) | (cntord == NULL))
306                                  error(SYSTEM, "out of memory in direct");
307                  }
308                  cntord[sn].sndx = sn;
# Line 355 | Line 360 | char  *p;                      /* data for f */
360                  rayorigin(&sr, r, SHADOW, 1.0);
361                  VCOPY(sr.rdir, scp->dir);
362                  sr.rsrc = scp->sno;
363 <                source[scp->sno].ntests++;      /* keep statistics */
363 >                                                /* keep statistics */
364 >                if (source[scp->sno].ntests++ > 0xfffffff0) {
365 >                        source[scp->sno].ntests >>= 1;
366 >                        source[scp->sno].nhits >>= 1;
367 >                }
368                  if (localhit(&sr, &thescene) &&
369                                  ( sr.ro != source[scp->sno].so ||
370                                  source[scp->sno].sflags & SFOLLOW )) {
# Line 487 | Line 496 | register RAY  *r;
496   * geometry behind (or inside) an effective radiator.
497   */
498  
499 < static int weaksrcmod(obj) int obj;     /* efficiency booster function */
500 < {register OBJREC *o = objptr(obj);
501 < return(o->otype==MAT_ILLUM|o->otype==MAT_GLOW);}
499 > static int
500 > weaksrcmat(int obj)             /* identify material */
501 > {
502 >        register OBJREC *o = objptr(obj);
503 >        
504 >        while (!ismaterial(o->otype))   /* find material */
505 >                o = objptr(o->omod);
506 >        return((o->otype==MAT_ILLUM)|(o->otype==MAT_GLOW));
507 > }
508  
509   #define  illumblock(m, r)       (!(source[r->rsrc].sflags&SVIRTUAL) && \
510                                  r->rod > 0.0 && \
511 <                                weaksrcmod(source[r->rsrc].so->omod))
511 >                                weaksrcmat(source[r->rsrc].so->omod))
512  
513   /* wrongsource *
514   *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines