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

Comparing ray/src/common/image.c (file contents):
Revision 2.43 by greg, Wed Jan 24 04:39:52 2018 UTC vs.
Revision 2.48 by greg, Fri Apr 27 18:09:26 2018 UTC

# Line 231 | Line 231 | viewloc(                       /* find image location for point */
231   FVECT  ip,
232   VIEW  *v,
233   FVECT  p
234 < )
234 > )       /* Use VL_* flags to interpret return value */
235   {
236 <        int     rval;
236 >        int     rflags = VL_GOOD;
237          double  d, d2;
238          FVECT  disp;
239  
# Line 245 | Line 245 | FVECT  p
245                  break;
246          case VT_PER:                    /* perspective view */
247                  d = DOT(disp,v->vdir);
248 +                if ((v->vaft > FTINY) & (d >= v->vaft))
249 +                        rflags |= VL_BEYOND;
250                  ip[2] = VLEN(disp);
251                  if (d < -FTINY) {       /* fold pyramid */
252                          ip[2] = -ip[2];
253                          d = -d;
254                  } else if (d <= FTINY)
255 <                        return(0);      /* at infinite edge */
255 >                        return(VL_BAD); /* at infinite edge */
256                  d = 1.0/d;
257                  disp[0] *= d;
258                  disp[1] *= d;
# Line 272 | Line 274 | FVECT  p
274                  ip[0] = 180.0/PI * atan2(d,d2) / v->horiz + 0.5 - v->hoff;
275                  d = d*d + d2*d2;
276                  if (d <= FTINY*FTINY)
277 <                        return(0);      /* at pole */
277 >                        return(VL_BAD); /* at pole */
278 >                if ((v->vaft > FTINY) & (d >= v->vaft*v->vaft))
279 >                        rflags |= VL_BEYOND;
280                  d = 1.0/sqrt(d);
281                  ip[1] = DOT(disp,v->vvec)*d/v->vn2 + 0.5 - v->voff;
282                  ip[2] = VLEN(disp);
# Line 301 | Line 305 | FVECT  p
305                  if (d >= 1.0-FTINY)
306                          goto gotall;
307                  if (d <= -(1.0-FTINY))
308 <                        return(0);
308 >                        return(VL_BAD);
309                  ip[0] += DOT(disp,v->hvec)/((1. + d)*sqrt(v->hn2));
310                  ip[1] += DOT(disp,v->vvec)/((1. + d)*sqrt(v->vn2));
311                  goto gotall;
312 +        default:
313 +                return(VL_BAD);
314          }
315          ip[0] = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff;
316          ip[1] = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff;
317 < gotall:                                 /* return negative if behind */
318 <        rval = 1 - 2*(ip[2] <= 0.0);
319 <        if ((0.0 > ip[0]) | (ip[0] > 1.0) || (0.0 > ip[1]) | (ip[1] > 1.0))
320 <                return 2*rval;          /* +/-2 if outside frame */
321 <        return rval;
317 > gotall:                                 /* add appropriate return flags */
318 >        if (ip[2] <= 0.0)
319 >                rflags |= VL_BEHIND;
320 >        else if ((v->type != VT_PER) & (v->type != VT_CYL))
321 >                rflags |= VL_BEYOND*((v->vaft > FTINY) &
322 >                                        (ip[2] >= v->vaft - v->vfore));
323 >        rflags |= VL_OUTSIDE*((0.0 >= ip[0]) | (ip[0] >= 1.0) |
324 >                                (0.0 >= ip[1]) | (ip[1] >= 1.0));
325 >        return(rflags);
326   }
327  
328  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines