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

Comparing ray/src/rt/m_mirror.c (file contents):
Revision 2.16 by greg, Sat May 10 17:43:01 2014 UTC vs.
Revision 2.24 by greg, Thu May 29 16:42:28 2025 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include  "ray.h"
11   #include  "otypes.h"
12 + #include  "otspecial.h"
13   #include  "rtotypes.h"
14   #include  "source.h"
15  
# Line 35 | Line 36 | m_mirror(                      /* shade mirrored ray */
36          RAY  *r
37   )
38   {
39 <        COLOR  mcolor;
39 >        SCOLOR  mcolor;
40          RAY  nr;
41          int  rpure = 1;
42          int  i;
# Line 44 | Line 45 | m_mirror(                      /* shade mirrored ray */
45                  objerror(m, USER, "bad number of arguments");
46                                          /* check for substitute material */
47                                          /* but avoid double-counting */
48 <        if (m->oargs.nsargs > 0 && !(r->crtype & (AMBIENT|SPECULAR)) &&
48 >        if (m->oargs.nsargs > 0 &&
49                          (r->rsrc < 0 || source[r->rsrc].so != r->ro)) {
50 <                if (!strcmp(m->oargs.sarg[0], VOIDID)) {
51 <                        raytrans(r);
50 >                int     passOK = (r->rod < 0.) |
51 >                                        !(r->crtype & (AMBIENT|SPECULAR));
52 >                if (strcmp(m->oargs.sarg[0], VOIDID)) {
53 >                        OBJECT  altmod = lastmod(objndx(m), m->oargs.sarg[0]);
54 >                        OBJREC  *altmat;
55 >                        if (passOK)             /* no double-count hazard? */
56 >                                return(rayshade(r, altmod));
57 >                        if (altmod == OVOID ||  /* else check alternate type */
58 >                                        (altmat = findmaterial(objptr(altmod))) == NULL)
59 >                                return(0);
60 >                        if (istransp(altmat))   /* pass "transparent" materials */
61 >                                return(rayshade(r, altmod));
62 >                } else if (passOK) {
63 >                        raytrans(r);            /* "safe" void passage */
64                          return(1);
65                  }
53                return(rayshade(r, lastmod(objndx(m), m->oargs.sarg[0])));
66          }
67                                          /* check for bad source ray */
68          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
# Line 64 | Line 76 | m_mirror(                      /* shade mirrored ray */
76                                          /* get modifiers */
77          raytexture(r, m->omod);
78                                          /* assign material color */
79 <        setcolor(mcolor, m->oargs.farg[0],
79 >        setscolor(mcolor, m->oargs.farg[0],
80                          m->oargs.farg[1],
81                          m->oargs.farg[2]);
82 <        multcolor(mcolor, r->pcol);
82 >        smultscolor(mcolor, r->pcol);
83                                          /* compute reflected ray */
84          if (r->rsrc >= 0) {                     /* relayed light source */
85                  rayorigin(&nr, REFLECTED, r, mcolor);
# Line 96 | Line 108 | m_mirror(                      /* shade mirrored ray */
108          }
109          checknorm(nr.rdir);
110          rayvalue(&nr);
111 <        multcolor(nr.rcol, nr.rcoef);
112 <        addcolor(r->rcol, nr.rcol);
111 >        smultscolor(nr.rcol, nr.rcoef);
112 >        copyscolor(r->mcol, nr.rcol);
113 >        saddscolor(r->rcol, nr.rcol);
114 >        r->rmt = r->rot;
115          if (rpure && r->ro != NULL && isflat(r->ro->otype))
116 <                r->rt = r->rot + nr.rt;
116 >                r->rmt += raydistance(&nr);
117          return(1);
118   }
119  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines