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.64 by greg, Fri Oct 18 17:04:13 2013 UTC vs.
Revision 2.77 by greg, Tue Apr 22 15:47:47 2025 UTC

# Line 16 | Line 16 | static const char      RCSid[] = "$Id$";
16   #include  "rtprocess.h" /* win_popen() */
17   #include  "paths.h"
18   #include  "ray.h"
19 #include  "source.h"
19   #include  "ambient.h"
20   #include  "otypes.h"
21 + #include  "otspecial.h"
22   #include  "rpaint.h"
23  
24   extern int  psample;                    /* pixel sample size */
# 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 380 | Line 376 | getorigin(                             /* origin viewpoint */
376          VIEW    nv = ourview;
377          double  d;
378                                          /* get new view origin */
379 <        if (!sscanvec(s, nv.vp)) {
380 <                int     x, y;
379 >        if (sscanf(s, "%lf %lf", &d, &d) == 1) {
380 >                                        /* just moving some distance */
381 >                VSUM(nv.vp, nv.vp, nv.vdir, d);
382 >        } else if (!sscanvec(s, nv.vp)) {
383 >                int     x, y;           /* need to pick origin */
384                  RAY     thisray;
385                  if (dev->getcur == NULL)
386                          return;
# Line 400 | Line 399 | getorigin(                             /* origin viewpoint */
399                  }
400                  if (thisray.rod < 0.0)  /* don't look through other side */
401                          flipsurface(&thisray);
402 <                VSUM(nv.vp, thisray.rop, thisray.ron, 2.0*FTINY);
402 >                VSUM(nv.vp, thisray.rop, thisray.ron, 20.0*FTINY);
403                  VCOPY(nv.vdir, thisray.ron);
404          } else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0)
405                  VCOPY(nv.vdir, ourview.vdir);
# Line 460 | Line 459 | getexposure(                           /* get new exposure */
459                                          return;
460                          }
461                  }
462 <                if (*cp == '+' || *cp == '-')   /* f-stops */
462 >                if ((*cp == '+') | (*cp == '-'))        /* f-stops */
463                          e *= pow(2.0, atof(cp));
464                  else                            /* multiplier */
465                          e *= atof(cp);
# Line 484 | Line 483 | getexposure(                           /* get new exposure */
483   }
484  
485   typedef union {int i; double d; COLOR C;}       *MyUptr;
487 #define  FEQ(x,y)     (fabs((x)-(y)) <= FTINY)
486  
487   int
488   getparam(               /* get variable from user */
# Line 522 | Line 520 | getparam(              /* get variable from user */
520                          if (sscanf(buf, "%lf", &d0) != 1)
521                                  return(0);
522                  }
523 <                if (FEQ(ptr->d, d0))
523 >                if (FRELEQ(ptr->d, d0))
524                          return(0);
525                  ptr->d = d0;
526                  break;
# Line 554 | Line 552 | getparam(              /* get variable from user */
552                          if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
553                                  return(0);
554                  }
555 <                if (FEQ(colval(ptr->C,RED), d0) &&
556 <                                FEQ(colval(ptr->C,GRN), d1) &&
557 <                                FEQ(colval(ptr->C,BLU), d2))
555 >                if (FRELEQ(colval(ptr->C,RED), d0) &&
556 >                                FRELEQ(colval(ptr->C,GRN), d1) &&
557 >                                FRELEQ(colval(ptr->C,BLU), d2))
558                          return(0);
559                  setcolor(ptr->C, d0, d1, d2);
560                  break;
# Line 590 | Line 588 | setparam(                              /* get/set program parameter */
588          case 'l':                       /* limit */
589                  switch (s[1]) {
590                  case 'w':                       /* weight */
591 <                        getparam(s+2, "limit weight", 'r',
594 <                                        (void *)&minweight);
591 >                        getparam(s+2, "limit weight", 'r', &minweight);
592                          break;
593                  case 'r':                       /* reflection */
594 <                        getparam(s+2, "limit reflection", 'i',
598 <                                        (void *)&maxdepth);
594 >                        getparam(s+2, "limit reflection", 'i', &maxdepth);
595                          break;
596                  default:
597                          goto badparam;
# Line 604 | Line 600 | setparam(                              /* get/set program parameter */
600          case 'd':                       /* direct */
601                  switch (s[1]) {
602                  case 'j':                       /* jitter */
603 <                        getparam(s+2, "direct jitter", 'r',
608 <                                        (void *)&dstrsrc);
603 >                        getparam(s+2, "direct jitter", 'r', &dstrsrc);
604                          break;
605                  case 'c':                       /* certainty */
606 <                        getparam(s+2, "direct certainty", 'r',
612 <                                        (void *)&shadcert);
606 >                        getparam(s+2, "direct certainty", 'r', &shadcert);
607                          break;
608                  case 't':                       /* threshold */
609 <                        getparam(s+2, "direct threshold", 'r',
616 <                                        (void *)&shadthresh);
609 >                        getparam(s+2, "direct threshold", 'r', &shadthresh);
610                          break;
611                  case 'v':                       /* visibility */
612 <                        getparam(s+2, "direct visibility", 'b',
620 <                                        (void *)&directvis);
612 >                        getparam(s+2, "direct visibility", 'b', &directvis);
613                          break;
614                  case 's':                       /* sampling */
615 <                        getparam(s+2, "direct sampling", 'r',
624 <                                        (void *)&srcsizerat);
615 >                        getparam(s+2, "direct sampling", 'r', &srcsizerat);
616                          break;
617                  default:
618                          goto badparam;
# Line 637 | Line 628 | setparam(                              /* get/set program parameter */
628                  case ' ':
629                  case 'y': case 'Y': case 't': case 'T': case '1': case '+':
630                  case 'n': case 'N': case 'f': case 'F': case '0': case '-':
631 <                        getparam(s+1, "black and white", 'b',
641 <                                        (void *)&greyscale);
631 >                        getparam(s+1, "black and white", 'b', &greyscale);
632                          newparam = prev_newp;
633                          break;
634                  default:
# Line 646 | Line 636 | setparam(                              /* get/set program parameter */
636                  }
637                  break;
638          case 'i':                       /* irradiance */
639 <                getparam(s+1, "irradiance", 'b',
650 <                                (void *)&do_irrad);
639 >                getparam(s+1, "irradiance", 'b', &do_irrad);
640                  break;
641          case 'a':                       /* ambient */
642                  switch (s[1]) {
643                  case 'v':                       /* value */
644 <                        getparam(s+2, "ambient value", 'C',
656 <                                        (void *)ambval);
644 >                        getparam(s+2, "ambient value", 'C', ambval);
645                          break;
646                  case 'w':                       /* weight */
647 <                        getparam(s+2, "ambient value weight", 'i',
660 <                                        (void *)&ambvwt);
647 >                        getparam(s+2, "ambient value weight", 'i', &ambvwt);
648                          break;
649                  case 'a':                       /* accuracy */
650 <                        if (getparam(s+2, "ambient accuracy", 'r',
664 <                                        (void *)&ambacc))
650 >                        if (getparam(s+2, "ambient accuracy", 'r', &ambacc))
651                                  setambacc(ambacc);
652                          break;
653                  case 'd':                       /* divisions */
654 <                        getparam(s+2, "ambient divisions", 'i',
669 <                                        (void *)&ambdiv);
654 >                        getparam(s+2, "ambient divisions", 'i', &ambdiv);
655                          break;
656                  case 's':                       /* samples */
657 <                        getparam(s+2, "ambient super-samples", 'i',
673 <                                        (void *)&ambssamp);
657 >                        getparam(s+2, "ambient super-samples", 'i', &ambssamp);
658                          break;
659                  case 'b':                       /* bounces */
660 <                        getparam(s+2, "ambient bounces", 'i',
677 <                                        (void *)&ambounce);
660 >                        getparam(s+2, "ambient bounces", 'i', &ambounce);
661                          break;
662                  case 'r':
663 <                        if (getparam(s+2, "ambient resolution", 'i',
681 <                                        (void *)&ambres))
663 >                        if (getparam(s+2, "ambient resolution", 'i', &ambres))
664                                  setambres(ambres);
665                          break;
666                  default:
# Line 688 | Line 670 | setparam(                              /* get/set program parameter */
670          case 'm':                       /* medium */
671                  switch (s[1]) {
672                  case 'e':                       /* extinction coefficient */
673 <                        getparam(s+2, "extinction coefficient", 'C',
692 <                                        (void *)cextinction);
673 >                        getparam(s+2, "extinction coefficient", 'C', cextinction);
674                          break;
675                  case 'a':                       /* scattering albedo */
676 <                        getparam(s+2, "scattering albedo", 'C',
696 <                                        (void *)salbedo);
676 >                        getparam(s+2, "scattering albedo", 'C', salbedo);
677                          break;
678                  case 'g':                       /* scattering eccentricity */
679 <                        getparam(s+2, "scattering eccentricity", 'r',
700 <                                        (void *)&seccg);
679 >                        getparam(s+2, "scattering eccentricity", 'r', &seccg);
680                          break;
681                  case 's':                       /* sampling distance */
682 <                        getparam(s+2, "mist sampling distance", 'r',
704 <                                        (void *)&ssampdist);
682 >                        getparam(s+2, "mist sampling distance", 'r', &ssampdist);
683                          break;
684                  default:
685                          goto badparam;
# Line 710 | Line 688 | setparam(                              /* get/set program parameter */
688          case 'p':                       /* pixel */
689                  switch (s[1]) {
690                  case 's':                       /* sample */
691 <                        if (getparam(s+2, "pixel sample", 'i',
714 <                                        (void *)&psample))
691 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
692                                  pdepth = 0;
693                          break;
694                  case 't':                       /* threshold */
695 <                        if (getparam(s+2, "pixel threshold", 'r',
719 <                                        (void *)&maxdiff))
695 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
696                                  pdepth = 0;
697                          break;
698                  default:
# Line 727 | Line 703 | setparam(                              /* get/set program parameter */
703          case 's':                       /* specular */
704                  switch (s[1]) {
705                  case 's':                       /* sampling */
706 <                        getparam(s+2, "specular sampling", 'r',
731 <                                        (void *)&specjitter);
706 >                        getparam(s+2, "specular sampling", 'r', &specjitter);
707                          break;
708                  case 't':                       /* threshold */
709 <                        getparam(s+2, "specular threshold", 'r',
735 <                                        (void *)&specthresh);
709 >                        getparam(s+2, "specular threshold", 'r', &specthresh);
710                          break;
711                  default:
712                          goto badparam;
# Line 757 | Line 731 | traceray(                              /* trace a single ray */
731   {
732          RAY     thisray;
733          char    buf[512];
734 +        COLOR   col;
735  
736          thisray.rmax = 0.0;
737  
# Line 794 | Line 769 | traceray(                              /* trace a single ray */
769                  matspec[0] = '\0';
770                  if (thisray.ro->omod != OVOID) {
771                          mod = objptr(thisray.ro->omod);
772 <                        mat = findmaterial(mod);
772 >                        mat = findmaterial(thisray.ro);
773                  }
774                  if (thisray.rod < 0.0)
775                          strcpy(matspec, "back of ");
# Line 813 | Line 788 | traceray(                              /* trace a single ray */
788                                          ofun[ino->otype].funame, ino->oname);
789                  (*dev->comout)(buf);
790                  (*dev->comin)(buf, NULL);
791 <                if (thisray.rot >= FHUGE)
791 >                if (thisray.rot >= FHUGE*.99)
792                          (*dev->comout)("at infinity");
793                  else {
794                          sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)",
795                                          thisray.rop[0], thisray.rop[1],
796 <                                        thisray.rop[2], thisray.rt);
796 >                                        thisray.rop[2], raydistance(&thisray));
797                          (*dev->comout)(buf);
798                  }
799                  (*dev->comin)(buf, NULL);
800 +                scolor_rgb(col, thisray.rcol);
801                  sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)",
802 <                                colval(thisray.rcol,RED),
803 <                                colval(thisray.rcol,GRN),
804 <                                colval(thisray.rcol,BLU),
805 <                                luminance(thisray.rcol));
802 >                                colval(col,RED),
803 >                                colval(col,GRN),
804 >                                colval(col,BLU),
805 >                                luminance(col));
806                  (*dev->comout)(buf);
807          }
808          (*dev->comin)(buf, NULL);
# Line 872 | Line 848 | writepict(                             /* write the picture to a file */
848                  fputexpos(exposure, fp);
849          if (dev->pixaspect != 1.0)
850                  fputaspect(dev->pixaspect, fp);
851 +        fputprims(stdprims, fp);
852          fputformat(COLRFMT, fp);
853          putc('\n', fp);
854          fprtresolu(hresolu, vresolu, fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines