1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
64 |
|
int directvis = 1; /* sources visible? */ |
65 |
|
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
66 |
|
|
67 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
68 |
+ |
double salbedo = 0.; /* global scattering albedo */ |
69 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
70 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
71 |
+ |
|
72 |
|
double specthresh = .15; /* specular sampling threshold */ |
73 |
|
double specjitter = 1.; /* specular sampling jitter */ |
74 |
|
|
75 |
+ |
int backvis = 1; /* back face visibility */ |
76 |
+ |
|
77 |
|
int maxdepth = 6; /* maximum recursion depth */ |
78 |
|
double minweight = 5e-3; /* minimum ray weight */ |
79 |
|
|
162 |
|
gethostname(hostname, sizeof(hostname)); |
163 |
|
#else |
164 |
|
times(&tbuf); |
165 |
+ |
#ifdef _SC_CLK_TCK |
166 |
|
period = 1.0 / sysconf(_SC_CLK_TCK); |
167 |
+ |
#else |
168 |
+ |
period = 1.0 / 60.0; |
169 |
+ |
#endif |
170 |
|
u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; |
171 |
|
s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; |
172 |
|
uname(&nambuf); |
177 |
|
nrays, pctdone, u/3600., s/3600., |
178 |
|
(tlastrept-tstart)/3600., hostname); |
179 |
|
eputs(errmsg); |
180 |
+ |
#ifndef BSD |
181 |
+ |
signal(SIGCONT, report); |
182 |
|
#undef hostname |
183 |
+ |
#endif |
184 |
|
} |
185 |
|
#else |
186 |
|
report() /* report progress */ |
189 |
|
sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n", |
190 |
|
nrays, pctdone, (tlastrept-tstart)/3600.0); |
191 |
|
eputs(errmsg); |
178 |
– |
signal(SIGCONT, report); |
192 |
|
} |
193 |
|
#endif |
194 |
|
|
398 |
|
fprtresolu(hres, vres, stdout); |
399 |
|
/* recover file and compute first */ |
400 |
|
i = salvage(oldfile); |
401 |
+ |
if (i >= vres) |
402 |
+ |
goto alldone; |
403 |
|
if (zfd != -1 && i > 0 && |
404 |
|
lseek(zfd, (long)i*hres*sizeof(float), 0) == -1) |
405 |
|
error(SYSTEM, "z-file seek error in render"); |
455 |
|
} |
456 |
|
/* clean up */ |
457 |
|
signal(SIGCONT, SIG_IGN); |
458 |
< |
if (zfd != -1) { |
444 |
< |
if (write(zfd, (char *)zbar[0], hres*sizeof(float)) |
458 |
> |
if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float)) |
459 |
|
< hres*sizeof(float)) |
460 |
< |
goto writerr; |
460 |
> |
goto writerr; |
461 |
> |
fwritescan(scanbar[0], hres, stdout); |
462 |
> |
if (fflush(stdout) == EOF) |
463 |
> |
goto writerr; |
464 |
> |
alldone: |
465 |
> |
if (zfd != -1) { |
466 |
|
if (close(zfd) == -1) |
467 |
|
goto writerr; |
468 |
|
for (i = 0; i <= psample; i++) |
469 |
|
free((char *)zbar[i]); |
470 |
|
} |
452 |
– |
fwritescan(scanbar[0], hres, stdout); |
453 |
– |
if (fflush(stdout) == EOF) |
454 |
– |
goto writerr; |
471 |
|
for (i = 0; i <= psample; i++) |
472 |
|
free((char *)scanbar[i]); |
473 |
|
if (sampdens != NULL) |
510 |
|
b = fillsample(scanline, zline, 0, y, i, 0, b/2); |
511 |
|
else |
512 |
|
b = fillsample(scanline+i-xstep, |
513 |
< |
zline ? zline+i-xstep : NULL, |
513 |
> |
zline ? zline+i-xstep : (float *)NULL, |
514 |
|
i-xstep, y, xstep, 0, b/2); |
515 |
|
if (sd) *sd++ = nc & 1 ? bl : b; |
516 |
|
bl = b; |
538 |
|
zline[ysize] = zbar[ysize][i]; |
539 |
|
} |
540 |
|
|
541 |
< |
b = fillsample(vline, zbar[0] ? zline : NULL, |
541 |
> |
b = fillsample(vline, zbar[0] ? zline : (float *)NULL, |
542 |
|
i, y, 0, ysize, b/2); |
543 |
|
|
544 |
|
for (j = 1; j < ysize; j++) |
596 |
|
/* recurse */ |
597 |
|
ncut += fillsample(colline, zline, x, y, xlen>>1, ylen>>1, (b-1)/2); |
598 |
|
|
599 |
< |
ncut += fillsample(colline+(len>>1), zline ? zline+(len>>1) : NULL, |
599 |
> |
ncut += fillsample(colline+(len>>1), |
600 |
> |
zline ? zline+(len>>1) : (float *)NULL, |
601 |
|
x+(xlen>>1), y+(ylen>>1), |
602 |
|
xlen-(xlen>>1), ylen-(ylen>>1), b/2); |
603 |
|
|
612 |
|
{ |
613 |
|
static RAY thisray; |
614 |
|
|
615 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
616 |
< |
(x+pixjitter())/hres, (y+pixjitter())/vres) < 0) { |
615 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
616 |
> |
(x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) { |
617 |
|
setcolor(col, 0.0, 0.0, 0.0); |
618 |
|
return(0.0); |
619 |
|
} |
639 |
|
int x, y; |
640 |
|
|
641 |
|
if (oldfile == NULL) |
642 |
< |
return(0); |
643 |
< |
|
642 |
> |
goto gotzip; |
643 |
> |
|
644 |
|
if ((fp = fopen(oldfile, "r")) == NULL) { |
645 |
|
sprintf(errmsg, "cannot open recover file \"%s\"", oldfile); |
646 |
|
error(WARNING, errmsg); |
647 |
< |
return(0); |
647 |
> |
goto gotzip; |
648 |
|
} |
649 |
|
#ifdef MSDOS |
650 |
|
setmode(fileno(fp), O_BINARY); |
657 |
|
oldfile); |
658 |
|
error(WARNING, errmsg); |
659 |
|
fclose(fp); |
660 |
< |
return(0); |
660 |
> |
goto gotzip; |
661 |
|
} |
662 |
|
|
663 |
|
if (x != hres || y != vres) { |
681 |
|
fclose(fp); |
682 |
|
unlink(oldfile); |
683 |
|
return(y); |
684 |
+ |
gotzip: |
685 |
+ |
if (fflush(stdout) == EOF) |
686 |
+ |
error(SYSTEM, "error writing picture header"); |
687 |
+ |
return(0); |
688 |
|
writerr: |
689 |
|
sprintf(errmsg, "write error during recovery of \"%s\"", oldfile); |
690 |
|
error(SYSTEM, errmsg); |