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.6 by greg, Fri Jun 15 00:57:40 2012 UTC vs.
Revision 2.12 by greg, Thu Jun 21 17:14:32 2012 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   #include "rcontrib.h"
10   #include "source.h"
11   #include "otypes.h"
12 #include "platform.h"
12  
13   char    *shm_boundary = NULL;           /* boundary of shared memory */
14  
# Line 27 | Line 26 | int    do_irrad = 0;                   /* compute irradiance? */
26  
27   int     rand_samp = 1;                  /* pure Monte Carlo sampling? */
28  
29 < double  dstrsrc = 0.0;                  /* square source distribution */
29 > double  dstrsrc = 0.9;                  /* square source distribution */
30   double  shadthresh = .03;               /* shadow threshold */
31   double  shadcert = .75;                 /* shadow certainty */
32   int     directrelay = 3;                /* number of source relays */
# Line 137 | Line 136 | addmodifier(char *modn, char *outf, char *binv, int bi
136   }
137  
138  
139 < /* add modifiers from a file list */
139 > /* Add modifiers from a file list */
140   void
141   addmodfile(char *fname, char *outf, char *binv, int bincnt)
142   {
# Line 159 | Line 158 | quit(                  /* quit program */
158   )
159   {
160          if (nchild > 0)         /* close children if any */
161 <                end_children();
161 >                end_children(code != 0);
162          exit(code);
163   }
164  
# Line 178 | Line 177 | rcinit()
177                                          /* set shared memory boundary */
178                  shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY");
179          }
181        if ((nproc > 1) & (accumulate <= 0))
182                put_zero_record(0);     /* prime our queue to accumulate */
183
180          if (yres > 0) {                 /* set up flushing & ray counts */
181                  if (xres > 0)
182                          raysleft = (RNUMBER)xres*yres;
# Line 199 | Line 195 | rcinit()
195                  return;                 /* return to main processing loop */
196  
197          if (recover) {                  /* recover previous output? */
198 <                if (accumulate <= 0) {
198 >                if (accumulate <= 0)
199                          reload_output();
200 <                        if (nproc > 1)
205 <                                queue_modifiers();
206 <                } else
200 >                else
201                          recover_output();
202          }
203          if (nproc == 1)                 /* single process? */
204                  return;
205 <
206 <        parental_loop();                /* else run controller */
205 >                                        /* else run appropriate controller */
206 >        if (accumulate <= 0)
207 >                feeder_loop();
208 >        else
209 >                parental_loop();
210          quit(0);                        /* parent musn't return! */
211   }
212  
# Line 244 | Line 241 | trace_contrib(RAY *r)
241   }
242  
243  
244 + /* Evaluate irradiance contributions */
245   static void
246 < rayirrad(                       /* compute irradiance rather than radiance */
249 <        RAY *r
250 < )
246 > eval_irrad(FVECT org, FVECT dir)
247   {
248 <        r->rot = 1e-5;                  /* pretend we hit surface */
249 <        VSUM(r->rop, r->rorg, r->rdir, r->rot);
250 <        r->ron[0] = -r->rdir[0];
251 <        r->ron[1] = -r->rdir[1];
252 <        r->ron[2] = -r->rdir[2];
253 <        r->rod = 1.0;
254 <                                        /* compute result */
255 <        r->revf = raytrace;
256 <        (*ofun[Lamb.otype].funp)(&Lamb, r);
257 <        r->revf = rayirrad;
248 >        RAY     thisray;
249 >
250 >        VSUM(thisray.rorg, org, dir, 1.1e-4);
251 >        thisray.rdir[0] = -dir[0];
252 >        thisray.rdir[1] = -dir[1];
253 >        thisray.rdir[2] = -dir[2];
254 >        thisray.rmax = 0.0;
255 >        rayorigin(&thisray, PRIMARY, NULL, NULL);
256 >        thisray.rot = 1e-5;             /* pretend we hit surface */
257 >        thisray.rod = 1.0;
258 >        VSUM(thisray.rop, org, dir, 1e-4);
259 >        samplendx++;                    /* compute result */
260 >        (*ofun[Lamb.otype].funp)(&Lamb, &thisray);
261   }
262  
263  
264 < /* Evaluate ray contributions */
264 > /* Evaluate radiance contributions */
265   static void
266 < eval_ray(FVECT  org, FVECT  dir, double dmax)
266 > eval_rad(FVECT org, FVECT dir, double dmax)
267   {
268          RAY     thisray;
269                                          /* set up ray */
270 +        VCOPY(thisray.rorg, org);
271 +        VCOPY(thisray.rdir, dir);
272 +        thisray.rmax = dmax;
273          rayorigin(&thisray, PRIMARY, NULL, NULL);
272        if (imm_irrad) {
273                VSUM(thisray.rorg, org, dir, 1.1e-4);
274                thisray.rdir[0] = -dir[0];
275                thisray.rdir[1] = -dir[1];
276                thisray.rdir[2] = -dir[2];
277                thisray.rmax = 0.0;
278                thisray.revf = rayirrad;
279        } else {
280                VCOPY(thisray.rorg, org);
281                VCOPY(thisray.rdir, dir);
282                thisray.rmax = dmax;
283        }
274          samplendx++;                    /* call ray evaluation */
275          rayvalue(&thisray);
276   }
# Line 335 | Line 325 | rcontrib()
325                          if ((yres <= 0) | (xres <= 0))
326                                  waitflush = 1;          /* flush right after */
327                          account = 1;
328 <                } else {                                /* else compute */
329 <                        eval_ray(orig, direc, lim_dist ? d : 0.0);
328 >                } else if (imm_irrad) {                 /* else compute */
329 >                        eval_irrad(orig, direc);
330 >                } else {
331 >                        eval_rad(orig, direc, lim_dist ? d : 0.0);
332                  }
333                  done_contrib();         /* accumulate/output */
334                  ++lastdone;
# Line 351 | Line 343 | rcontrib()
343                  account = 1;            /* output accumulated totals */
344                  done_contrib();
345          }
346 +        lu_done(&ofiletab);             /* close output files */
347          if (raysleft)
348                  error(USER, "unexpected EOF on input");
356        lu_done(&ofiletab);             /* close output files */
349   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines