9 |
|
|
10 |
|
#include <sys/types.h> |
11 |
|
|
12 |
< |
#ifndef NON_POSIX |
13 |
< |
#ifdef BSD |
14 |
< |
#include <sys/time.h> |
15 |
< |
#include <sys/resource.h> |
12 |
> |
#include "platform.h" |
13 |
> |
#ifdef NON_POSIX |
14 |
> |
#ifdef MINGW |
15 |
> |
#include <sys/time.h> |
16 |
> |
#endif |
17 |
|
#else |
18 |
< |
#include <sys/times.h> |
19 |
< |
#include <unistd.h> |
18 |
> |
#ifdef BSD |
19 |
> |
#include <sys/time.h> |
20 |
> |
#include <sys/resource.h> |
21 |
> |
#else |
22 |
> |
#include <sys/times.h> |
23 |
> |
#include <unistd.h> |
24 |
> |
#endif |
25 |
|
#endif |
20 |
– |
#endif |
26 |
|
|
27 |
|
#include <time.h> |
28 |
|
#include <signal.h> |
29 |
|
|
25 |
– |
#include "platform.h" |
30 |
|
#include "ray.h" |
31 |
|
#include "paths.h" |
32 |
|
#include "ambient.h" |
51 |
|
int ndims = 0; /* number of sampling dimensions */ |
52 |
|
int samplendx; /* sample index number */ |
53 |
|
|
50 |
– |
//extern void ambnotify(); |
54 |
|
void (*addobjnotify[])() = {ambnotify, NULL}; |
55 |
|
|
56 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
91 |
|
int backvis = 1; /* back face visibility */ |
92 |
|
|
93 |
|
int maxdepth = 7; /* maximum recursion depth */ |
94 |
< |
double minweight = 4e-3; /* minimum ray weight */ |
94 |
> |
double minweight = 1e-3; /* minimum ray weight */ |
95 |
|
|
96 |
|
char *ambfile = NULL; /* ambient file name */ |
97 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
118 |
|
|
119 |
|
static VIEW lastview; /* the previous view input */ |
120 |
|
|
118 |
– |
//extern char *mktemp(); /* XXX should be in stdlib.h or unistd.h */ |
119 |
– |
|
120 |
– |
//double pixvalue(); |
121 |
– |
|
121 |
|
static void report(int); |
122 |
|
static int nextview(FILE *fp); |
123 |
|
static void render(char *zfile, char *oldfile); |
236 |
|
{ |
237 |
|
char fbuf[128], fbuf2[128]; |
238 |
|
int npicts; |
239 |
< |
register char *cp; |
239 |
> |
char *cp; |
240 |
|
RESOLU rs; |
241 |
|
double pa; |
242 |
|
/* check sampling */ |
252 |
|
if (seq <= 0) |
253 |
|
seq = 0; |
254 |
|
else if (prvr != NULL && isint(prvr)) { |
255 |
< |
register int rn; /* skip to specified view */ |
255 |
> |
int rn; /* skip to specified view */ |
256 |
|
if ((rn = atoi(prvr)) < seq) |
257 |
|
error(USER, "recover frame less than start frame"); |
258 |
|
if (pout == NULL) |
341 |
|
fputs(VIEWSTR, stdout); |
342 |
|
fprintview(&ourview, stdout); |
343 |
|
putchar('\n'); |
344 |
< |
if (pa < .99 || pa > 1.01) |
344 |
> |
if ((pa < .99) | (pa > 1.01)) |
345 |
|
fputaspect(pa, stdout); |
346 |
|
fputnow(stdout); |
347 |
|
fputformat(COLRFMT, stdout); |
390 |
|
int zfd; |
391 |
|
COLOR *colptr; |
392 |
|
float *zptr; |
393 |
< |
register int i; |
393 |
> |
int i; |
394 |
|
/* check for empty image */ |
395 |
< |
if (hres <= 0 || vres <= 0) { |
395 |
> |
if ((hres <= 0) | (vres <= 0)) { |
396 |
|
error(WARNING, "empty output picture"); |
397 |
|
fprtresolu(0, 0, stdout); |
398 |
|
return; |
436 |
|
i = salvage(oldfile); |
437 |
|
if (i >= vres) |
438 |
|
goto alldone; |
439 |
< |
if (zfd != -1 && i > 0 && |
439 |
> |
if ((zfd != -1) & (i > 0) && |
440 |
|
lseek(zfd, (off_t)i*hres*sizeof(float), SEEK_SET) < 0) |
441 |
|
error(SYSTEM, "z-file seek error in render"); |
442 |
|
pctdone = 100.0*i/vres; |
530 |
|
|
531 |
|
static void |
532 |
|
fillscanline( /* fill scan at y */ |
533 |
< |
register COLOR *scanline, |
534 |
< |
register float *zline, |
535 |
< |
register char *sd, |
533 |
> |
COLOR *scanline, |
534 |
> |
float *zline, |
535 |
> |
char *sd, |
536 |
|
int xres, |
537 |
|
int y, |
538 |
|
int xstep |
541 |
|
static int nc = 0; /* number of calls */ |
542 |
|
int bl = xstep, b = xstep; |
543 |
|
double z; |
544 |
< |
register int i; |
544 |
> |
int i; |
545 |
|
|
546 |
|
z = pixvalue(scanline[0], 0, y); |
547 |
|
if (zline) zline[0] = z; |
569 |
|
|
570 |
|
static void |
571 |
|
fillscanbar( /* fill interior */ |
572 |
< |
register COLOR *scanbar[], |
573 |
< |
register float *zbar[], |
572 |
> |
COLOR *scanbar[], |
573 |
> |
float *zbar[], |
574 |
|
int xres, |
575 |
|
int y, |
576 |
|
int ysize |
579 |
|
COLOR vline[MAXDIV+1]; |
580 |
|
float zline[MAXDIV+1]; |
581 |
|
int b = ysize; |
582 |
< |
register int i, j; |
582 |
> |
int i, j; |
583 |
|
|
584 |
|
for (i = 0; i < xres; i++) { |
585 |
|
copycolor(vline[0], scanbar[0][i]); |
602 |
|
|
603 |
|
static int |
604 |
|
fillsample( /* fill interior points */ |
605 |
< |
register COLOR *colline, |
606 |
< |
register float *zline, |
605 |
> |
COLOR *colline, |
606 |
> |
float *zline, |
607 |
|
int x, |
608 |
|
int y, |
609 |
|
int xlen, |
615 |
|
double z; |
616 |
|
COLOR ctmp; |
617 |
|
int ncut; |
618 |
< |
register int len; |
618 |
> |
int len; |
619 |
|
|
620 |
|
if (xlen > 0) /* x or y length is zero */ |
621 |
|
len = xlen; |
666 |
|
RAY thisray; |
667 |
|
FVECT lorg, ldir; |
668 |
|
double hpos, vpos, vdist, lmax; |
669 |
< |
register int i; |
669 |
> |
int i; |
670 |
|
/* compute view ray */ |
671 |
+ |
setcolor(col, 0.0, 0.0, 0.0); |
672 |
|
hpos = (x+pixjitter())/hres; |
673 |
|
vpos = (y+pixjitter())/vres; |
674 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
675 |
< |
&ourview, hpos, vpos)) < -FTINY) { |
676 |
< |
setcolor(col, 0.0, 0.0, 0.0); |
675 |
> |
&ourview, hpos, vpos)) < -FTINY) |
676 |
|
return(0.0); |
677 |
< |
} |
677 |
> |
|
678 |
|
vdist = ourview.vdist; |
679 |
|
/* set pixel index */ |
680 |
|
samplendx = pixnumber(x,y,hres,vres); |
681 |
|
/* optional motion blur */ |
682 |
|
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
683 |
|
&lastview, hpos, vpos)) >= -FTINY) { |
684 |
< |
register double d = mblur*(.5-urand(281+samplendx)); |
684 |
> |
double d = mblur*(.5-urand(281+samplendx)); |
685 |
|
|
686 |
|
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
687 |
|
for (i = 3; i--; ) { |
693 |
|
vdist = (1.-d)*vdist + d*lastview.vdist; |
694 |
|
} |
695 |
|
/* optional depth-of-field */ |
696 |
< |
if (dblur > FTINY && vdist > FTINY) { |
696 |
> |
if (dblur > FTINY) { |
697 |
|
double vc, dfh, dfv; |
698 |
< |
/* PI/4. square/circle conv. */ |
699 |
< |
dfh = PI/4.*dblur*(.5 - frandom()); |
700 |
< |
dfv = PI/4.*dblur*(.5 - frandom()); |
701 |
< |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
698 |
> |
/* square/circle conv. */ |
699 |
> |
dfh = vc = 1. - 2.*frandom(); |
700 |
> |
dfv = 1. - 2.*frandom(); |
701 |
> |
dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); |
702 |
> |
dfv *= .5*dblur*sqrt(1. - .5*vc*vc); |
703 |
> |
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
704 |
> |
double adj = 1.0; |
705 |
> |
if (ourview.type == VT_PER) |
706 |
> |
adj /= DOT(thisray.rdir, ourview.vdir); |
707 |
|
dfh /= sqrt(ourview.hn2); |
708 |
|
dfv /= sqrt(ourview.vn2); |
709 |
|
for (i = 3; i--; ) { |
710 |
< |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
710 |
> |
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
711 |
|
thisray.rorg[i] += dfh*ourview.hvec[i] + |
712 |
|
dfv*ourview.vvec[i] ; |
713 |
|
thisray.rdir[i] = vc - thisray.rorg[i]; |
714 |
|
} |
715 |
|
} else { /* non-standard view case */ |
716 |
|
double dfd = PI/4.*dblur*(.5 - frandom()); |
717 |
< |
if (ourview.type != VT_ANG) { |
717 |
> |
if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) { |
718 |
|
if (ourview.type != VT_CYL) |
719 |
|
dfh /= sqrt(ourview.hn2); |
720 |
|
dfv /= sqrt(ourview.vn2); |
721 |
|
} |
722 |
|
for (i = 3; i--; ) { |
723 |
< |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
723 |
> |
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
724 |
|
thisray.rorg[i] += dfh*ourview.hvec[i] + |
725 |
|
dfv*ourview.vvec[i] + |
726 |
|
dfd*ourview.vdir[i] ; |
770 |
|
goto gotzip; |
771 |
|
} |
772 |
|
|
773 |
< |
if (x != hres || y != vres) { |
773 |
> |
if ((x != hres) | (y != vres)) { |
774 |
|
sprintf(errmsg, "resolution mismatch in recover file \"%s\"", |
775 |
|
oldfile); |
776 |
|
error(USER, errmsg); |
803 |
|
|
804 |
|
static int |
805 |
|
pixnumber( /* compute pixel index (brushed) */ |
806 |
< |
register int x, |
807 |
< |
register int y, |
806 |
> |
int x, |
807 |
> |
int y, |
808 |
|
int xres, |
809 |
|
int yres |
810 |
|
) |