| 11 |
|
#include "otypes.h" |
| 12 |
|
#include "platform.h" |
| 13 |
|
|
| 14 |
+ |
char *shm_boundary = NULL; /* boundary of shared memory */ |
| 15 |
+ |
|
| 16 |
|
CUBE thescene; /* our scene */ |
| 17 |
|
OBJECT nsceneobjs; /* number of objects in our scene */ |
| 18 |
|
|
| 25 |
|
|
| 26 |
|
int do_irrad = 0; /* compute irradiance? */ |
| 27 |
|
|
| 28 |
< |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
| 28 |
> |
int rand_samp = 1; /* pure Monte Carlo sampling? */ |
| 29 |
|
|
| 30 |
|
double dstrsrc = 0.0; /* square source distribution */ |
| 31 |
|
double shadthresh = .03; /* shadow threshold */ |
| 45 |
|
|
| 46 |
|
int backvis = 1; /* back face visibility */ |
| 47 |
|
|
| 48 |
< |
int maxdepth = 8; /* maximum recursion depth */ |
| 49 |
< |
double minweight = 5e-4; /* minimum ray weight */ |
| 48 |
> |
int maxdepth = -10; /* maximum recursion depth */ |
| 49 |
> |
double minweight = 2e-3; /* minimum ray weight */ |
| 50 |
|
|
| 51 |
|
char *ambfile = NULL; /* ambient file name */ |
| 52 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
| 63 |
|
RNUMBER raysleft; /* number of rays left to trace */ |
| 64 |
|
long waitflush; /* how long until next flush */ |
| 65 |
|
|
| 66 |
< |
int lastray = 0; /* last ray number sent */ |
| 67 |
< |
int lastdone = 0; /* last ray output */ |
| 66 |
> |
RNUMBER lastray = 0; /* last ray number sent */ |
| 67 |
> |
RNUMBER lastdone = 0; /* last ray output */ |
| 68 |
|
|
| 67 |
– |
/* Close output stream and free record */ |
| 68 |
– |
static void |
| 69 |
– |
closestream(void *p) |
| 70 |
– |
{ |
| 71 |
– |
STREAMOUT *sop = (STREAMOUT *)p; |
| 72 |
– |
int status = 0; |
| 73 |
– |
if (sop->outpipe) |
| 74 |
– |
status = pclose(sop->ofp); |
| 75 |
– |
else if (sop->ofp != stdout) |
| 76 |
– |
status = fclose(sop->ofp); |
| 77 |
– |
if (status) |
| 78 |
– |
error(SYSTEM, "error closing output stream"); |
| 79 |
– |
free(p); |
| 80 |
– |
} |
| 81 |
– |
|
| 82 |
– |
LUTAB ofiletab = LU_SINIT(free,closestream); /* output file table */ |
| 83 |
– |
|
| 84 |
– |
#define OF_MODIFIER 01 |
| 85 |
– |
#define OF_BIN 02 |
| 86 |
– |
|
| 69 |
|
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); } |
| 70 |
|
|
| 71 |
|
LUTAB modconttab = LU_SINIT(NULL,mcfree); /* modifier lookup table */ |
| 204 |
|
if (nproc > MAXPROCESS) |
| 205 |
|
sprintf(errmsg, "too many processes requested -- reducing to %d", |
| 206 |
|
nproc = MAXPROCESS); |
| 207 |
< |
|
| 207 |
> |
if (nproc > 1) { |
| 208 |
> |
preload_objs(); /* preload auxiliary data */ |
| 209 |
> |
/* set shared memory boundary */ |
| 210 |
> |
shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY"); |
| 211 |
> |
} |
| 212 |
|
if ((nproc > 1) & (accumulate <= 0)) |
| 213 |
< |
zero_record(0); /* prime our queue to accumulate */ |
| 213 |
> |
put_zero_record(0); /* prime our queue to accumulate */ |
| 214 |
|
|
| 215 |
|
if (recover) { /* recover previous output? */ |
| 216 |
|
if (accumulate <= 0) { |
| 217 |
|
reload_output(); |
| 218 |
< |
if ((nproc > 1) & (accumulate <= 0)) |
| 218 |
> |
if (nproc > 1) |
| 219 |
|
queue_modifiers(); |
| 220 |
|
} else |
| 221 |
|
recover_output(); |
| 342 |
|
static int ignore_warning_given = 0; |
| 343 |
|
FVECT orig, direc; |
| 344 |
|
double d; |
| 345 |
< |
/* initialize & fork */ |
| 345 |
> |
/* initialize (& fork more of us) */ |
| 346 |
|
rcinit(); |
| 347 |
|
/* load rays from stdin & process */ |
| 348 |
|
#ifdef getc_unlocked |
| 349 |
< |
flockfile(stdin); /* avoid lock/unlock overhead */ |
| 349 |
> |
flockfile(stdin); /* avoid mutex overhead */ |
| 350 |
|
#endif |
| 351 |
|
while (getvec(orig) == 0 && getvec(direc) == 0) { |
| 352 |
|
d = normalize(direc); |
| 353 |
< |
if ((d == 0.0) & (accumulate != 1)) { |
| 353 |
> |
if (nchild != -1 && (d == 0.0) & (accumulate != 1)) { |
| 354 |
|
if (!ignore_warning_given++) |
| 355 |
|
error(WARNING, |
| 356 |
|
"dummy ray(s) ignored during accumulation\n"); |
| 362 |
|
if (d == 0.0) { /* zero ==> flush */ |
| 363 |
|
if ((yres <= 0) | (xres <= 0)) |
| 364 |
|
waitflush = 1; /* flush right after */ |
| 365 |
+ |
account = 1; |
| 366 |
|
} else { /* else compute */ |
| 367 |
|
eval_ray(orig, direc, lim_dist ? d : 0.0); |
| 368 |
|
} |
| 371 |
|
if (raysleft && !--raysleft) |
| 372 |
|
break; /* preemptive EOI */ |
| 373 |
|
} |
| 374 |
< |
if (accumulate <= 0 || account < accumulate) { |
| 374 |
> |
if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { |
| 375 |
|
if (account < accumulate) { |
| 376 |
|
error(WARNING, "partial accumulation in final record"); |
| 377 |
|
accumulate -= account; |