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.62 by greg, Mon Oct 20 18:55:19 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! */
912 <                fputs(progname, stderr);
911 <                fputs(": no sender surface!\n", stderr);
911 >        if (p->slist == NULL) {         /* missing sample surface! */
912 >                error(USER, "no sender surface");
913                  return(-1);
914          }
915                                          /* misplaced output file spec. */
916 <        if ((curparams.outfn != NULL) & !(verbose & NOWARN))
917 <                fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n",
918 <                                progname, curparams.outfn);
916 >        if (p->outfn[0]) {
917 >                sprintf(errmsg, "ignoring output file in sender ('%s')",
918 >                                p->outfn);
919 >                error(WARNING, errmsg);
920 >        }
921                                          /* check/set basis hemisphere */
922 <        if (!curparams.hemis[0]) {
923 <                fputs(progname, stderr);
921 <                fputs(": missing sender sampling type!\n", stderr);
922 >        if (!p->hemis[0]) {
923 >                error(USER, "missing sender sampling type");
924                  return(-1);
925          }
926 <        if (normalize(curparams.nrm) == 0) {
927 <                fputs(progname, stderr);
926 <                fputs(": undefined normal for sender sampling\n", stderr);
926 >        if (normalize(p->nrm) == 0) {
927 >                error(USER, "undefined normal for sender sampling");
928                  return(-1);
929          }
930 <        if (normalize(curparams.vup) == 0) {
931 <                if (fabs(curparams.nrm[2]) < .7)
932 <                        curparams.vup[2] = 1;
930 >        if (normalize(p->vup) == 0) {
931 >                if (fabs(p->nrm[2]) < .7)
932 >                        p->vup[2] = 1;
933                  else
934 <                        curparams.vup[1] = 1;
934 >                        p->vup[1] = 1;
935          }
936 <        fcross(curparams.udir, curparams.vup, curparams.nrm);
937 <        if (normalize(curparams.udir) == 0) {
938 <                fputs(progname, stderr);
938 <                fputs(": up vector coincides with sender normal\n", stderr);
936 >        fcross(p->udir, p->vup, p->nrm);
937 >        if (normalize(p->udir) == 0) {
938 >                error(USER, "up vector coincides with sender normal");
939                  return(-1);
940          }
941 <        fcross(curparams.vdir, curparams.nrm, curparams.udir);
942 <        if (curparams.sign == '-') {    /* left-handed coordinate system? */
943 <                curparams.udir[0] *= -1.;
944 <                curparams.udir[1] *= -1.;
945 <                curparams.udir[2] *= -1.;
941 >        fcross(p->vdir, p->nrm, p->udir);
942 >        if (p->sign == '-') {           /* left-handed coordinate system? */
943 >                p->udir[0] *= -1.;
944 >                p->udir[1] *= -1.;
945 >                p->udir[2] *= -1.;
946          }
947 <        if ((tolower(curparams.hemis[0]) == 'u') | (curparams.hemis[0] == '1'))
948 <                curparams.sample_basis = sample_uniform;
949 <        else if (tolower(curparams.hemis[0]) == 's' &&
950 <                                tolower(curparams.hemis[1]) == 'c')
951 <                curparams.sample_basis = sample_shirchiu;
952 <        else if ((tolower(curparams.hemis[0]) == 'r') |
953 <                        (tolower(curparams.hemis[0]) == 't'))
954 <                curparams.sample_basis = sample_reinhart;
955 <        else if (tolower(curparams.hemis[0]) == 'k') {
956 <                switch (curparams.hemis[1]) {
947 >        if ((tolower(p->hemis[0]) == 'u') | (p->hemis[0] == '1'))
948 >                p->sample_basis = sample_uniform;
949 >        else if (tolower(p->hemis[0]) == 's' &&
950 >                                tolower(p->hemis[1]) == 'c')
951 >                p->sample_basis = sample_shirchiu;
952 >        else if ((tolower(p->hemis[0]) == 'r') |
953 >                        (tolower(p->hemis[0]) == 't'))
954 >                p->sample_basis = sample_reinhart;
955 >        else if (tolower(p->hemis[0]) == 'k') {
956 >                switch (p->hemis[1]) {
957                  case '1':
958                  case '2':
959                  case '4':
# Line 961 | Line 961 | prepare_sampler(void)
961                  case 'f':
962                  case 'F':
963                  case '\0':
964 <                        curparams.hemis[1] = '1';
964 >                        p->hemis[1] = '1';
965                          break;
966                  case 'h':
967                  case 'H':
968 <                        curparams.hemis[1] = '2';
968 >                        p->hemis[1] = '2';
969                          break;
970                  case 'q':
971                  case 'Q':
972 <                        curparams.hemis[1] = '4';
972 >                        p->hemis[1] = '4';
973                          break;
974                  default:
975                          goto unrecognized;
976                  }
977 <                curparams.hemis[2] = '\0';
978 <                curparams.sample_basis = sample_klems;
977 >                p->hemis[2] = '\0';
978 >                p->sample_basis = sample_klems;
979          } else
980                  goto unrecognized;
981                                          /* return number of bins */
982 <        return((*curparams.sample_basis)(&curparams,0,NULL));
982 >        return((*p->sample_basis)(p,0,NULL));
983   unrecognized:
984          fprintf(stderr, "%s: unrecognized sender sampling: h=%s\n",
985 <                        progname, curparams.hemis);
985 >                        progname, p->hemis);
986          return(-1);
987   }
988  
# Line 1420 | Line 1420 | main(int argc, char *argv[])
1420          curmod[0] = '\0';
1421          if (load_scene(sendfn, add_send_object) < 0)
1422                  return(1);
1423 <        if ((nsbins = prepare_sampler()) <= 0)
1423 >        if ((nsbins = prepare_sampler(&curparams)) <= 0)
1424                  return(1);
1425          CHECKARGC(3);                   /* add row count and octree */
1426          rcarg[nrcargs++] = "-y";

Diff Legend

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