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.65 by greg, Wed Oct 22 20:00:17 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 449 | Line 450 | finish_receiver(void)
450          }
451                                          /* determine sample type/bin */
452          if ((tolower(curparams.hemis[0]) == 'u') | (curparams.hemis[0] == '1')) {
453 <                sprintf(sbuf, "if(-Dx*%g-Dy*%g-Dz*%g,0,-1)",
454 <                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2]);
455 <                binv = savqstr(sbuf);
453 >                if (curparams.slist->styp != ST_SOURCE) {
454 >                        sprintf(sbuf, "if(-Dx*%g-Dy*%g-Dz*%g,0,-1)",
455 >                                curparams.nrm[0], curparams.nrm[1], curparams.nrm[2]);
456 >                        binv = savqstr(sbuf);
457 >                } else
458 >                        binv = "0";
459                  nbins = "1";            /* uniform sampling -- one bin */
460                  uniform = 1;
461          } else if (tolower(curparams.hemis[0]) == 's' &&
# Line 507 | Line 511 | finish_receiver(void)
511                          curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
512                          curparams.vup[0], curparams.vup[1], curparams.vup[2],
513                          curparams.sign);
514 +                params = savqstr(sbuf);
515                  binv = "cbin";
516                  nbins = "Ncbins";
517          } else {
# Line 904 | Line 909 | sample_klems(PARAMS *p, int b, FILE *fp)
909  
910   /* Prepare hemisphere basis sampler that will send rays to rcontrib */
911   static int
912 < prepare_sampler(void)
912 > prepare_sampler(PARAMS *p)
913   {
914 <        if (curparams.slist == NULL) {  /* missing sample surface! */
914 >        if (p->slist == NULL) { /* missing sample surface! */
915                  fputs(progname, stderr);
916                  fputs(": no sender surface!\n", stderr);
917                  return(-1);
918          }
919                                          /* misplaced output file spec. */
920 <        if ((curparams.outfn != NULL) & !(verbose & NOWARN))
920 >        if ((p->outfn != NULL) & !(verbose & NOWARN))
921                  fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n",
922 <                                progname, curparams.outfn);
922 >                                progname, p->outfn);
923                                          /* check/set basis hemisphere */
924 <        if (!curparams.hemis[0]) {
924 >        if (!p->hemis[0]) {
925                  fputs(progname, stderr);
926                  fputs(": missing sender sampling type!\n", stderr);
927                  return(-1);
928          }
929 <        if (normalize(curparams.nrm) == 0) {
929 >        if (normalize(p->nrm) == 0) {
930                  fputs(progname, stderr);
931                  fputs(": undefined normal for sender sampling\n", stderr);
932                  return(-1);
933          }
934 <        if (normalize(curparams.vup) == 0) {
935 <                if (fabs(curparams.nrm[2]) < .7)
936 <                        curparams.vup[2] = 1;
934 >        if (normalize(p->vup) == 0) {
935 >                if (fabs(p->nrm[2]) < .7)
936 >                        p->vup[2] = 1;
937                  else
938 <                        curparams.vup[1] = 1;
938 >                        p->vup[1] = 1;
939          }
940 <        fcross(curparams.udir, curparams.vup, curparams.nrm);
941 <        if (normalize(curparams.udir) == 0) {
940 >        fcross(p->udir, p->vup, p->nrm);
941 >        if (normalize(p->udir) == 0) {
942                  fputs(progname, stderr);
943                  fputs(": up vector coincides with sender normal\n", stderr);
944                  return(-1);
945          }
946 <        fcross(curparams.vdir, curparams.nrm, curparams.udir);
947 <        if (curparams.sign == '-') {    /* left-handed coordinate system? */
948 <                curparams.udir[0] *= -1.;
949 <                curparams.udir[1] *= -1.;
950 <                curparams.udir[2] *= -1.;
946 >        fcross(p->vdir, p->nrm, p->udir);
947 >        if (p->sign == '-') {   /* left-handed coordinate system? */
948 >                p->udir[0] *= -1.;
949 >                p->udir[1] *= -1.;
950 >                p->udir[2] *= -1.;
951          }
952 <        if ((tolower(curparams.hemis[0]) == 'u') | (curparams.hemis[0] == '1'))
953 <                curparams.sample_basis = sample_uniform;
954 <        else if (tolower(curparams.hemis[0]) == 's' &&
955 <                                tolower(curparams.hemis[1]) == 'c')
956 <                curparams.sample_basis = sample_shirchiu;
957 <        else if ((tolower(curparams.hemis[0]) == 'r') |
958 <                        (tolower(curparams.hemis[0]) == 't'))
959 <                curparams.sample_basis = sample_reinhart;
960 <        else if (tolower(curparams.hemis[0]) == 'k') {
961 <                switch (curparams.hemis[1]) {
952 >        if ((tolower(p->hemis[0]) == 'u') | (p->hemis[0] == '1'))
953 >                p->sample_basis = sample_uniform;
954 >        else if (tolower(p->hemis[0]) == 's' &&
955 >                                tolower(p->hemis[1]) == 'c')
956 >                p->sample_basis = sample_shirchiu;
957 >        else if ((tolower(p->hemis[0]) == 'r') |
958 >                        (tolower(p->hemis[0]) == 't'))
959 >                p->sample_basis = sample_reinhart;
960 >        else if (tolower(p->hemis[0]) == 'k') {
961 >                switch (p->hemis[1]) {
962                  case '1':
963                  case '2':
964                  case '4':
# Line 961 | Line 966 | prepare_sampler(void)
966                  case 'f':
967                  case 'F':
968                  case '\0':
969 <                        curparams.hemis[1] = '1';
969 >                        p->hemis[1] = '1';
970                          break;
971                  case 'h':
972                  case 'H':
973 <                        curparams.hemis[1] = '2';
973 >                        p->hemis[1] = '2';
974                          break;
975                  case 'q':
976                  case 'Q':
977 <                        curparams.hemis[1] = '4';
977 >                        p->hemis[1] = '4';
978                          break;
979                  default:
980                          goto unrecognized;
981                  }
982 <                curparams.hemis[2] = '\0';
983 <                curparams.sample_basis = sample_klems;
982 >                p->hemis[2] = '\0';
983 >                p->sample_basis = sample_klems;
984          } else
985                  goto unrecognized;
986                                          /* return number of bins */
987 <        return((*curparams.sample_basis)(&curparams,0,NULL));
987 >        return((*p->sample_basis)(p,0,NULL));
988   unrecognized:
989          fprintf(stderr, "%s: unrecognized sender sampling: h=%s\n",
990 <                        progname, curparams.hemis);
990 >                        progname, p->hemis);
991          return(-1);
992   }
993  
# Line 1420 | Line 1425 | main(int argc, char *argv[])
1425          curmod[0] = '\0';
1426          if (load_scene(sendfn, add_send_object) < 0)
1427                  return(1);
1428 <        if ((nsbins = prepare_sampler()) <= 0)
1428 >        if ((nsbins = prepare_sampler(&curparams)) <= 0)
1429                  return(1);
1430          CHECKARGC(3);                   /* add row count and octree */
1431          rcarg[nrcargs++] = "-y";
# Line 1448 | Line 1453 | main(int argc, char *argv[])
1453          return(pclose_al(rcfp) < 0);    /* all finished! */
1454   userr:
1455          if (a < argc-2)
1456 <                fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1456 >                fprintf(stderr, "%s: unsupported option '%s'\n", progname, argv[a]);
1457          fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n",
1458                                  progname);
1459          return(1);

Diff Legend

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