| 1 |
|
#ifndef lint |
| 2 |
< |
static const char RCSid[] = "$Id$"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 4 |
|
/* |
| 5 |
|
* rpict.c - routines and variables for picture generation. |
| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
– |
#include "ray.h" |
| 11 |
– |
|
| 10 |
|
#include <sys/types.h> |
| 11 |
|
|
| 12 |
< |
#ifndef NIX |
| 12 |
> |
#ifndef NON_POSIX |
| 13 |
|
#ifdef BSD |
| 14 |
|
#include <sys/time.h> |
| 15 |
|
#include <sys/resource.h> |
| 19 |
|
#endif |
| 20 |
|
#endif |
| 21 |
|
|
| 22 |
< |
extern time_t time(); |
| 25 |
< |
|
| 22 |
> |
#include <time.h> |
| 23 |
|
#include <signal.h> |
| 24 |
|
|
| 25 |
+ |
#include "platform.h" |
| 26 |
+ |
#include "ray.h" |
| 27 |
+ |
#include "paths.h" |
| 28 |
+ |
#include "ambient.h" |
| 29 |
|
#include "view.h" |
| 29 |
– |
|
| 30 |
|
#include "random.h" |
| 31 |
– |
|
| 31 |
|
#include "paths.h" |
| 32 |
+ |
#include "rtmisc.h" /* myhostname() */ |
| 33 |
|
|
| 34 |
+ |
|
| 35 |
|
#define RFTEMPLATE "rfXXXXXX" |
| 36 |
|
|
| 37 |
|
#ifndef SIGCONT |
| 38 |
+ |
#ifdef SIGIO /* XXX can we live without this? */ |
| 39 |
|
#define SIGCONT SIGIO |
| 40 |
|
#endif |
| 41 |
+ |
#endif |
| 42 |
|
|
| 43 |
|
CUBE thescene; /* our scene */ |
| 44 |
|
OBJECT nsceneobjs; /* number of objects in our scene */ |
| 47 |
|
int ndims = 0; /* number of sampling dimensions */ |
| 48 |
|
int samplendx; /* sample index number */ |
| 49 |
|
|
| 50 |
< |
extern void ambnotify(); |
| 50 |
> |
//extern void ambnotify(); |
| 51 |
|
void (*addobjnotify[])() = {ambnotify, NULL}; |
| 52 |
|
|
| 53 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
| 61 |
|
|
| 62 |
|
double mblur = 0.; /* motion blur parameter */ |
| 63 |
|
|
| 64 |
+ |
double dblur = 0.; /* depth-of-field blur parameter */ |
| 65 |
+ |
|
| 66 |
|
void (*trace)() = NULL; /* trace call */ |
| 67 |
|
|
| 68 |
|
int do_irrad = 0; /* compute irradiance? */ |
| 69 |
|
|
| 70 |
+ |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
| 71 |
+ |
|
| 72 |
|
double dstrsrc = 0.0; /* square source distribution */ |
| 73 |
|
double shadthresh = .05; /* shadow threshold */ |
| 74 |
|
double shadcert = .5; /* shadow certainty */ |
| 87 |
|
|
| 88 |
|
int backvis = 1; /* back face visibility */ |
| 89 |
|
|
| 90 |
< |
int maxdepth = 6; /* maximum recursion depth */ |
| 91 |
< |
double minweight = 5e-3; /* minimum ray weight */ |
| 90 |
> |
int maxdepth = 7; /* maximum recursion depth */ |
| 91 |
> |
double minweight = 4e-3; /* minimum ray weight */ |
| 92 |
|
|
| 93 |
|
char *ambfile = NULL; /* ambient file name */ |
| 94 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
| 95 |
|
int ambvwt = 0; /* initial weight for ambient value */ |
| 96 |
|
double ambacc = 0.2; /* ambient accuracy */ |
| 97 |
< |
int ambres = 32; /* ambient resolution */ |
| 98 |
< |
int ambdiv = 128; /* ambient divisions */ |
| 99 |
< |
int ambssamp = 0; /* ambient super-samples */ |
| 97 |
> |
int ambres = 64; /* ambient resolution */ |
| 98 |
> |
int ambdiv = 512; /* ambient divisions */ |
| 99 |
> |
int ambssamp = 128; /* ambient super-samples */ |
| 100 |
|
int ambounce = 0; /* ambient bounces */ |
| 101 |
< |
char *amblist[128]; /* ambient include/exclude list */ |
| 101 |
> |
char *amblist[AMBLLEN]; /* ambient include/exclude list */ |
| 102 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
| 103 |
|
|
| 104 |
|
int ralrm = 0; /* seconds between reports */ |
| 115 |
|
|
| 116 |
|
static VIEW lastview; /* the previous view input */ |
| 117 |
|
|
| 118 |
< |
extern char *mktemp(); |
| 118 |
> |
//extern char *mktemp(); /* XXX should be in stdlib.h or unistd.h */ |
| 119 |
|
|
| 120 |
< |
void report(); |
| 120 |
> |
//double pixvalue(); |
| 121 |
|
|
| 122 |
< |
double pixvalue(); |
| 122 |
> |
static void report(int); |
| 123 |
> |
static int nextview(FILE *fp); |
| 124 |
> |
static void render(char *zfile, char *oldfile); |
| 125 |
> |
static void fillscanline(COLOR *scanline, float *zline, char *sd, int xres, |
| 126 |
> |
int y, int xstep); |
| 127 |
> |
static void fillscanbar(COLOR *scanbar[], float *zbar[], int xres, |
| 128 |
> |
int y, int ysize); |
| 129 |
> |
static int fillsample(COLOR *colline, float *zline, int x, int y, |
| 130 |
> |
int xlen, int ylen, int b); |
| 131 |
> |
static double pixvalue(COLOR col, int x, int y); |
| 132 |
> |
static int salvage(char *oldfile); |
| 133 |
> |
static int pixnumber(int x, int y, int xres, int yres); |
| 134 |
|
|
| 135 |
< |
#ifdef NIX |
| 136 |
< |
#define file_exists(f) (access(f,F_OK)==0) |
| 137 |
< |
#else |
| 135 |
> |
|
| 136 |
> |
|
| 137 |
> |
#ifdef RHAS_STAT |
| 138 |
|
#include <sys/types.h> |
| 139 |
|
#include <sys/stat.h> |
| 140 |
|
int |
| 145 |
|
if (stat(fname, &sbuf) < 0) return(0); |
| 146 |
|
return((sbuf.st_mode & S_IFREG) != 0); |
| 147 |
|
} |
| 148 |
+ |
#else |
| 149 |
+ |
#define file_exists(f) (access(f,F_OK)==0) |
| 150 |
|
#endif |
| 151 |
|
|
| 152 |
|
|
| 155 |
|
int code; |
| 156 |
|
{ |
| 157 |
|
if (code) /* report status */ |
| 158 |
< |
report(); |
| 159 |
< |
#ifndef NIX |
| 158 |
> |
report(0); |
| 159 |
> |
#ifndef NON_POSIX |
| 160 |
|
headclean(); /* delete header file */ |
| 161 |
|
pfclean(); /* clean up persist files */ |
| 162 |
|
#endif |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
|
| 167 |
< |
#ifndef NIX |
| 168 |
< |
void |
| 169 |
< |
report() /* report progress */ |
| 167 |
> |
#ifndef NON_POSIX |
| 168 |
> |
static void |
| 169 |
> |
report(int dummy) /* report progress */ |
| 170 |
|
{ |
| 151 |
– |
extern char *myhostname(); |
| 171 |
|
double u, s; |
| 172 |
|
#ifdef BSD |
| 173 |
|
struct rusage rubuf; |
| 200 |
|
nrays, pctdone, u/3600., s/3600., |
| 201 |
|
(tlastrept-tstart)/3600., myhostname()); |
| 202 |
|
eputs(errmsg); |
| 203 |
< |
#ifndef BSD |
| 203 |
> |
#ifdef SIGCONT |
| 204 |
|
signal(SIGCONT, report); |
| 205 |
|
#endif |
| 206 |
|
} |
| 207 |
|
#else |
| 208 |
< |
void |
| 209 |
< |
report() /* report progress */ |
| 208 |
> |
static void |
| 209 |
> |
report(int dummy) /* report progress */ |
| 210 |
|
{ |
| 211 |
|
tlastrept = time((time_t *)NULL); |
| 212 |
|
sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n", |
| 216 |
|
#endif |
| 217 |
|
|
| 218 |
|
|
| 219 |
< |
void |
| 220 |
< |
rpict(seq, pout, zout, prvr) /* generate image(s) */ |
| 221 |
< |
int seq; |
| 222 |
< |
char *pout, *zout, *prvr; |
| 219 |
> |
extern void |
| 220 |
> |
rpict( /* generate image(s) */ |
| 221 |
> |
int seq, |
| 222 |
> |
char *pout, |
| 223 |
> |
char *zout, |
| 224 |
> |
char *prvr |
| 225 |
> |
) |
| 226 |
|
/* |
| 227 |
|
* If seq is greater than zero, then we will render a sequence of |
| 228 |
|
* images based on view parameter strings read from the standard input. |
| 235 |
|
* sequenced file naming. |
| 236 |
|
*/ |
| 237 |
|
{ |
| 216 |
– |
extern char *rindex(), *strncpy(), *strcat(), *strcpy(); |
| 238 |
|
char fbuf[128], fbuf2[128]; |
| 239 |
|
int npicts; |
| 240 |
|
register char *cp; |
| 264 |
|
setview(&ourview); |
| 265 |
|
prvr = fbuf; /* mark for renaming */ |
| 266 |
|
} |
| 267 |
< |
if (pout != NULL & prvr != NULL) { |
| 267 |
> |
if ((pout != NULL) & (prvr != NULL)) { |
| 268 |
|
sprintf(fbuf, pout, seq); |
| 269 |
|
if (!strcmp(prvr, fbuf)) { /* rename */ |
| 270 |
|
strcpy(fbuf2, fbuf); |
| 274 |
|
cp--; |
| 275 |
|
strcpy(cp, RFTEMPLATE); |
| 276 |
|
prvr = mktemp(fbuf2); |
| 277 |
< |
if (rename(fbuf, prvr) < 0) |
| 277 |
> |
if (rename(fbuf, prvr) < 0) { |
| 278 |
|
if (errno == ENOENT) { /* ghost file */ |
| 279 |
|
sprintf(errmsg, |
| 280 |
|
"new output file \"%s\"", |
| 287 |
|
fbuf, prvr); |
| 288 |
|
error(SYSTEM, errmsg); |
| 289 |
|
} |
| 290 |
+ |
} |
| 291 |
|
} |
| 292 |
|
} |
| 293 |
|
npicts = 0; /* render sequence */ |
| 312 |
|
"cannot open output file \"%s\"", fbuf); |
| 313 |
|
error(SYSTEM, errmsg); |
| 314 |
|
} |
| 315 |
< |
#ifdef MSDOS |
| 294 |
< |
setmode(fileno(stdout), O_BINARY); |
| 295 |
< |
#endif |
| 315 |
> |
SET_FILE_BINARY(stdout); |
| 316 |
|
dupheader(); |
| 317 |
|
} |
| 318 |
|
hres = hresolu; vres = vresolu; pa = pixaspect; |
| 319 |
< |
if (prvr != NULL) |
| 320 |
< |
if (viewfile(prvr, &ourview, &rs) <= 0 |
| 301 |
< |
|| rs.rt != PIXSTANDARD) { |
| 319 |
> |
if (prvr != NULL) { |
| 320 |
> |
if (viewfile(prvr, &ourview, &rs) <= 0) { |
| 321 |
|
sprintf(errmsg, |
| 322 |
|
"cannot recover view parameters from \"%s\"", prvr); |
| 323 |
|
error(WARNING, errmsg); |
| 326 |
|
hres = scanlen(&rs); |
| 327 |
|
vres = numscans(&rs); |
| 328 |
|
} |
| 329 |
+ |
} |
| 330 |
|
if ((cp = setview(&ourview)) != NULL) |
| 331 |
|
error(USER, cp); |
| 332 |
|
normaspect(viewaspect(&ourview), &pa, &hres, &vres); |
| 344 |
|
putchar('\n'); |
| 345 |
|
if (pa < .99 || pa > 1.01) |
| 346 |
|
fputaspect(pa, stdout); |
| 347 |
+ |
fputnow(stdout); |
| 348 |
|
fputformat(COLRFMT, stdout); |
| 349 |
|
putchar('\n'); |
| 350 |
|
if (zout != NULL) |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
|
| 364 |
< |
nextview(fp) /* get next view from fp */ |
| 365 |
< |
FILE *fp; |
| 364 |
> |
static int |
| 365 |
> |
nextview( /* get next view from fp */ |
| 366 |
> |
FILE *fp |
| 367 |
> |
) |
| 368 |
|
{ |
| 369 |
|
char linebuf[256]; |
| 370 |
|
|
| 371 |
< |
copystruct(&lastview, &ourview); |
| 371 |
> |
lastview = ourview; |
| 372 |
|
while (fgets(linebuf, sizeof(linebuf), fp) != NULL) |
| 373 |
|
if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) |
| 374 |
|
return(0); |
| 376 |
|
} |
| 377 |
|
|
| 378 |
|
|
| 379 |
< |
render(zfile, oldfile) /* render the scene */ |
| 380 |
< |
char *zfile, *oldfile; |
| 379 |
> |
static void |
| 380 |
> |
render( /* render the scene */ |
| 381 |
> |
char *zfile, |
| 382 |
> |
char *oldfile |
| 383 |
> |
) |
| 384 |
|
{ |
| 385 |
|
COLOR *scanbar[MAXDIV+1]; /* scanline arrays of pixel values */ |
| 386 |
|
float *zbar[MAXDIV+1]; /* z values */ |
| 420 |
|
sprintf(errmsg, "cannot open z-file \"%s\"", zfile); |
| 421 |
|
error(SYSTEM, errmsg); |
| 422 |
|
} |
| 423 |
< |
#ifdef MSDOS |
| 398 |
< |
setmode(zfd, O_BINARY); |
| 399 |
< |
#endif |
| 423 |
> |
SET_FD_BINARY(zfd); |
| 424 |
|
for (i = 0; i <= psample; i++) { |
| 425 |
|
zbar[i] = (float *)malloc(hres*sizeof(float)); |
| 426 |
|
if (zbar[i] == NULL) |
| 438 |
|
if (i >= vres) |
| 439 |
|
goto alldone; |
| 440 |
|
if (zfd != -1 && i > 0 && |
| 441 |
< |
lseek(zfd, (off_t)i*hres*sizeof(float), 0) < 0) |
| 441 |
> |
lseek(zfd, (off_t)i*hres*sizeof(float), SEEK_SET) < 0) |
| 442 |
|
error(SYSTEM, "z-file seek error in render"); |
| 443 |
|
pctdone = 100.0*i/vres; |
| 444 |
|
if (ralrm > 0) /* report init stats */ |
| 445 |
< |
report(); |
| 446 |
< |
#ifndef BSD |
| 445 |
> |
report(0); |
| 446 |
> |
#ifdef SIGCONT |
| 447 |
|
else |
| 424 |
– |
#endif |
| 448 |
|
signal(SIGCONT, report); |
| 449 |
+ |
#endif |
| 450 |
|
ypos = vres-1 - i; /* initialize sampling */ |
| 451 |
|
if (directvis) |
| 452 |
|
init_drawsources(psample); |
| 472 |
|
if (directvis) /* add bitty sources */ |
| 473 |
|
drawsources(scanbar, zbar, 0, hres, ypos, ystep); |
| 474 |
|
/* write it out */ |
| 475 |
< |
#ifndef BSD |
| 475 |
> |
#ifdef SIGCONT |
| 476 |
|
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
| 477 |
|
#endif |
| 478 |
|
for (i = ystep; i > 0; i--) { |
| 488 |
|
/* record progress */ |
| 489 |
|
pctdone = 100.0*(vres-1-ypos)/vres; |
| 490 |
|
if (ralrm > 0 && time((time_t *)NULL) >= tlastrept+ralrm) |
| 491 |
< |
report(); |
| 492 |
< |
#ifndef BSD |
| 491 |
> |
report(0); |
| 492 |
> |
#ifdef SIGCONT |
| 493 |
|
else |
| 494 |
|
signal(SIGCONT, report); |
| 495 |
|
#endif |
| 496 |
|
} |
| 497 |
|
/* clean up */ |
| 498 |
+ |
#ifdef SIGCONT |
| 499 |
|
signal(SIGCONT, SIG_IGN); |
| 500 |
+ |
#endif |
| 501 |
|
if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float)) |
| 502 |
|
< hres*sizeof(float)) |
| 503 |
|
goto writerr; |
| 517 |
|
free(sampdens); |
| 518 |
|
pctdone = 100.0; |
| 519 |
|
if (ralrm > 0) |
| 520 |
< |
report(); |
| 520 |
> |
report(0); |
| 521 |
> |
#ifdef SIGCONT |
| 522 |
|
signal(SIGCONT, SIG_DFL); |
| 523 |
+ |
#endif |
| 524 |
|
return; |
| 525 |
|
writerr: |
| 526 |
|
error(SYSTEM, "write error in render"); |
| 529 |
|
} |
| 530 |
|
|
| 531 |
|
|
| 532 |
< |
fillscanline(scanline, zline, sd, xres, y, xstep) /* fill scan at y */ |
| 533 |
< |
register COLOR *scanline; |
| 534 |
< |
register float *zline; |
| 535 |
< |
register char *sd; |
| 536 |
< |
int xres, y, xstep; |
| 532 |
> |
static void |
| 533 |
> |
fillscanline( /* fill scan at y */ |
| 534 |
> |
register COLOR *scanline, |
| 535 |
> |
register float *zline, |
| 536 |
> |
register char *sd, |
| 537 |
> |
int xres, |
| 538 |
> |
int y, |
| 539 |
> |
int xstep |
| 540 |
> |
) |
| 541 |
|
{ |
| 542 |
|
static int nc = 0; /* number of calls */ |
| 543 |
|
int bl = xstep, b = xstep; |
| 568 |
|
} |
| 569 |
|
|
| 570 |
|
|
| 571 |
< |
fillscanbar(scanbar, zbar, xres, y, ysize) /* fill interior */ |
| 572 |
< |
register COLOR *scanbar[]; |
| 573 |
< |
register float *zbar[]; |
| 574 |
< |
int xres, y, ysize; |
| 571 |
> |
static void |
| 572 |
> |
fillscanbar( /* fill interior */ |
| 573 |
> |
register COLOR *scanbar[], |
| 574 |
> |
register float *zbar[], |
| 575 |
> |
int xres, |
| 576 |
> |
int y, |
| 577 |
> |
int ysize |
| 578 |
> |
) |
| 579 |
|
{ |
| 580 |
|
COLOR vline[MAXDIV+1]; |
| 581 |
|
float zline[MAXDIV+1]; |
| 601 |
|
} |
| 602 |
|
|
| 603 |
|
|
| 604 |
< |
int |
| 605 |
< |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
| 606 |
< |
register COLOR *colline; |
| 607 |
< |
register float *zline; |
| 608 |
< |
int x, y; |
| 609 |
< |
int xlen, ylen; |
| 610 |
< |
int b; |
| 604 |
> |
static int |
| 605 |
> |
fillsample( /* fill interior points */ |
| 606 |
> |
register COLOR *colline, |
| 607 |
> |
register float *zline, |
| 608 |
> |
int x, |
| 609 |
> |
int y, |
| 610 |
> |
int xlen, |
| 611 |
> |
int ylen, |
| 612 |
> |
int b |
| 613 |
> |
) |
| 614 |
|
{ |
| 615 |
|
double ratio; |
| 616 |
|
double z; |
| 657 |
|
} |
| 658 |
|
|
| 659 |
|
|
| 660 |
< |
double |
| 661 |
< |
pixvalue(col, x, y) /* compute pixel value */ |
| 662 |
< |
COLOR col; /* returned color */ |
| 663 |
< |
int x, y; /* pixel position */ |
| 660 |
> |
static double |
| 661 |
> |
pixvalue( /* compute pixel value */ |
| 662 |
> |
COLOR col, /* returned color */ |
| 663 |
> |
int x, /* pixel position */ |
| 664 |
> |
int y |
| 665 |
> |
) |
| 666 |
|
{ |
| 667 |
|
RAY thisray; |
| 668 |
|
FVECT lorg, ldir; |
| 669 |
< |
double hpos, vpos, lmax, d; |
| 669 |
> |
double hpos, vpos, vdist, lmax; |
| 670 |
> |
register int i; |
| 671 |
|
/* compute view ray */ |
| 672 |
|
hpos = (x+pixjitter())/hres; |
| 673 |
|
vpos = (y+pixjitter())/vres; |
| 676 |
|
setcolor(col, 0.0, 0.0, 0.0); |
| 677 |
|
return(0.0); |
| 678 |
|
} |
| 679 |
+ |
vdist = ourview.vdist; |
| 680 |
|
|
| 681 |
< |
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
| 681 |
> |
if (rand_samp) /* set pixel index */ |
| 682 |
> |
samplendx = random(); |
| 683 |
> |
else |
| 684 |
> |
samplendx = pixnumber(x,y,hres,vres); |
| 685 |
|
|
| 686 |
|
/* optional motion blur */ |
| 687 |
|
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
| 688 |
|
&lastview, hpos, vpos)) >= -FTINY) { |
| 643 |
– |
register int i; |
| 689 |
|
register double d = mblur*(.5-urand(281+samplendx)); |
| 690 |
|
|
| 691 |
|
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
| 695 |
|
} |
| 696 |
|
if (normalize(thisray.rdir) == 0.0) |
| 697 |
|
return(0.0); |
| 698 |
+ |
vdist = (1.-d)*vdist + d*lastview.vdist; |
| 699 |
|
} |
| 700 |
+ |
/* optional depth-of-field */ |
| 701 |
+ |
if (dblur > FTINY && vdist > FTINY) { |
| 702 |
+ |
double vc, dfh, dfv; |
| 703 |
+ |
/* PI/4. square/circle conv. */ |
| 704 |
+ |
dfh = PI/4.*dblur*(.5 - frandom()); |
| 705 |
+ |
dfv = PI/4.*dblur*(.5 - frandom()); |
| 706 |
+ |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
| 707 |
+ |
dfh /= sqrt(ourview.hn2); |
| 708 |
+ |
dfv /= sqrt(ourview.vn2); |
| 709 |
+ |
for (i = 3; i--; ) { |
| 710 |
+ |
vc = thisray.rorg[i] + 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) { |
| 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]; |
| 724 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
| 725 |
+ |
dfv*ourview.vvec[i] + |
| 726 |
+ |
dfd*ourview.vdir[i] ; |
| 727 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
| 728 |
+ |
} |
| 729 |
+ |
} |
| 730 |
+ |
if (normalize(thisray.rdir) == 0.0) |
| 731 |
+ |
return(0.0); |
| 732 |
+ |
} |
| 733 |
|
|
| 734 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
| 734 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
| 735 |
|
|
| 736 |
|
rayvalue(&thisray); /* trace ray */ |
| 737 |
|
|
| 741 |
|
} |
| 742 |
|
|
| 743 |
|
|
| 744 |
< |
int |
| 745 |
< |
salvage(oldfile) /* salvage scanlines from killed program */ |
| 746 |
< |
char *oldfile; |
| 744 |
> |
static int |
| 745 |
> |
salvage( /* salvage scanlines from killed program */ |
| 746 |
> |
char *oldfile |
| 747 |
> |
) |
| 748 |
|
{ |
| 749 |
|
COLR *scanline; |
| 750 |
|
FILE *fp; |
| 758 |
|
error(WARNING, errmsg); |
| 759 |
|
goto gotzip; |
| 760 |
|
} |
| 761 |
< |
#ifdef MSDOS |
| 682 |
< |
setmode(fileno(fp), O_BINARY); |
| 683 |
< |
#endif |
| 761 |
> |
SET_FILE_BINARY(fp); |
| 762 |
|
/* discard header */ |
| 763 |
|
getheader(fp, NULL, NULL); |
| 764 |
|
/* get picture size */ |
| 798 |
|
writerr: |
| 799 |
|
sprintf(errmsg, "write error during recovery of \"%s\"", oldfile); |
| 800 |
|
error(SYSTEM, errmsg); |
| 801 |
+ |
return -1; /* pro forma return */ |
| 802 |
|
} |
| 803 |
|
|
| 804 |
< |
|
| 805 |
< |
int |
| 806 |
< |
pixnumber(x, y, xres, yres) /* compute pixel index (brushed) */ |
| 807 |
< |
register int x, y; |
| 808 |
< |
int xres, yres; |
| 804 |
> |
static int |
| 805 |
> |
pixnumber( /* compute pixel index (brushed) */ |
| 806 |
> |
register int x, |
| 807 |
> |
register int y, |
| 808 |
> |
int xres, |
| 809 |
> |
int yres |
| 810 |
> |
) |
| 811 |
|
{ |
| 812 |
|
x -= y; |
| 813 |
|
while (x < 0) |