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.17 by greg, Thu Jun 14 05:19:05 2012 UTC vs.
Revision 3.22 by greg, Fri Dec 3 17:22:28 2021 UTC

# Line 133 | Line 133 | main(
133                          fprintf(stderr, "%s: no view in picture\n", argv[i]);
134                          exit(1);
135                  }
136 <                if (i+1 < argc) {
137 <                        zfd = open(argv[i+1], O_RDONLY);
138 <                        if (zfd < 0) {
139 <                                fprintf(stderr,
140 <                                        "%s: cannot open depth buffer\n",
141 <                                                argv[i+1]);
136 >                if (!getdim & (i+1 < argc)) {
137 >                        zfd = open_float_depth(argv[i+1], (long)rs.xr*rs.yr);
138 >                        if (zfd < 0)
139                                  exit(1);
143                        }
140                  }
141          }
142          if ((err = setview(&vw)) != NULL) {
# Line 151 | Line 147 | main(
147                  normaspect(viewaspect(&vw), &pa, &rs.xr, &rs.yr);
148          if (getdim) {
149                  printf("-x %d -y %d -ld%c\n", rs.xr, rs.yr,
150 <                                vw.vaft > FTINY ? '+' : '-');
150 >                                (i+1 == argc) & (vw.vaft > FTINY) ? '+' : '-');
151                  exit(0);
152          }
153          if (fromstdin)
# Line 190 | Line 186 | pix2rays(
186          RREAL   loc[2];
187          int     pp[2];
188          double  d;
189 <        int     i;
189 >        int     i, c;
190  
191          while (fscanf(fp, "%lf %lf", &px, &py) == 2) {
192                  px += .5; py += .5;
193                  loc[0] = px/rs.xr; loc[1] = py/rs.yr;
194                  if (zfd >= 0) {
195 +                        if ((loc[0] < 0) | (loc[0] >= 1) |
196 +                                        (loc[1] < 0) | (loc[1] >= 1)) {
197 +                                fprintf(stderr, "%s: input pixel outside image\n",
198 +                                                progname);
199 +                                exit(1);
200 +                        }
201                          loc2pix(pp, &rs, loc[0], loc[1]);
202                          if (lseek(zfd,
203                                  (pp[1]*scanlen(&rs)+pp[0])*sizeof(float),
# Line 207 | Line 209 | pix2rays(
209                                  exit(1);
210                          }
211                  }
212 <                jitterloc(loc);
213 <                d = viewray(rorg, rdir, &vw, loc[0], loc[1]);
214 <                if (d < -FTINY)
215 <                        rorg[0] = rorg[1] = rorg[2] =
216 <                        rdir[0] = rdir[1] = rdir[2] = 0.;
217 <                else if (zfd >= 0)
218 <                        for (i = 0; i < 3; i++) {
219 <                                rorg[i] += rdir[i]*zval;
220 <                                rdir[i] = -rdir[i];
212 >                for (c = repeatcnt; c-- > 0; ) {
213 >                        jitterloc(loc);
214 >                        d = viewray(rorg, rdir, &vw, loc[0], loc[1]);
215 >                        if (d < -FTINY)
216 >                                rorg[0] = rorg[1] = rorg[2] =
217 >                                rdir[0] = rdir[1] = rdir[2] = 0.;
218 >                        else if (zfd >= 0)
219 >                                for (i = 0; i < 3; i++) {
220 >                                        rorg[i] += rdir[i]*zval;
221 >                                        rdir[i] = -rdir[i];
222 >                                }
223 >                        else if (d > FTINY) {
224 >                                rdir[0] *= d; rdir[1] *= d; rdir[2] *= d;
225                          }
226 <                else if (d > FTINY) {
227 <                        rdir[0] *= d; rdir[1] *= d; rdir[2] *= d;
226 >                        (*putr)(rorg, rdir);
227 >                        if (c) {
228 >                                loc[0] = px/rs.xr; loc[1] = py/rs.yr;
229 >                        }
230                  }
223                (*putr)(rorg, rdir);
231                  if (unbuffered)
232                          fflush(stdout);
233          }
# Line 267 | Line 274 | putrays(void)
274                                  rdir[0] = rdir[1] = rdir[2] = 0.;
275                          else if (zfd >= 0)
276                                  for (i = 0; i < 3; i++) {
277 <                                        rorg[i] += rdir[i]*zbuf[si];
278 <                                        rdir[i] = -rdir[i];
277 >                                        rdir[i] = -rdir[i]*zbuf[si];
278 >                                        rorg[i] -= rdir[i];
279                                  }
280                          else if (d > FTINY) {
281                                  rdir[0] *= d; rdir[1] *= d; rdir[2] *= d;
# Line 304 | Line 311 | putf(          /* put out ray in float format */
311  
312          v[0] = ro[0]; v[1] = ro[1]; v[2] = ro[2];
313          v[3] = rd[0]; v[4] = rd[1]; v[5] = rd[2];
314 <        fwrite(v, sizeof(float), 6, stdout);
314 >        putbinary(v, sizeof(float), 6, stdout);
315   }
316  
317  
# Line 318 | Line 325 | putd(          /* put out ray in double format */
325  
326          v[0] = ro[0]; v[1] = ro[1]; v[2] = ro[2];
327          v[3] = rd[0]; v[4] = rd[1]; v[5] = rd[2];
328 <        fwrite(v, sizeof(double), 6, stdout);
328 >        putbinary(v, sizeof(double), 6, stdout);
329   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines