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

Comparing ray/src/rt/rcontrib.c (file contents):
Revision 2.20 by greg, Sat Jul 19 18:19:33 2014 UTC vs.
Revision 2.31 by greg, Fri Feb 23 03:21:24 2018 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8  
9   #include "copyright.h"
10  
11 #include <ctype.h>
11   #include "rcontrib.h"
12   #include "otypes.h"
13   #include "source.h"
# Line 30 | Line 29 | int    do_irrad = 0;                   /* compute irradiance? */
29   int     rand_samp = 1;                  /* pure Monte Carlo sampling? */
30  
31   double  dstrsrc = 0.9;                  /* square source distribution */
32 < double  shadthresh = .03;               /* shadow threshold */
32 > double  shadthresh = 0.;                /* shadow threshold */
33   double  shadcert = .75;                 /* shadow certainty */
34   int     directrelay = 3;                /* number of source relays */
35   int     vspretest = 512;                /* virtual source pretest density */
# Line 42 | Line 41 | COLOR  salbedo = BLKCOLOR;             /* global scattering albedo
41   double  seccg = 0.;                     /* global scattering eccentricity */
42   double  ssampdist = 0.;                 /* scatter sampling distance */
43  
44 < double  specthresh = .15;               /* specular sampling threshold */
44 > double  specthresh = .02;               /* specular sampling threshold */
45   double  specjitter = 1.;                /* specular sampling jitter */
46  
47   int     backvis = 1;                    /* back face visibility */
# Line 53 | Line 52 | double minweight = 2e-3;               /* minimum ray weight */
52   char    *ambfile = NULL;                /* ambient file name */
53   COLOR   ambval = BLKCOLOR;              /* ambient value */
54   int     ambvwt = 0;                     /* initial weight for ambient value */
55 < double  ambacc = 0;                     /* ambient accuracy */
55 > double  ambacc = 0.;                    /* ambient accuracy */
56   int     ambres = 256;                   /* ambient resolution */
57   int     ambdiv = 350;                   /* ambient divisions */
58   int     ambssamp = 0;                   /* ambient super-samples */
# Line 102 | Line 101 | addmodifier(char *modn, char *outf, char *prms, char *
101                  sprintf(errmsg, "duplicate modifier '%s'", modn);
102                  error(USER, errmsg);
103          }
104 <        if (nmods >= MAXMODLIST)
105 <                error(INTERNAL, "too many modifiers");
104 >        if (nmods >= MAXMODLIST) {
105 >                sprintf(errmsg, "too many modifiers (%d limit)", MAXMODLIST);
106 >                error(INTERNAL, errmsg);
107 >        }
108 >        if (!strcmp(modn, VOIDID)) {
109 >                sprintf(errmsg, "cannot track '%s' modifier", VOIDID);
110 >                error(USER, errmsg);
111 >        }
112          modname[nmods++] = modn;        /* XXX assumes static string */
113          lep->key = modn;                /* XXX assumes static string */
114          if (binv == NULL)
# Line 128 | Line 133 | addmodifier(char *modn, char *outf, char *prms, char *
133                  error(SYSTEM, "out of memory in addmodifier");
134          mp->outspec = outf;             /* XXX assumes static string */
135          mp->modname = modn;             /* XXX assumes static string */
136 <        mp->params = prms;
136 >        mp->params = prms;              /* XXX assumes static string */
137          mp->binv = ebinv;
138 +        mp->bin0 = 0;
139          mp->nbins = bincnt;
140          memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt);
141 <                                        /* allocate output streams */
142 <        for (i = bincnt; i-- > 0; )
143 <                getostream(mp->outspec, mp->modname, i, 1);
141 >                                        /* figure out starting bin */
142 >        while (!getostream(mp->outspec, mp->modname, mp->bin0, 1))
143 >                mp->bin0++;
144 >                                        /* allocate other output streams */
145 >        for (i = 0; ++i < mp->nbins; )
146 >                getostream(mp->outspec, mp->modname, mp->bin0+i, 1);
147          lep->data = (char *)mp;
148          return(mp);
149   }
# Line 147 | Line 156 | addmodfile(char *fname, char *outf, char *prms, char *
156          char    *mname[MAXMODLIST];
157          int     i;
158                                          /* find the file & store strings */
159 <        if (wordfile(mname, getpath(fname, getrlibpath(), R_OK)) < 0) {
159 >        i = wordfile(mname, MAXMODLIST, getpath(fname, getrlibpath(), R_OK));
160 >        if (i < 0) {
161                  sprintf(errmsg, "cannot find modifier file '%s'", fname);
162                  error(SYSTEM, errmsg);
163          }
164 +        if (i >= MAXMODLIST-1) {
165 +                sprintf(errmsg, "too many modifiers (%d limit) in file '%s'",
166 +                                MAXMODLIST-1, fname);
167 +                error(INTERNAL, errmsg);
168 +        }
169          for (i = 0; mname[i]; i++)      /* add each one */
170                  addmodifier(mname[i], outf, prms, binv, bincnt);
171   }
# Line 169 | Line 184 | quit(                  /* quit program */
184  
185   /* Initialize our process(es) */
186   static void
187 < rcinit()
187 > rcinit(void)
188   {
189          int     i;
190  
# Line 215 | Line 230 | rcinit()
230  
231   /************************** MAIN CALCULATION PROCESS ***********************/
232  
218 /* Set parameters for current bin evaluation */
219 static void
220 set_eparams(char *prms)
221 {
222        char    vname[64];
223        double  value;
224        char    *cps, *cpd;
225                                        /* assign each variable */
226        for (cps = prms; *cps; cps++) {
227                if (isspace(*cps))
228                        continue;
229                if (!isalpha(*cps))
230                        goto bad_params;
231                cpd = vname;
232                while (*cps && (*cps != '=') & !isspace(*cps)) {
233                        if (!isid(*cps))
234                                goto bad_params;
235                        *cpd++ = *cps++;
236                }
237                if (cpd == vname)
238                        goto bad_params;
239                *cpd = '\0';
240                while (isspace(*cps)) cps++;
241                if (*cps++ != '=')
242                        goto bad_params;
243                value = atof(cps);
244                if ((cps = fskip(cps)) == NULL)
245                        goto bad_params;
246                while (isspace(*cps)) cps++;
247                cps += (*cps == ',') | (*cps == ';');
248                varset(vname, '=', value);
249        }
250        return;
251 bad_params:
252        sprintf(errmsg, "bad parameter list '%s'", prms);
253        error(USER, errmsg);
254 }
255
233   /* Our trace call to sum contributions */
234   static void
235   trace_contrib(RAY *r)
236   {
260        static char     *last_params = NULL;
237          MODCONT *mp;
238          double  bval;
239          int     bn;
# Line 274 | Line 250 | trace_contrib(RAY *r)
250          if (mp == NULL)                         /* not in our list? */
251                  return;
252  
253 <        worldfunc(RCCONTEXT, r);                /* else get bin number */
254 <        if (mp->params != last_params)
255 <                set_eparams(last_params = (char *)mp->params);
256 <        if ((bval = evalue(mp->binv)) <= -.5)
281 <                return;                         /* silently ignore */
253 >        worldfunc(RCCONTEXT, r);                /* else set context */
254 >        set_eparams((char *)mp->params);
255 >        if ((bval = evalue(mp->binv)) <= -.5)   /* and get bin number */
256 >                return;                         /* silently ignore negatives */
257          if ((bn = (int)(bval + .5)) >= mp->nbins) {
258 <                error(WARNING, "bad bin number (ignored)");
258 >                sprintf(errmsg, "bad bin number (%d ignored)", bn);
259 >                error(WARNING, errmsg);
260                  return;
261          }
262          raycontrib(contr, r, PRIMARY);          /* compute coefficient */
# Line 329 | Line 305 | eval_rad(FVECT org, FVECT dir, double dmax)
305  
306   /* Accumulate and/or output ray contributions (child or only process) */
307   static void
308 < done_contrib()
308 > done_contrib(void)
309   {
310          MODCONT *mp;
311          int     i;
# Line 350 | Line 326 | done_contrib()
326  
327   /* Principal calculation loop (called by main) */
328   void
329 < rcontrib()
329 > rcontrib(void)
330   {
331          static int      ignore_warning_given = 0;
332          FVECT           orig, direc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines