ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/util/rfluxmtx.c
(Generate patch)

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.61 by greg, Fri Oct 17 17:24:47 2025 UTC vs.
Revision 2.64 by greg, Wed Oct 22 17:04:14 2025 UTC

# Line 110 | Line 110 | clear_params(PARAMS *p, int reset_only)
110                  free(sdel);
111          }
112          if (reset_only) {
113 +                p->slist = NULL;
114                  p->nsurfs = 0;
115                  memset(p->nrm, 0, sizeof(FVECT));
116                  memset(p->vup, 0, sizeof(FVECT));
# Line 507 | Line 508 | finish_receiver(void)
508                          curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
509                          curparams.vup[0], curparams.vup[1], curparams.vup[2],
510                          curparams.sign);
511 +                params = savqstr(sbuf);
512                  binv = "cbin";
513                  nbins = "Ncbins";
514          } else {
# Line 904 | Line 906 | sample_klems(PARAMS *p, int b, FILE *fp)
906  
907   /* Prepare hemisphere basis sampler that will send rays to rcontrib */
908   static int
909 < prepare_sampler(void)
909 > prepare_sampler(PARAMS *p)
910   {
911 <        if (curparams.slist == NULL) {  /* missing sample surface! */
911 >        if (p->slist == NULL) { /* missing sample surface! */
912                  fputs(progname, stderr);
913                  fputs(": no sender surface!\n", stderr);
914                  return(-1);
915          }
916                                          /* misplaced output file spec. */
917 <        if ((curparams.outfn != NULL) & !(verbose & NOWARN))
917 >        if ((p->outfn != NULL) & !(verbose & NOWARN))
918                  fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n",
919 <                                progname, curparams.outfn);
919 >                                progname, p->outfn);
920                                          /* check/set basis hemisphere */
921 <        if (!curparams.hemis[0]) {
921 >        if (!p->hemis[0]) {
922                  fputs(progname, stderr);
923                  fputs(": missing sender sampling type!\n", stderr);
924                  return(-1);
925          }
926 <        if (normalize(curparams.nrm) == 0) {
926 >        if (normalize(p->nrm) == 0) {
927                  fputs(progname, stderr);
928                  fputs(": undefined normal for sender sampling\n", stderr);
929                  return(-1);
930          }
931 <        if (normalize(curparams.vup) == 0) {
932 <                if (fabs(curparams.nrm[2]) < .7)
933 <                        curparams.vup[2] = 1;
931 >        if (normalize(p->vup) == 0) {
932 >                if (fabs(p->nrm[2]) < .7)
933 >                        p->vup[2] = 1;
934                  else
935 <                        curparams.vup[1] = 1;
935 >                        p->vup[1] = 1;
936          }
937 <        fcross(curparams.udir, curparams.vup, curparams.nrm);
938 <        if (normalize(curparams.udir) == 0) {
937 >        fcross(p->udir, p->vup, p->nrm);
938 >        if (normalize(p->udir) == 0) {
939                  fputs(progname, stderr);
940                  fputs(": up vector coincides with sender normal\n", stderr);
941                  return(-1);
942          }
943 <        fcross(curparams.vdir, curparams.nrm, curparams.udir);
944 <        if (curparams.sign == '-') {    /* left-handed coordinate system? */
945 <                curparams.udir[0] *= -1.;
946 <                curparams.udir[1] *= -1.;
947 <                curparams.udir[2] *= -1.;
943 >        fcross(p->vdir, p->nrm, p->udir);
944 >        if (p->sign == '-') {   /* left-handed coordinate system? */
945 >                p->udir[0] *= -1.;
946 >                p->udir[1] *= -1.;
947 >                p->udir[2] *= -1.;
948          }
949 <        if ((tolower(curparams.hemis[0]) == 'u') | (curparams.hemis[0] == '1'))
950 <                curparams.sample_basis = sample_uniform;
951 <        else if (tolower(curparams.hemis[0]) == 's' &&
952 <                                tolower(curparams.hemis[1]) == 'c')
953 <                curparams.sample_basis = sample_shirchiu;
954 <        else if ((tolower(curparams.hemis[0]) == 'r') |
955 <                        (tolower(curparams.hemis[0]) == 't'))
956 <                curparams.sample_basis = sample_reinhart;
957 <        else if (tolower(curparams.hemis[0]) == 'k') {
958 <                switch (curparams.hemis[1]) {
949 >        if ((tolower(p->hemis[0]) == 'u') | (p->hemis[0] == '1'))
950 >                p->sample_basis = sample_uniform;
951 >        else if (tolower(p->hemis[0]) == 's' &&
952 >                                tolower(p->hemis[1]) == 'c')
953 >                p->sample_basis = sample_shirchiu;
954 >        else if ((tolower(p->hemis[0]) == 'r') |
955 >                        (tolower(p->hemis[0]) == 't'))
956 >                p->sample_basis = sample_reinhart;
957 >        else if (tolower(p->hemis[0]) == 'k') {
958 >                switch (p->hemis[1]) {
959                  case '1':
960                  case '2':
961                  case '4':
# Line 961 | Line 963 | prepare_sampler(void)
963                  case 'f':
964                  case 'F':
965                  case '\0':
966 <                        curparams.hemis[1] = '1';
966 >                        p->hemis[1] = '1';
967                          break;
968                  case 'h':
969                  case 'H':
970 <                        curparams.hemis[1] = '2';
970 >                        p->hemis[1] = '2';
971                          break;
972                  case 'q':
973                  case 'Q':
974 <                        curparams.hemis[1] = '4';
974 >                        p->hemis[1] = '4';
975                          break;
976                  default:
977                          goto unrecognized;
978                  }
979 <                curparams.hemis[2] = '\0';
980 <                curparams.sample_basis = sample_klems;
979 >                p->hemis[2] = '\0';
980 >                p->sample_basis = sample_klems;
981          } else
982                  goto unrecognized;
983                                          /* return number of bins */
984 <        return((*curparams.sample_basis)(&curparams,0,NULL));
984 >        return((*p->sample_basis)(p,0,NULL));
985   unrecognized:
986          fprintf(stderr, "%s: unrecognized sender sampling: h=%s\n",
987 <                        progname, curparams.hemis);
987 >                        progname, p->hemis);
988          return(-1);
989   }
990  
# Line 1420 | Line 1422 | main(int argc, char *argv[])
1422          curmod[0] = '\0';
1423          if (load_scene(sendfn, add_send_object) < 0)
1424                  return(1);
1425 <        if ((nsbins = prepare_sampler()) <= 0)
1425 >        if ((nsbins = prepare_sampler(&curparams)) <= 0)
1426                  return(1);
1427          CHECKARGC(3);                   /* add row count and octree */
1428          rcarg[nrcargs++] = "-y";
# Line 1448 | Line 1450 | main(int argc, char *argv[])
1450          return(pclose_al(rcfp) < 0);    /* all finished! */
1451   userr:
1452          if (a < argc-2)
1453 <                fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1453 >                fprintf(stderr, "%s: unsupported option '%s'\n", progname, argv[a]);
1454          fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n",
1455                                  progname);
1456          return(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)