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

Comparing ray/src/rt/rv2.c (file contents):
Revision 2.63 by greg, Thu Sep 6 00:07:43 2012 UTC vs.
Revision 2.65 by greg, Fri Apr 11 20:27:23 2014 UTC

# Line 26 | Line 26 | extern double  maxdiff;                        /* max. sample difference */
26  
27   #define  CTRL(c)        ((c)-'@')
28  
29 < #ifdef  SMLFLT
30 < #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
31 < #else
32 < #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
33 < #endif
29 > #define  sscanvec(s,v)  (sscanf(s,FVFORMAT,v,v+1,v+2)==3)
30  
31   extern char  rifname[128];              /* rad input file name */
32  
# Line 369 | Line 365 | getpivot(                              /* pivot viewpoint */
365          if (getinterest(sskip2(s,2), 0, vc, &mag) < 0)
366                  return;
367          moveview(angle, elev, mag, vc);
368 + }
369 +
370 +
371 + void
372 + getorigin(                              /* origin viewpoint */
373 +        char  *s
374 + )
375 + {
376 +        VIEW    nv = ourview;
377 +        double  d;
378 +                                        /* get new view origin */
379 +        if (!sscanvec(s, nv.vp)) {
380 +                int     x, y;
381 +                RAY     thisray;
382 +                if (dev->getcur == NULL)
383 +                        return;
384 +                (*dev->comout)("Pick point on surface for new origin\n");
385 +                if ((*dev->getcur)(&x, &y) == ABORT)
386 +                        return;
387 +                if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
388 +                        &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
389 +                        error(COMMAND, "not on image");
390 +                        return;
391 +                }
392 +                rayorigin(&thisray, PRIMARY, NULL, NULL);
393 +                if (!localhit(&thisray, &thescene)) {
394 +                        error(COMMAND, "not a local object");
395 +                        return;
396 +                }
397 +                if (thisray.rod < 0.0)  /* don't look through other side */
398 +                        flipsurface(&thisray);
399 +                VSUM(nv.vp, thisray.rop, thisray.ron, 2.0*FTINY);
400 +                VCOPY(nv.vdir, thisray.ron);
401 +        } else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0)
402 +                VCOPY(nv.vdir, ourview.vdir);
403 +
404 +        d = DOT(nv.vdir, nv.vup);       /* need different up vector? */
405 +        if (d*d >= 1.-2.*FTINY) {
406 +                int     i;
407 +                nv.vup[0] = nv.vup[1] = nv.vup[2] = 0.0;
408 +                for (i = 3; i--; )
409 +                        if (nv.vdir[i]*nv.vdir[i] < 0.34)
410 +                                break;
411 +                nv.vup[i] = 1.;
412 +        }
413 +        newview(&nv);
414   }
415  
416  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines