ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/vwrays.c
(Generate patch)

Comparing ray/src/util/vwrays.c (file contents):
Revision 3.22 by greg, Fri Dec 3 17:22:28 2021 UTC vs.
Revision 3.26 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 27 | Line 27 | double pa = 1.;
27  
28   double  pj = 0.;
29  
30 + double  pd = 0.;
31 +
32   int     zfd = -1;
33  
34   int     fromstdin = 0;
# Line 35 | Line 37 | int    unbuffered = 0;
37  
38   int     repeatcnt = 1;
39  
38 char    *progname;
40  
40
41   int
42   main(
43          int     argc,
# Line 48 | Line 48 | main(
48          int     rval, getdim = 0;
49          int     i;
50  
51 <        progname = argv[0];
51 >        fixargv0(argv[0]);              /* sets global progname */
52          if (argc < 2)
53                  goto userr;
54          for (i = 1; i < argc && argv[i][0] == '-'; i++)
# Line 77 | Line 77 | main(
77                                          fprintf(stderr,
78                                                  "%s: no view in file\n",
79                                                          argv[i]);
80 <                                        exit(1);
80 >                                        return(1);
81                                  }
82                                  break;
83                          }
# Line 94 | Line 94 | main(
94                          if (rs.xr <= 0) {
95                                  fprintf(stderr, "%s: bad x resolution\n",
96                                                  progname);
97 <                                exit(1);
97 >                                return(1);
98                          }
99                          break;
100                  case 'y':                       /* y resolution */
# Line 102 | Line 102 | main(
102                          if (rs.yr <= 0) {
103                                  fprintf(stderr, "%s: bad y resolution\n",
104                                                  progname);
105 <                                exit(1);
105 >                                return(1);
106                          }
107                          break;
108                  case 'c':                       /* repeat count */
109                          repeatcnt = atoi(argv[++i]);
110 +                        if (repeatcnt < 1) repeatcnt = 1;
111                          break;
112                  case 'p':                       /* pixel aspect or jitter */
113                          if (argv[i][2] == 'a')
114                                  pa = atof(argv[++i]);
115                          else if (argv[i][2] == 'j')
116                                  pj = atof(argv[++i]);
117 +                        else if (argv[i][2] == 'd')
118 +                                pd = atof(argv[++i]);
119                          else
120                                  goto userr;
121                          break;
# Line 131 | Line 134 | main(
134                  rval = viewfile(argv[i], &vw, &rs);
135                  if (rval <= 0) {
136                          fprintf(stderr, "%s: no view in picture\n", argv[i]);
137 <                        exit(1);
137 >                        return(1);
138                  }
139                  if (!getdim & (i+1 < argc)) {
140                          zfd = open_float_depth(argv[i+1], (long)rs.xr*rs.yr);
141                          if (zfd < 0)
142 <                                exit(1);
142 >                                return(1);
143                  }
144          }
145          if ((err = setview(&vw)) != NULL) {
146                  fprintf(stderr, "%s: %s\n", progname, err);
147 <                exit(1);
147 >                return(1);
148          }
149          if (i == argc)
150                  normaspect(viewaspect(&vw), &pa, &rs.xr, &rs.yr);
151          if (getdim) {
152 <                printf("-x %d -y %d -ld%c\n", rs.xr, rs.yr,
153 <                                (i+1 == argc) & (vw.vaft > FTINY) ? '+' : '-');
154 <                exit(0);
152 >                printf("-x %d -y %d%s\n", rs.xr, rs.yr,
153 >                                (vw.vaft > FTINY) ? " -ld+" : "");
154 >                return(0);
155          }
156 +        if ((repeatcnt > 1) & (pj > FTINY))
157 +                initurand(1024);
158          if (fromstdin)
159                  pix2rays(stdin);
160          else
161                  putrays();
162 <        exit(0);
162 >        return(0);
163   userr:
164          fprintf(stderr,
165          "Usage: %s [ -i -u -f{a|f|d} -c rept | -d ] { view opts .. | picture [zbuf] }\n",
166                          progname);
167 <        exit(1);
167 >        return(1);
168   }
169  
170  
# Line 168 | Line 173 | jitterloc(
173          RREAL   loc[2]
174   )
175   {
176 <        if (pj > FTINY) {
177 <                loc[0] += pj*(.5 - frandom())/rs.xr;
178 <                loc[1] += pj*(.5 - frandom())/rs.yr;
179 <        }
176 >        static int      nsamp;
177 >        double          xyr[2];
178 >
179 >        if (pj <= FTINY)
180 >                return;
181 >
182 >        if (repeatcnt == 1) {
183 >                xyr[0] = frandom();
184 >                xyr[1] = frandom();
185 >        } else                          /* stratify samples */
186 >                multisamp(xyr, 2, urand(nsamp++));
187 >
188 >        loc[0] += pj*(.5 - xyr[0])/rs.xr;
189 >        loc[1] += pj*(.5 - xyr[1])/rs.yr;
190   }
191  
192  
# Line 212 | Line 227 | pix2rays(
227                  for (c = repeatcnt; c-- > 0; ) {
228                          jitterloc(loc);
229                          d = viewray(rorg, rdir, &vw, loc[0], loc[1]);
230 <                        if (d < -FTINY)
230 >                        if (d < -FTINY || !jitteraperture(rorg, rdir, &vw, pd))
231                                  rorg[0] = rorg[1] = rorg[2] =
232                                  rdir[0] = rdir[1] = rdir[2] = 0.;
233                          else if (zfd >= 0)
# Line 269 | Line 284 | putrays(void)
284                          pix2loc(loc, &rs, si, sc);
285                          jitterloc(loc);
286                          d = viewray(rorg, rdir, &vw, loc[0], loc[1]);
287 <                        if (d < -FTINY)
287 >                        if (d < -FTINY || !jitteraperture(rorg, rdir, &vw, pd))
288                                  rorg[0] = rorg[1] = rorg[2] =
289                                  rdir[0] = rdir[1] = rdir[2] = 0.;
290                          else if (zfd >= 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines