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.9 by greg, Sat Jun 16 17:30:13 2012 UTC vs.
Revision 2.24 by greg, Wed May 20 12:58:31 2015 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   * Initialization and calculation routines
7   */
8  
9 + #include "copyright.h"
10 +
11 + #include <ctype.h>
12   #include "rcontrib.h"
10 #include "source.h"
13   #include "otypes.h"
14 < #include "platform.h"
14 > #include "source.h"
15  
16   char    *shm_boundary = NULL;           /* boundary of shared memory */
17  
# Line 89 | Line 91 | formstr(                               /* return format identifier */
91  
92   /* Add modifier to our list to track */
93   MODCONT *
94 < addmodifier(char *modn, char *outf, char *binv, int bincnt)
94 > addmodifier(char *modn, char *outf, char *prms, char *binv, int bincnt)
95   {
96          LUENT   *lep = lu_find(&modconttab,modn);
97          MODCONT *mp;
# Line 126 | Line 128 | addmodifier(char *modn, char *outf, char *binv, int bi
128                  error(SYSTEM, "out of memory in addmodifier");
129          mp->outspec = outf;             /* XXX assumes static string */
130          mp->modname = modn;             /* XXX assumes static string */
131 +        mp->params = prms;
132          mp->binv = ebinv;
133          mp->nbins = bincnt;
134          memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt);
# Line 137 | Line 140 | addmodifier(char *modn, char *outf, char *binv, int bi
140   }
141  
142  
143 < /* add modifiers from a file list */
143 > /* Add modifiers from a file list */
144   void
145 < addmodfile(char *fname, char *outf, char *binv, int bincnt)
145 > addmodfile(char *fname, char *outf, char *prms, char *binv, int bincnt)
146   {
147          char    *mname[MAXMODLIST];
148          int     i;
# Line 149 | Line 152 | addmodfile(char *fname, char *outf, char *binv, int bi
152                  error(SYSTEM, errmsg);
153          }
154          for (i = 0; mname[i]; i++)      /* add each one */
155 <                addmodifier(mname[i], outf, binv, bincnt);
155 >                addmodifier(mname[i], outf, prms, binv, bincnt);
156   }
157  
158  
# Line 159 | Line 162 | quit(                  /* quit program */
162   )
163   {
164          if (nchild > 0)         /* close children if any */
165 <                end_children();
165 >                end_children(code != 0);
166          exit(code);
167   }
168  
# Line 178 | Line 181 | rcinit()
181                                          /* set shared memory boundary */
182                  shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY");
183          }
184 +        for (i = 0; i < nsources; i++)  /* tracing to sources as well */
185 +                source[i].sflags |= SFOLLOW;
186          if (yres > 0) {                 /* set up flushing & ray counts */
187                  if (xres > 0)
188                          raysleft = (RNUMBER)xres*yres;
# Line 188 | Line 193 | rcinit()
193          if ((account = accumulate) > 1)
194                  raysleft *= accumulate;
195          waitflush = (yres > 0) & (xres > 1) ? 0 : xres;
191                                        /* tracing to sources as well */
192        for (i = 0; i < nsources; i++)
193                source[i].sflags |= SFOLLOW;
196  
197          if (nproc > 1 && in_rchild())   /* forked child? */
198                  return;                 /* return to main processing loop */
# Line 218 | Line 220 | static void
220   trace_contrib(RAY *r)
221   {
222          MODCONT *mp;
223 +        double  bval;
224          int     bn;
225          RREAL   contr[3];
226  
227          if (r->ro == NULL || r->ro->omod == OVOID)
228                  return;
229 +                                                /* shadow ray not on source? */
230 +        if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
231 +                return;
232  
233          mp = (MODCONT *)lu_find(&modconttab,objptr(r->ro->omod)->oname)->data;
234  
235          if (mp == NULL)                         /* not in our list? */
236                  return;
237  
238 <        worldfunc(RCCONTEXT, r);                /* get bin number */
239 <        bn = (int)(evalue(mp->binv) + .5);
240 <        if ((bn < 0) | (bn >= mp->nbins)) {
241 <                error(WARNING, "bad bin number (ignored)");
238 >        worldfunc(RCCONTEXT, r);                /* else set context */
239 >        set_eparams((char *)mp->params);
240 >        if ((bval = evalue(mp->binv)) <= -.5)   /* and get bin number */
241 >                return;                         /* silently ignore negatives */
242 >        if ((bn = (int)(bval + .5)) >= mp->nbins) {
243 >                sprintf(errmsg, "bad bin number (%d ignored)", bn);
244 >                error(WARNING, errmsg);
245                  return;
246          }
247 <        raycontrib(contr, r, PRIMARY);
247 >        raycontrib(contr, r, PRIMARY);          /* compute coefficient */
248          if (contrib)
249 <                multcolor(contr, r->rcol);
249 >                multcolor(contr, r->rcol);      /* -> contribution */
250          addcolor(mp->cbin[bn], contr);
251   }
252  
# Line 254 | Line 263 | eval_irrad(FVECT org, FVECT dir)
263          thisray.rdir[2] = -dir[2];
264          thisray.rmax = 0.0;
265          rayorigin(&thisray, PRIMARY, NULL, NULL);
266 <        thisray.rot = 1e-5;             /* pretend we hit surface */
266 >                                        /* pretend we hit surface */
267 >        thisray.rt = thisray.rot = 1e-5;
268          thisray.rod = 1.0;
269 +        VCOPY(thisray.ron, dir);
270          VSUM(thisray.rop, org, dir, 1e-4);
271          samplendx++;                    /* compute result */
272          (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
# Line 313 | Line 324 | rcontrib()
324   #endif
325          while (getvec(orig) == 0 && getvec(direc) == 0) {
326                  d = normalize(direc);
327 <                if (nchild != -1 && (d == 0.0) & (accumulate != 1)) {
327 >                if (nchild != -1 && (d == 0.0) & (accumulate == 0)) {
328                          if (!ignore_warning_given++)
329                                  error(WARNING,
330                                  "dummy ray(s) ignored during accumulation\n");
# Line 323 | Line 334 | rcontrib()
334                          lastray = lastdone = 0;
335                  ++lastray;
336                  if (d == 0.0) {                         /* zero ==> flush */
337 <                        if ((yres <= 0) | (xres <= 0))
338 <                                waitflush = 1;          /* flush right after */
339 <                        account = 1;
337 >                        if ((yres <= 0) | (xres <= 1))
338 >                                waitflush = 1;          /* flush after */
339 >                        if (nchild == -1)
340 >                                account = 1;
341                  } else if (imm_irrad) {                 /* else compute */
342                          eval_irrad(orig, direc);
343                  } else {
# Line 336 | Line 348 | rcontrib()
348                  if (raysleft && !--raysleft)
349                          break;          /* preemptive EOI */
350          }
351 <        if ((accumulate <= 0) | (account < accumulate)) {
351 >        if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) {
352                  if (account < accumulate) {
353                          error(WARNING, "partial accumulation in final record");
354                          accumulate -= account;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines