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.1 by greg, Tue Nov 12 17:09:52 1991 UTC vs.
Revision 2.8 by greg, Wed Mar 4 16:52:10 1992 UTC

# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22  
23   #include  <ctype.h>
24  
25 < #define  CTRL(c)        ('c'-'@')
25 > #define  CTRL(c)        ((c)-'@')
26  
27 + #ifdef  SMLFLT
28 + #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
29 + #else
30 + #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
31 + #endif
32 +
33 +
34   extern char  VersionID[];
35   extern char  *progname;
36   extern char  *octname;
# Line 75 | Line 82 | char  *s;
82          sprintf(buf, "view type (%c): ", ourview.type);
83          (*dev->comout)(buf);
84          (*dev->comin)(buf, NULL);
85 <        if (buf[0] == CTRL(C)) return;
85 >        if (buf[0] == CTRL('C')) return;
86          if (buf[0] && buf[0] != ourview.type) {
87                  nv.type = buf[0];
88                  change++;
# Line 85 | Line 92 | char  *s;
92                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
93          (*dev->comout)(buf);
94          (*dev->comin)(buf, NULL);
95 <        if (buf[0] == CTRL(C)) return;
96 <        if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
95 >        if (buf[0] == CTRL('C')) return;
96 >        if (sscanvec(buf, nv.vp))
97                  change++;
98          else
99                  VCOPY(nv.vp, ourview.vp);
# Line 94 | Line 101 | char  *s;
101                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
102          (*dev->comout)(buf);
103          (*dev->comin)(buf, NULL);
104 <        if (buf[0] == CTRL(C)) return;
105 <        if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
104 >        if (buf[0] == CTRL('C')) return;
105 >        if (sscanvec(buf, nv.vdir))
106                  change++;
107          else
108                  VCOPY(nv.vdir, ourview.vdir);
# Line 103 | Line 110 | char  *s;
110                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
111          (*dev->comout)(buf);
112          (*dev->comin)(buf, NULL);
113 <        if (buf[0] == CTRL(C)) return;
114 <        if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
113 >        if (buf[0] == CTRL('C')) return;
114 >        if (sscanvec(buf, nv.vup))
115                  change++;
116          else
117                  VCOPY(nv.vup, ourview.vup);
# Line 112 | Line 119 | char  *s;
119                          ourview.horiz, ourview.vert);
120          (*dev->comout)(buf);
121          (*dev->comin)(buf, NULL);
122 <        if (buf[0] == CTRL(C)) return;
122 >        if (buf[0] == CTRL('C')) return;
123          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
124                  change++;
125          else {
# Line 122 | Line 129 | char  *s;
129                          ourview.hoff, ourview.voff);
130          (*dev->comout)(buf);
131          (*dev->comin)(buf, NULL);
132 <        if (buf[0] == CTRL(C)) return;
132 >        if (buf[0] == CTRL('C')) return;
133          if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
134                  change++;
135          else {
# Line 246 | Line 253 | register char  *s;
253   getexposure(s)                          /* get new exposure */
254   char  *s;
255   {
249        double  atof(), pow(), fabs();
256          char  buf[128];
257          register char  *cp;
258          register PNODE  *p;
# Line 291 | Line 297 | char  *s;
297                          e *= atof(cp);
298          }
299          if (p != NULL) {                /* relative setting */
300 <                if (bright(p->v) <= FTINY) {
300 >                if (bright(p->v) < 1e-25) {
301                          error(COMMAND, "cannot normalize to zero");
302                          return;
303                  }
# Line 341 | Line 347 | register union {int i; double d; COLOR C;}  *ptr;
347          case 'b':                       /* boolean */
348                  if (sscanf(str, "%1s", buf) != 1) {
349                          (*dev->comout)(dsc);
350 <                        sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n');
350 >                        sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n');
351                          (*dev->comout)(buf);
352                          (*dev->comin)(buf, NULL);
353                          if (buf[0] == '\0' ||
# Line 380 | Line 386 | register char  *s;
386          extern double  shadcert;
387          extern COLOR  ambval;
388          extern double  ambacc;
383        extern double  minarad;
389          extern int  ambres;
390          extern int  ambdiv;
391          extern int  ambssamp;
# Line 388 | Line 393 | register char  *s;
393          extern int  directinvis;
394          extern double  srcsizerat;
395          extern int  do_irrad;
396 +        extern double  specjitter;
397 +        extern double  specthresh;
398          char  buf[128];
399          
400          if (s[0] == '\0') {
401                  (*dev->comout)(
402 <                        "aa ab ad ar as av b dc di dj ds dt i lr lw sp st: ");
402 >                "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: ");
403                  (*dev->comin)(buf, NULL);
404                  s = buf;
405          }
# Line 456 | Line 463 | register char  *s;
463                          break;
464                  case 'r':
465                          if (getparam(s+2, "ambient resolution", 'i', &ambres))
466 <                                minarad = ambres > 0 ?
460 <                                                thescene.cusize/ambres : 0.0;
466 >                                setambres(ambres);
467                          break;
468                  default:
469                          goto badparam;
470                  }
471                  break;
472 <        case 's':                       /* sample */
472 >        case 'p':                       /* pixel */
473                  switch (s[1]) {
474 <                case 'p':                       /* pixel */
475 <                        if (getparam(s+2, "sample pixel", 'i', &psample))
474 >                case 's':                       /* sample */
475 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
476                                  pdepth = 0;
477                          break;
478                  case 't':                       /* threshold */
479 <                        if (getparam(s+2, "sample threshold", 'r', &maxdiff))
479 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
480                                  pdepth = 0;
481                          break;
482                  default:
483                          goto badparam;
484                  }
485                  break;
486 +        case 's':                       /* specular */
487 +                switch (s[1]) {
488 +                case 'j':                       /* jitter */
489 +                        getparam(s+2, "specular jitter", 'r', &specjitter);
490 +                        break;
491 +                case 't':                       /* threshold */
492 +                        getparam(s+2, "specular threshold", 'r', &specthresh);
493 +                        break;
494 +                default:
495 +                        goto badparam;
496 +                }
497 +                break;
498          case '\0':                      /* nothing */
499                  break;
500          default:;
# Line 496 | Line 514 | char  *s;
514          int  x, y;
515          RAY  thisray;
516  
517 <        if (sscanf(s, "%lf %lf %lf %lf %lf %lf",
518 <                &thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2],
501 <                &thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) {
517 >        if (!sscanvec(s, thisray.rorg) ||
518 >                        !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) {
519  
520                  if (dev->getcur == NULL)
521                          return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines