--- ray/src/util/vwrays.c 2009/06/22 00:12:04 3.14 +++ ray/src/util/vwrays.c 2012/06/14 05:19:05 3.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: vwrays.c,v 3.14 2009/06/22 00:12:04 greg Exp $"; +static const char RCSid[] = "$Id: vwrays.c,v 3.17 2012/06/14 05:19:05 greg Exp $"; #endif /* * Compute rays corresponding to a given picture or view. @@ -31,6 +31,10 @@ int zfd = -1; int fromstdin = 0; +int unbuffered = 0; + +int repeatcnt = 1; + char *progname; @@ -42,7 +46,7 @@ main( { char *err; int rval, getdim = 0; - register int i; + int i; progname = argv[0]; if (argc < 2) @@ -101,17 +105,23 @@ main( exit(1); } break; + case 'c': /* repeat count */ + repeatcnt = atoi(argv[++i]); + break; case 'p': /* pixel aspect or jitter */ if (argv[i][2] == 'a') pa = atof(argv[++i]); else if (argv[i][2] == 'j') - pj= atof(argv[++i]); + pj = atof(argv[++i]); else goto userr; break; case 'i': /* get pixels from stdin */ fromstdin = 1; break; + case 'u': /* unbuffered output */ + unbuffered = 1; + break; default: goto userr; } @@ -151,7 +161,7 @@ main( exit(0); userr: fprintf(stderr, - "Usage: %s [ -i -f{a|f|d} | -d ] { view opts .. | picture [zbuf] }\n", + "Usage: %s [ -i -u -f{a|f|d} -c rept | -d ] { view opts .. | picture [zbuf] }\n", progname); exit(1); } @@ -180,7 +190,7 @@ pix2rays( RREAL loc[2]; int pp[2]; double d; - register int i; + int i; while (fscanf(fp, "%lf %lf", &px, &py) == 2) { px += .5; py += .5; @@ -211,6 +221,8 @@ pix2rays( rdir[0] *= d; rdir[1] *= d; rdir[2] *= d; } (*putr)(rorg, rdir); + if (unbuffered) + fflush(stdout); } if (!feof(fp)) { fprintf(stderr, "%s: expected px py on input\n", progname); @@ -227,7 +239,7 @@ putrays(void) float *zbuf = NULL; int sc; double d; - register int si, i; + int si, i, c; if (zfd >= 0) { zbuf = (float *)malloc(scanlen(&rs)*sizeof(float)); @@ -246,6 +258,7 @@ putrays(void) } } for (si = 0; si < scanlen(&rs); si++) { + for (c = repeatcnt; c-- > 0; ) { pix2loc(loc, &rs, si, sc); jitterloc(loc); d = viewray(rorg, rdir, &vw, loc[0], loc[1]); @@ -261,6 +274,7 @@ putrays(void) rdir[0] *= d; rdir[1] *= d; rdir[2] *= d; } (*putr)(rorg, rdir); + } } } if (zfd >= 0)