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.13 by greg, Sun Sep 26 15:51:15 2010 UTC vs.
Revision 2.17 by greg, Tue Feb 24 19:39:26 2015 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11   #include  "otypes.h"
12   #include  "rtotypes.h"
13   #include  "source.h"
14 + #include  "pmapmat.h"
15  
16   /*
17   * The real arguments for MAT_MIRROR are simply:
# Line 29 | Line 30 | static void mirrorproj(MAT4  m, FVECT  nv, double  off
30   VSMATERIAL  mirror_vs = {mir_proj, 1};
31  
32  
33 < extern int
33 > int
34   m_mirror(                       /* shade mirrored ray */
35 <        register OBJREC  *m,
36 <        register RAY  *r
35 >        OBJREC  *m,
36 >        RAY  *r
37   )
38   {
39          COLOR  mcolor;
40          RAY  nr;
41          int  rpure = 1;
42 <        register int  i;
42 >        int  i;
43 >        
44 >        /* PMAP: skip specular refl via ambient bounce if already accounted for
45 >         * in photon map */
46 >        if (ambRayInPmap(r))
47 >                return(1);
48                                          /* check arguments */
49          if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1)
50                  objerror(m, USER, "bad number of arguments");
51                                          /* check for substitute material */
52 <        if (m->oargs.nsargs > 0 &&
52 >                                        /* but avoid double-counting */
53 >        if (m->oargs.nsargs > 0 && !(r->crtype & (AMBIENT|SPECULAR)) &&
54                          (r->rsrc < 0 || source[r->rsrc].so != r->ro)) {
55                  if (!strcmp(m->oargs.sarg[0], VOIDID)) {
56                          raytrans(r);
# Line 55 | Line 62 | m_mirror(                      /* shade mirrored ray */
62          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
63                  return(1);
64  
65 <        if (r->rod < 0.)                /* back is black */
65 >        if (r->rod < 0.) {              /* back is black */
66 >                if (!backvis)
67 >                        raytrans(r);    /* unless back visibility is off */
68                  return(1);
69 +        }
70                                          /* get modifiers */
71          raytexture(r, m->omod);
72                                          /* assign material color */
# Line 78 | Line 88 | m_mirror(                      /* shade mirrored ray */
88  
89                  if (rayorigin(&nr, REFLECTED, r, mcolor) < 0)
90                          return(1);
91 <                if (DOT(r->pert,r->pert) > FTINY*FTINY) {
91 >                if (!(r->crtype & AMBIENT) &&
92 >                                DOT(r->pert,r->pert) > FTINY*FTINY) {
93                          pdot = raynormal(pnorm, r);     /* use textures */
94                          for (i = 0; i < 3; i++)
95                                  nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i];
# Line 102 | Line 113 | m_mirror(                      /* shade mirrored ray */
113   static int
114   mir_proj(               /* compute a mirror's projection */
115          MAT4  pm,
116 <        register OBJREC  *o,
116 >        OBJREC  *o,
117          SRCREC  *s,
118          int  n
119   )
# Line 138 | Line 149 | mir_proj(              /* compute a mirror's projection */
149  
150   static void
151   mirrorproj(             /* get mirror projection for surface */
152 <        register MAT4  m,
152 >        MAT4  m,
153          FVECT  nv,
154          double  offs
155   )
156   {
157 <        register int  i, j;
157 >        int  i, j;
158                                          /* assign matrix */
159          setident4(m);
160          for (j = 0; j < 3; j++) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines