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

Comparing ray/src/rt/m_brdf.c (file contents):
Revision 2.24 by greg, Wed Aug 22 21:21:51 2007 UTC vs.
Revision 2.31 by greg, Sat Jan 25 18:27:39 2014 UTC

# Line 38 | Line 38 | static const char      RCSid[] = "$Id$";
38   *  Arguments for MAT_TFUNC are:
39   *      2+      func    funcfile        transform
40   *      0
41 < *      4+      red     grn     blu     rspec   trans   tspec   A7 ..
41 > *      6+      red     grn     blu     rspec   trans   tspec   A7 ..
42   *
43   *  Arguments for MAT_TDATA are:
44   *      4+      func    datafile        funcfile        v0 ..   transform
45   *      0
46 < *      4+      red     grn     blu     rspec   trans   tspec   A7 ..
46 > *      6+      red     grn     blu     rspec   trans   tspec   A7 ..
47   *
48   *  Arguments for the more general MAT_BRTDF are:
49   *      10+     rrefl   grefl   brefl
# Line 77 | Line 77 | typedef struct {
77   }  BRDFDAT;             /* BRDF material data */
78  
79  
80 < static srcdirf_t dirbrdf;
81 < static int setbrdfunc(BRDFDAT  *np);
80 > static int setbrdfunc(BRDFDAT *np);
81  
82  
83   static void
# Line 89 | Line 88 | dirbrdf(               /* compute source contribution */
88          double  omega                   /* light source size */
89   )
90   {
91 <        register BRDFDAT *np = nnp;
91 >        BRDFDAT *np = nnp;
92          double  ldot;
93          double  dtmp;
94          COLOR  ctmp;
95          FVECT  ldx;
96          static double  vldx[5], pt[MAXDIM];
97 <        register char   **sa;
98 <        register int    i;
97 >        char    **sa;
98 >        int     i;
99   #define lddx (vldx+1)
100  
101          setcolor(cval, 0.0, 0.0, 0.0);
# Line 168 | Line 167 | dirbrdf(               /* compute source contribution */
167                  dtmp = funvalue(sa[0], 5, vldx);
168                  setcolor(ctmp, dtmp, dtmp, dtmp);
169          }
170 <        if (errno == EDOM || errno == ERANGE) {
170 >        if ((errno == EDOM) | (errno == ERANGE)) {
171                  objerror(np->mp, WARNING, "compute error");
172                  return;
173          }
# Line 197 | Line 196 | dirbrdf(               /* compute source contribution */
196   }
197  
198  
199 < extern int
199 > int
200   m_brdf(                 /* color a ray that hit a BRDTfunc material */
201 <        register OBJREC  *m,
202 <        register RAY  *r
201 >        OBJREC  *m,
202 >        RAY  *r
203   )
204   {
205          int  hitfront = 1;
206          BRDFDAT  nd;
207          RAY  sr;
208          double  mirtest=0, mirdist=0;
209 <        double  transtest, transdist;
209 >        double  transtest=0, transdist=0;
210          int  hasrefl, hastrans;
211          int  hastexture;
212          COLOR  ctmp;
213          FVECT  vtmp;
214          double  d;
215 <        register MFUNC  *mf;
216 <        register int  i;
215 >        MFUNC  *mf;
216 >        int  i;
217                                                  /* check arguments */
218          if ((m->oargs.nsargs < 10) | (m->oargs.nfargs < 9))
219                  objerror(m, USER, "bad # arguments");
# Line 267 | Line 266 | m_brdf(                        /* color a ray that hit a BRDTfunc material
266          setcolor(ctmp, evalue(mf->ep[3]),
267                          evalue(mf->ep[4]),
268                          evalue(mf->ep[5]));
269 <        if (errno == EDOM || errno == ERANGE)
269 >        if ((errno == EDOM) | (errno == ERANGE))
270                  objerror(m, WARNING, "compute error");
271          else if (rayorigin(&sr, TRANS, r, ctmp) == 0) {
272                  if (!(r->crtype & SHADOW) && hastexture) {
273 <                        for (i = 0; i < 3; i++) /* perturb direction */
274 <                                sr.rdir[i] = r->rdir[i] - .75*r->pert[i];
273 >                                                /* perturb direction */
274 >                        VSUM(sr.rdir, r->rdir, r->pert, -.75);
275                          if (normalize(sr.rdir) == 0.0) {
276                                  objerror(m, WARNING, "illegal perturbation");
277                                  VCOPY(sr.rdir, r->rdir);
# Line 296 | Line 295 | m_brdf(                        /* color a ray that hit a BRDTfunc material
295          setcolor(ctmp, evalue(mf->ep[0]),
296                          evalue(mf->ep[1]),
297                          evalue(mf->ep[2]));
298 <        if (errno == EDOM || errno == ERANGE)
298 >        if ((errno == EDOM) | (errno == ERANGE))
299                  objerror(m, WARNING, "compute error");
300          else if (rayorigin(&sr, REFLECTED, r, ctmp) == 0) {
301 <                for (i = 0; i < 3; i++)
302 <                        sr.rdir[i] = r->rdir[i] + 2.0*nd.pdot*nd.pnorm[i];
301 >                VSUM(sr.rdir, r->rdir, nd.pnorm, 2.*nd.pdot);
302 >                checknorm(sr.rdir);
303                  rayvalue(&sr);
304                  multcolor(sr.rcol, sr.rcoef);
305                  addcolor(r->rcol, sr.rcol);
# Line 345 | Line 344 | m_brdf(                        /* color a ray that hit a BRDTfunc material
344  
345  
346  
347 < extern int
347 > int
348   m_brdf2(                        /* color a ray that hit a BRDF material */
349 <        register OBJREC  *m,
350 <        register RAY  *r
349 >        OBJREC  *m,
350 >        RAY  *r
351   )
352   {
353          BRDFDAT  nd;
# Line 364 | Line 363 | m_brdf2(                       /* color a ray that hit a BRDF material */
363                  objerror(m, USER, "bad # arguments");
364                                                  /* check for back side */
365          if (r->rod < 0.0) {
366 <                if (!backvis && m->otype != MAT_TFUNC
368 <                                && m->otype != MAT_TDATA) {
366 >                if (!backvis) {
367                          raytrans(r);
368                          return(1);
369                  }
# Line 434 | Line 432 | m_brdf2(                       /* color a ray that hit a BRDF material */
432  
433   static int
434   setbrdfunc(                     /* set up brdf function and variables */
435 <        register BRDFDAT  *np
435 >        BRDFDAT  *np
436   )
437   {
438          FVECT  vec;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines