--- ray/src/util/vwrays.c 2003/07/27 22:12:04 3.7 +++ ray/src/util/vwrays.c 2005/01/20 23:52:02 3.11 @@ -1,19 +1,22 @@ #ifndef lint -static const char RCSid[] = "$Id: vwrays.c,v 3.7 2003/07/27 22:12:04 schorsch Exp $"; +static const char RCSid[] = "$Id: vwrays.c,v 3.11 2005/01/20 23:52:02 greg Exp $"; #endif /* * Compute rays corresponding to a given picture or view. */ - -#include "standard.h" - #include "platform.h" +#include "standard.h" #include "view.h" -extern int putf(), putd(), puta(); +typedef void putfunc(FVECT ro, FVECT rd); +static putfunc puta; +static putfunc putf; +static putfunc putd; +static void pix2rays(FILE *fp); +static void putrays(void); -int (*putr)() = puta; +static putfunc *putr = puta; VIEW vw = STDVIEW; @@ -28,9 +31,11 @@ int fromstdin = 0; char *progname; -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { char *err; int rval, getdim = 0; @@ -142,7 +147,10 @@ userr: } -pix2rays(FILE *fp) +static void +pix2rays( + FILE *fp +) { static FVECT rorg, rdir; float zval; @@ -152,6 +160,7 @@ pix2rays(FILE *fp) register int i; while (fscanf(fp, "%lf %lf", &px, &py) == 2) { + px += .5; py += .5; if (px < 0 || px >= rs.xr || py < 0 || py >= rs.yr) { fprintf(stderr, @@ -162,10 +171,10 @@ pix2rays(FILE *fp) if (zfd >= 0) { loc2pix(pp, &rs, px/rs.xr, py/rs.yr); if (lseek(zfd, - (pp[1]*scanlen(&rs)+pp[0])*sizeof(float), 0) - < 0 || + (pp[1]*scanlen(&rs)+pp[0])*sizeof(float), + SEEK_SET) < 0 || read(zfd, &zval, sizeof(float)) - < sizeof(float)) { + < sizeof(float)) { fprintf(stderr, "%s: depth buffer read error\n", progname); exit(1); @@ -192,11 +201,12 @@ pix2rays(FILE *fp) } -putrays() +static void +putrays(void) { static RREAL loc[2]; static FVECT rorg, rdir; - float *zbuf; + float *zbuf = NULL; int sc; double d; register int si, i; @@ -239,8 +249,11 @@ putrays() } -puta(ro, rd) /* put out ray in ASCII format */ -FVECT ro, rd; +static void +puta( /* put out ray in ASCII format */ + FVECT ro, + FVECT rd +) { printf("%.5e %.5e %.5e %.5e %.5e %.5e\n", ro[0], ro[1], ro[2], @@ -248,8 +261,11 @@ FVECT ro, rd; } -putf(ro, rd) /* put out ray in float format */ -FVECT ro, rd; +static void +putf( /* put out ray in float format */ + FVECT ro, + FVECT rd +) { float v[6]; @@ -259,8 +275,11 @@ FVECT ro, rd; } -putd(ro, rd) /* put out ray in double format */ -FVECT ro, rd; +static void +putd( /* put out ray in double format */ + FVECT ro, + FVECT rd +) { double v[6];