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.74 by greg, Wed Nov 15 18:02:53 2023 UTC vs.
Revision 2.80 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 14 | Line 14 | static const char      RCSid[] = "$Id$";
14  
15   #include  "platform.h"
16   #include  "rtprocess.h" /* win_popen() */
17 #include  "paths.h"
17   #include  "ray.h"
18   #include  "ambient.h"
19   #include  "otypes.h"
# Line 374 | Line 373 | getorigin(                             /* origin viewpoint */
373   )
374   {
375          VIEW    nv = ourview;
376 +        FVECT   voff;
377 +        int     i;
378          double  d;
379 <                                        /* get new view origin */
380 <        if (sscanf(s, "%lf %lf", &d, &d) == 1) {
381 <                                        /* just moving some distance */
382 <                VSUM(nv.vp, nv.vp, nv.vdir, d);
383 <        } else if (!sscanvec(s, nv.vp)) {
384 <                int     x, y;           /* need to pick origin */
379 >                                        /* check for view origin shift */
380 >        if (sscanf(s, "%lf", &d) == 1) {
381 >                double  d_fore=d, d_right=0, d_up=0;
382 >                sscanf(s, "%*f %lf %lf", &d_right, &d_up);
383 >                d_right /= sqrt(nv.hn2);
384 >                for (i = 3; i--; )
385 >                        nv.vp[i] += d_fore*nv.vdir[i] +
386 >                                        d_right*nv.hvec[i] +
387 >                                        d_up*nv.vup[i];
388 >        } else {                        /* else pick new origin */
389 >                int     x, y;
390                  RAY     thisray;
391                  if (dev->getcur == NULL)
392                          return;
# Line 401 | Line 407 | getorigin(                             /* origin viewpoint */
407                          flipsurface(&thisray);
408                  VSUM(nv.vp, thisray.rop, thisray.ron, 20.0*FTINY);
409                  VCOPY(nv.vdir, thisray.ron);
410 <        } else if (!sscanvec(sskip2(s,3), nv.vdir) || normalize(nv.vdir) == 0.0)
411 <                VCOPY(nv.vdir, ourview.vdir);
412 <
413 <        d = DOT(nv.vdir, nv.vup);       /* need different up vector? */
414 <        if (d*d >= 1.-2.*FTINY) {
415 <                int     i;
416 <                nv.vup[0] = nv.vup[1] = nv.vup[2] = 0.0;
417 <                for (i = 3; i--; )
418 <                        if (nv.vdir[i]*nv.vdir[i] < 0.34)
413 <                                break;
414 <                nv.vup[i] = 1.;
410 >                d = DOT(nv.vdir, nv.vup);
411 >                if (d*d >= 1.-2.*FTINY) {
412 >                                        /* need different up vector */
413 >                        nv.vup[0] = nv.vup[1] = nv.vup[2] = 0.0;
414 >                        for (i = 3; i--; )
415 >                                if (nv.vdir[i]*nv.vdir[i] < 0.34)
416 >                                        break;
417 >                        nv.vup[i] = 1.;
418 >                }
419          }
420          newview(&nv);
421   }
# Line 459 | Line 463 | getexposure(                           /* get new exposure */
463                                          return;
464                          }
465                  }
466 <                if (*cp == '+' || *cp == '-')   /* f-stops */
466 >                if ((*cp == '+') | (*cp == '-'))        /* f-stops */
467                          e *= pow(2.0, atof(cp));
468                  else                            /* multiplier */
469                          e *= atof(cp);
# Line 520 | Line 524 | getparam(              /* get variable from user */
524                          if (sscanf(buf, "%lf", &d0) != 1)
525                                  return(0);
526                  }
527 <                if (FABSEQ(ptr->d, d0))
527 >                if (FRELEQ(ptr->d, d0))
528                          return(0);
529                  ptr->d = d0;
530                  break;
# Line 552 | Line 556 | getparam(              /* get variable from user */
556                          if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
557                                  return(0);
558                  }
559 <                if (FABSEQ(colval(ptr->C,RED), d0) &&
560 <                                FABSEQ(colval(ptr->C,GRN), d1) &&
561 <                                FABSEQ(colval(ptr->C,BLU), d2))
559 >                if (FRELEQ(colval(ptr->C,RED), d0) &&
560 >                                FRELEQ(colval(ptr->C,GRN), d1) &&
561 >                                FRELEQ(colval(ptr->C,BLU), d2))
562                          return(0);
563                  setcolor(ptr->C, d0, d1, d2);
564                  break;
# Line 588 | Line 592 | setparam(                              /* get/set program parameter */
592          case 'l':                       /* limit */
593                  switch (s[1]) {
594                  case 'w':                       /* weight */
595 <                        getparam(s+2, "limit weight", 'r',
592 <                                        (void *)&minweight);
595 >                        getparam(s+2, "limit weight", 'r', &minweight);
596                          break;
597                  case 'r':                       /* reflection */
598 <                        getparam(s+2, "limit reflection", 'i',
596 <                                        (void *)&maxdepth);
598 >                        getparam(s+2, "limit reflection", 'i', &maxdepth);
599                          break;
600                  default:
601                          goto badparam;
# Line 602 | Line 604 | setparam(                              /* get/set program parameter */
604          case 'd':                       /* direct */
605                  switch (s[1]) {
606                  case 'j':                       /* jitter */
607 <                        getparam(s+2, "direct jitter", 'r',
606 <                                        (void *)&dstrsrc);
607 >                        getparam(s+2, "direct jitter", 'r', &dstrsrc);
608                          break;
609                  case 'c':                       /* certainty */
610 <                        getparam(s+2, "direct certainty", 'r',
610 <                                        (void *)&shadcert);
610 >                        getparam(s+2, "direct certainty", 'r', &shadcert);
611                          break;
612                  case 't':                       /* threshold */
613 <                        getparam(s+2, "direct threshold", 'r',
614 <                                        (void *)&shadthresh);
613 >                        getparam(s+2, "direct threshold", 'r', &shadthresh);
614                          break;
615                  case 'v':                       /* visibility */
616 <                        getparam(s+2, "direct visibility", 'b',
618 <                                        (void *)&directvis);
616 >                        getparam(s+2, "direct visibility", 'b', &directvis);
617                          break;
618                  case 's':                       /* sampling */
619 <                        getparam(s+2, "direct sampling", 'r',
622 <                                        (void *)&srcsizerat);
619 >                        getparam(s+2, "direct sampling", 'r', &srcsizerat);
620                          break;
621                  default:
622                          goto badparam;
# Line 635 | Line 632 | setparam(                              /* get/set program parameter */
632                  case ' ':
633                  case 'y': case 'Y': case 't': case 'T': case '1': case '+':
634                  case 'n': case 'N': case 'f': case 'F': case '0': case '-':
635 <                        getparam(s+1, "black and white", 'b',
639 <                                        (void *)&greyscale);
635 >                        getparam(s+1, "black and white", 'b', &greyscale);
636                          newparam = prev_newp;
637                          break;
638                  default:
# Line 644 | Line 640 | setparam(                              /* get/set program parameter */
640                  }
641                  break;
642          case 'i':                       /* irradiance */
643 <                getparam(s+1, "irradiance", 'b',
648 <                                (void *)&do_irrad);
643 >                getparam(s+1, "irradiance", 'b', &do_irrad);
644                  break;
645          case 'a':                       /* ambient */
646                  switch (s[1]) {
647                  case 'v':                       /* value */
648 <                        getparam(s+2, "ambient value", 'C',
654 <                                        (void *)ambval);
648 >                        getparam(s+2, "ambient value", 'C', ambval);
649                          break;
650                  case 'w':                       /* weight */
651 <                        getparam(s+2, "ambient value weight", 'i',
658 <                                        (void *)&ambvwt);
651 >                        getparam(s+2, "ambient value weight", 'i', &ambvwt);
652                          break;
653                  case 'a':                       /* accuracy */
654 <                        if (getparam(s+2, "ambient accuracy", 'r',
662 <                                        (void *)&ambacc))
654 >                        if (getparam(s+2, "ambient accuracy", 'r', &ambacc))
655                                  setambacc(ambacc);
656                          break;
657                  case 'd':                       /* divisions */
658 <                        getparam(s+2, "ambient divisions", 'i',
667 <                                        (void *)&ambdiv);
658 >                        getparam(s+2, "ambient divisions", 'i', &ambdiv);
659                          break;
660                  case 's':                       /* samples */
661 <                        getparam(s+2, "ambient super-samples", 'i',
671 <                                        (void *)&ambssamp);
661 >                        getparam(s+2, "ambient super-samples", 'i', &ambssamp);
662                          break;
663                  case 'b':                       /* bounces */
664 <                        getparam(s+2, "ambient bounces", 'i',
675 <                                        (void *)&ambounce);
664 >                        getparam(s+2, "ambient bounces", 'i', &ambounce);
665                          break;
666                  case 'r':
667 <                        if (getparam(s+2, "ambient resolution", 'i',
679 <                                        (void *)&ambres))
667 >                        if (getparam(s+2, "ambient resolution", 'i', &ambres))
668                                  setambres(ambres);
669                          break;
670                  default:
# Line 686 | Line 674 | setparam(                              /* get/set program parameter */
674          case 'm':                       /* medium */
675                  switch (s[1]) {
676                  case 'e':                       /* extinction coefficient */
677 <                        getparam(s+2, "extinction coefficient", 'C',
690 <                                        (void *)cextinction);
677 >                        getparam(s+2, "extinction coefficient", 'C', cextinction);
678                          break;
679                  case 'a':                       /* scattering albedo */
680 <                        getparam(s+2, "scattering albedo", 'C',
694 <                                        (void *)salbedo);
680 >                        getparam(s+2, "scattering albedo", 'C', salbedo);
681                          break;
682                  case 'g':                       /* scattering eccentricity */
683 <                        getparam(s+2, "scattering eccentricity", 'r',
698 <                                        (void *)&seccg);
683 >                        getparam(s+2, "scattering eccentricity", 'r', &seccg);
684                          break;
685                  case 's':                       /* sampling distance */
686 <                        getparam(s+2, "mist sampling distance", 'r',
702 <                                        (void *)&ssampdist);
686 >                        getparam(s+2, "mist sampling distance", 'r', &ssampdist);
687                          break;
688                  default:
689                          goto badparam;
# Line 708 | Line 692 | setparam(                              /* get/set program parameter */
692          case 'p':                       /* pixel */
693                  switch (s[1]) {
694                  case 's':                       /* sample */
695 <                        if (getparam(s+2, "pixel sample", 'i',
712 <                                        (void *)&psample))
695 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
696                                  pdepth = 0;
697                          break;
698                  case 't':                       /* threshold */
699 <                        if (getparam(s+2, "pixel threshold", 'r',
717 <                                        (void *)&maxdiff))
699 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
700                                  pdepth = 0;
701                          break;
702                  default:
# Line 725 | Line 707 | setparam(                              /* get/set program parameter */
707          case 's':                       /* specular */
708                  switch (s[1]) {
709                  case 's':                       /* sampling */
710 <                        getparam(s+2, "specular sampling", 'r',
729 <                                        (void *)&specjitter);
710 >                        getparam(s+2, "specular sampling", 'r', &specjitter);
711                          break;
712                  case 't':                       /* threshold */
713 <                        getparam(s+2, "specular threshold", 'r',
733 <                                        (void *)&specthresh);
713 >                        getparam(s+2, "specular threshold", 'r', &specthresh);
714                          break;
715                  default:
716                          goto badparam;
# Line 755 | Line 735 | traceray(                              /* trace a single ray */
735   {
736          RAY     thisray;
737          char    buf[512];
738 +        COLOR   col;
739  
740          thisray.rmax = 0.0;
741  
# Line 814 | Line 795 | traceray(                              /* trace a single ray */
795                  if (thisray.rot >= FHUGE*.99)
796                          (*dev->comout)("at infinity");
797                  else {
798 <                        sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)",
798 >                        sprintf(buf, "at (%.3f %.3f %.3f) (%.6g)",
799                                          thisray.rop[0], thisray.rop[1],
800                                          thisray.rop[2], raydistance(&thisray));
801                          (*dev->comout)(buf);
802                  }
803                  (*dev->comin)(buf, NULL);
804 <                sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)",
805 <                                scolval(thisray.rcol,RED),
806 <                                scolval(thisray.rcol,GRN),
807 <                                scolval(thisray.rcol,BLU),
808 <                                sluminance(thisray.rcol));
804 >                scolor_rgb(col, thisray.rcol);
805 >                sprintf(buf, "value (%.4g %.4g %.4g) (%.3gL)",
806 >                                colval(col,RED),
807 >                                colval(col,GRN),
808 >                                colval(col,BLU),
809 >                                luminance(col));
810                  (*dev->comout)(buf);
811          }
812          (*dev->comin)(buf, NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines