--- ray/src/rt/rv2.c 2013/10/18 17:04:13 2.64 +++ ray/src/rt/rv2.c 2021/02/01 16:19:49 2.71 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv2.c,v 2.64 2013/10/18 17:04:13 greg Exp $"; +static const char RCSid[] = "$Id: rv2.c,v 2.71 2021/02/01 16:19:49 greg Exp $"; #endif /* * rv2.c - command routines used in tracing a view. @@ -16,9 +16,9 @@ static const char RCSid[] = "$Id: rv2.c,v 2.64 2013/10 #include "rtprocess.h" /* win_popen() */ #include "paths.h" #include "ray.h" -#include "source.h" #include "ambient.h" #include "otypes.h" +#include "otspecial.h" #include "rpaint.h" extern int psample; /* pixel sample size */ @@ -26,11 +26,7 @@ extern double maxdiff; /* max. sample difference */ #define CTRL(c) ((c)-'@') -#ifdef SMLFLT -#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) -#else -#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) -#endif +#define sscanvec(s,v) (sscanf(s,FVFORMAT,v,v+1,v+2)==3) extern char rifname[128]; /* rad input file name */ @@ -380,8 +376,11 @@ getorigin( /* origin viewpoint */ VIEW nv = ourview; double d; /* get new view origin */ - if (!sscanvec(s, nv.vp)) { - int x, y; + if (sscanf(s, "%lf %lf", &d, &d) == 1) { + /* just moving some distance */ + VSUM(nv.vp, nv.vp, nv.vdir, d); + } else if (!sscanvec(s, nv.vp)) { + int x, y; /* need to pick origin */ RAY thisray; if (dev->getcur == NULL) return; @@ -400,7 +399,7 @@ getorigin( /* origin viewpoint */ } if (thisray.rod < 0.0) /* don't look through other side */ flipsurface(&thisray); - VSUM(nv.vp, thisray.rop, thisray.ron, 2.0*FTINY); + VSUM(nv.vp, thisray.rop, thisray.ron, 20.0*FTINY); VCOPY(nv.vdir, thisray.ron); } else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0) VCOPY(nv.vdir, ourview.vdir); @@ -794,7 +793,7 @@ traceray( /* trace a single ray */ matspec[0] = '\0'; if (thisray.ro->omod != OVOID) { mod = objptr(thisray.ro->omod); - mat = findmaterial(mod); + mat = findmaterial(thisray.ro); } if (thisray.rod < 0.0) strcpy(matspec, "back of "); @@ -813,12 +812,12 @@ traceray( /* trace a single ray */ ofun[ino->otype].funame, ino->oname); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (thisray.rot >= FHUGE) + if (thisray.rot >= FHUGE*.99) (*dev->comout)("at infinity"); else { sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)", thisray.rop[0], thisray.rop[1], - thisray.rop[2], thisray.rt); + thisray.rop[2], raydistance(&thisray)); (*dev->comout)(buf); } (*dev->comin)(buf, NULL);