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

Comparing ray/src/rt/m_wgmdf.c (file contents):
Revision 2.8 by greg, Thu Dec 19 23:25:28 2024 UTC vs.
Revision 2.13 by greg, Fri Jun 20 16:48:39 2025 UTC

# Line 94 | Line 94 | typedef struct {
94          RAY             *rp;            /* ray pointer */
95          OBJREC          *mtp;           /* material pointer */
96          MFUNC           *mf;            /* pointer to expression list */
97 +        OBJECT          mto;            /* material object index (or -2) */
98          int             specfl;         /* specularity flags, defined above */
99          FVECT           ulocal;         /* u-vector in local coordinates */
100          DCOMP           rd, td;         /* diffuse component params */
# Line 101 | Line 102 | typedef struct {
102          FVECT           prdir;          /* vector in transmitted direction */
103   } WGMDDAT;              /* WGMD material data */
104  
105 < #define clr_comps(wp)   ((wp)->specfl = 0, \
105 > #define clr_comps(wp)   ((wp)->specfl = 0, (wp)->mto = OVOID-1, \
106                          (wp)->rd.mo.nam = (wp)->td.mo.nam = \
107                          (wp)->rs.mo.nam = (wp)->ts.mo.nam = "")
108  
# Line 133 | Line 134 | set_modval(MODVAL *mp, OBJECT omod, const RAY *r)
134  
135   /* fill modifier values, using previous setting if found */
136   static int
137 < fill_modval(MODVAL *mp, const WGMDDAT *wp)
137 > fill_modval(MODVAL *mp, WGMDDAT *wp)
138   {
139          if (mp == &wp->rd.mo) {         /* special case (should be first) */
140                  set_modval(mp, wp->mtp->omod, wp->rp);
# Line 154 | Line 155 | fill_modval(MODVAL *mp, const WGMDDAT *wp)
155          if (mp != &wp->ts.mo && !strcmp(mp->nam, wp->ts.mo.nam)) {
156                  *mp = wp->ts.mo;
157                  return(1);
158 <        }                               /* new modifier */
159 <        return(set_modval(mp, lastmod(objndx(wp->mtp), mp->nam), wp->rp));
158 >        }
159 >        if (wp->mto < OVOID)
160 >                wp->mto = objndx(wp->mtp);
161 >                                        /* new modifier */
162 >        return(set_modval(mp, lastmod(wp->mto, mp->nam), wp->rp));
163   }
164  
165   /* set calculation context for given component of MAT_WGMDF */
# Line 256 | Line 260 | set_scomp(WGMDDAT *wp, int trans)
260          if (normalize(sp->v) == 0.0) {  /* orientation vector==normal? */
261                  if (fabs(sp->u_alpha - sp->v_alpha) > 0.001)
262                          objerror(wp->mtp, WARNING, "bad orientation vector");
263 <                getperpendicular(sp->u, sp->mo.pnorm, 1);       /* punting */
263 >                getperpendicular(sp->u, sp->mo.pnorm, 0);       /* punting */
264                  fcross(sp->v, sp->mo.pnorm, sp->u);
265                  sp->u_alpha = sp->v_alpha = sqrt( 0.5 *
266                          (sp->u_alpha*sp->u_alpha + sp->v_alpha*sp->v_alpha) );
# Line 294 | Line 298 | agaussamp(WGMDDAT *wp)
298                                  nstarget = 1;
299                  }
300                  scolorblack(scol);
301 <                dimlist[ndims++] = (int)(size_t)wp->mtp;
301 >                dimlist[ndims_inc] = (int)(size_t)wp->mtp;
302                  maxiter = MAXITER*nstarget;
303                  for (nstaken = ntrials = 0; (nstaken < nstarget) &
304                                                  (ntrials < maxiter); ntrials++) {
# Line 343 | Line 347 | agaussamp(WGMDDAT *wp)
347                          scalescolor(scol, d);
348                          saddscolor(wp->rp->rcol, scol);
349                  }
350 <                ndims--;
350 >                dec_ndims;
351          }
352                                          /* compute transmission */
353          if ((wp->specfl & (SP_TRAN|SP_TPURE|SP_TBLT)) == SP_TRAN &&
# Line 360 | Line 364 | agaussamp(WGMDDAT *wp)
364                          } else
365                                  nstarget = 1;
366                  }
367 <                dimlist[ndims++] = (int)(size_t)wp->mtp;
367 >                dimlist[ndims_inc] = (int)(size_t)wp->mtp;
368                  maxiter = MAXITER*nstarget;
369                  for (nstaken = ntrials = 0; (nstaken < nstarget) &
370                                                  (ntrials < maxiter); ntrials++) {
# Line 397 | Line 401 | agaussamp(WGMDDAT *wp)
401                          saddscolor(wp->rp->rcol, sr.rcol);
402                          ++nstaken;
403                  }
404 <                ndims--;
404 >                dec_ndims;
405          }
406   }
407  
# Line 452 | Line 456 | dirwgmdf(SCOLOR scval, void *uwp, FVECT ldir, double o
456                   */
457                                                  /* add source width if flat */
458                  if (wp->specfl & SP_FLAT)
459 <                        au2 = av2 = omega * (0.25/PI);
459 >                        au2 = av2 = (1. - dstrsrc) * omega * (0.25/PI);
460                  else
461                          au2 = av2 = 0.0;
462                  au2 += wp->rs.u_alpha*wp->rs.u_alpha;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines