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

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.9 by greg, Fri Jul 25 16:58:20 2014 UTC vs.
Revision 2.32 by greg, Fri Dec 4 22:16:18 2015 UTC

# Line 11 | Line 11 | static const char RCSid[] = "$Id$";
11   #include <stdlib.h>
12   #include "rtio.h"
13   #include "rtmath.h"
14 + #include "rtprocess.h"
15   #include "bsdf.h"
16   #include "bsdf_m.h"
17   #include "random.h"
# Line 35 | Line 36 | static const char RCSid[] = "$Id$";
36  
37   char            *progname;              /* global argv[0] */
38  
39 < int             verbose = 0;            /* verbose mode? */
39 > int             verbose = 0;            /* verbose mode (< 0 no warnings) */
40  
41   char            *rcarg[MAXRCARG+1] = {"rcontrib", "-fo+"};
42   int             nrcargs = 2;
# Line 83 | Line 84 | typedef struct {
84   } POLYTRIS;                     /* triangulated polygon */
85  
86   typedef struct param_s {
87 <        char            hemis[32];      /* hemispherical sampling spec. */
87 >        char            sign;           /* '-' for axis reversal */
88 >        char            hemis[31];      /* hemispherical sampling spec. */
89          int             hsiz;           /* hemisphere basis size */
90          int             nsurfs;         /* number of surfaces */
91          SURF            *slist;         /* list of surfaces */
92          FVECT           vup;            /* up vector (zero if unset) */
93          FVECT           nrm;            /* average normal direction */
94 <        FVECT           udir, vdir;     /* v-up tangent axes */
94 >        FVECT           udir, vdir;     /* tangent axes */
95          char            *outfn;         /* output file name (receiver) */
96          int             (*sample_basis)(struct param_s *p, int, FILE *);
97   } PARAMS;                       /* sender/receiver parameters */
# Line 140 | Line 142 | surf_type(const char *otype)
142          return(ST_NONE);
143   }
144  
143 /* Add arguments to oconv command */
144 static char *
145 oconv_command(int ac, char *av[])
146 {
147        static char     oconvbuf[2048] = "!oconv -f";
148        char            *cp = oconvbuf + 9;
149
150        while (ac-- > 0) {
151                if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) {
152                        fputs(progname, stderr);
153                        fputs(": too many file arguments!\n", stderr);
154                        exit(1);
155                }
156                *cp++ = ' ';
157                strcpy(cp, *av++);
158                while (*cp) cp++;
159        }
160        *cp = '\0';
161        return(oconvbuf);
162 }
163
145   /* Check if any of the characters in str2 are found in str1 */
146   static int
147   matchany(const char *str1, const char *str2)
# Line 175 | Line 156 | matchany(const char *str1, const char *str2)
156          return(0);
157   }
158  
159 + /* Add arguments to oconv command */
160 + static char *
161 + oconv_command(int ac, char *av[])
162 + {
163 +        static char     oconvbuf[2048] = "!oconv -f ";
164 +        char            *cp = oconvbuf + 10;
165 +        char            *recv = *av++;
166 +        
167 +        if (ac-- <= 0)
168 +                return(NULL);
169 +        while (ac-- > 0) {
170 +                strcpy(cp, *av++);
171 +                while (*cp) cp++;
172 +                *cp++ = ' ';
173 +                if (cp >= oconvbuf+(sizeof(oconvbuf)-32))
174 +                        goto overrun;
175 +        }
176 +                                /* receiver goes last */
177 +        if (matchany(recv, SPECIALS)) {
178 +                *cp++ = QUOTCHAR;
179 +                while (*recv) {
180 +                        if (cp >= oconvbuf+(sizeof(oconvbuf)-3))
181 +                                goto overrun;
182 +                        *cp++ = *recv++;
183 +                }
184 +                *cp++ = QUOTCHAR;
185 +                *cp = '\0';
186 +        } else
187 +                strcpy(cp, recv);
188 +        return(oconvbuf);
189 + overrun:
190 +        fputs(progname, stderr);
191 +        fputs(": too many file arguments!\n", stderr);
192 +        exit(1);
193 + }
194  
195   /* Convert a set of arguments into a command line for pipe() or system() */
196   static char *
# Line 189 | Line 205 | convert_commandline(char *cmd, const int len, char *av
205                          fputs(progname, stderr);
206                          return(NULL);
207                  }
208 <                if ((match = matchany(*av, SPECIALS))) {
208 >                if (matchany(*av, SPECIALS)) {
209                          const int       quote =
210   #ifdef ALTQUOT
211 <                                (match == QUOTCHAR) ? ALTQUOT :
211 >                                strchr(*av, QUOTCHAR) ? ALTQUOT :
212   #endif
213                                          QUOTCHAR;
214                          *cp++ = quote;
# Line 222 | Line 238 | popen_arglist(char *av[], char *mode)
238                  fputs(": command line too long in popen_arglist()\n", stderr);
239                  return(NULL);
240          }
241 <        if (verbose)
241 >        if (verbose > 0)
242                  fprintf(stderr, "%s: opening pipe %s: %s\n",
243                                  progname, (*mode=='w') ? "to" : "from", cmd);
244          return(popen(cmd, mode));
# Line 240 | Line 256 | my_exec(char *av[])
256                  fputs(": command line too long in my_exec()\n", stderr);
257                  return(1);
258          }
259 <        if (verbose)
259 >        if (verbose > 0)
260                  fprintf(stderr, "%s: running: %s\n", progname, cmd);
261          return(system(cmd));
262   }
# Line 255 | Line 271 | my_exec(char *av[])
271                  fprintf(stderr, "%s: cannot locate %s\n", progname, av[0]);
272                  return(1);
273          }
274 <        if (verbose) {
274 >        if (verbose > 0) {
275                  char    cmd[4096];
276                  if (!convert_commandline(cmd, sizeof(cmd), av))
277                          strcpy(cmd, "COMMAND TOO LONG TO SHOW");
# Line 313 | Line 329 | parse_params(PARAMS *p, char *pargs)
329   {
330          char    *cp = pargs;
331          int     nparams = 0;
332 +        int     quot;
333          int     i;
334  
335 <        for ( ; ; )
335 >        for ( ; ; ) {
336                  switch (*cp++) {
337                  case 'h':
338                          if (*cp++ != '=')
339                                  break;
340 +                        if ((*cp == '+') | (*cp == '-'))
341 +                                p->sign = *cp++;
342 +                        else
343 +                                p->sign = '+';
344                          p->hsiz = 0;
345                          i = 0;
346                          while (*cp && !isspace(*cp)) {
# Line 338 | Line 359 | parse_params(PARAMS *p, char *pargs)
359                                  break;
360                          if (!get_direction(p->vup, cp))
361                                  break;
362 +                        while (*cp && !isspace(*cp++))
363 +                                ;
364                          ++nparams;
365                          continue;
366                  case 'o':
367                          if (*cp++ != '=')
368                                  break;
369 +                        quot = 0;
370 +                        if ((*cp == '"') | (*cp == '\''))
371 +                                quot = *cp++;
372                          i = 0;
373 <                        while (*cp && !isspace(*cp++))
374 <                                i++;
373 >                        while (*cp && (quot ? (*cp != quot) : !isspace(*cp))) {
374 >                                i++; cp++;
375 >                        }
376                          if (!i)
377                                  break;
378 <                        *--cp = '\0';
378 >                        if (!*cp) {
379 >                                if (quot)
380 >                                        break;
381 >                                cp[1] = '\0';
382 >                        }
383 >                        *cp = '\0';
384                          p->outfn = savqstr(cp-i);
385 <                        *cp++ = ' ';
385 >                        *cp++ = quot ? quot : ' ';
386                          ++nparams;
387                          continue;
388                  case ' ':
# Line 363 | Line 395 | parse_params(PARAMS *p, char *pargs)
395                  default:
396                          break;
397                  }
398 <        fprintf(stderr, "%s: bad parameter string '%s'\n", progname, pargs);
398 >                break;
399 >        }
400 >        fprintf(stderr, "%s: bad parameter string: %s", progname, pargs);
401          exit(1);
402          return(-1);     /* pro forma return */
403   }
# Line 401 | Line 435 | finish_receiver(void)
435                  fputs(": undefined normal for hemisphere sampling\n", stderr);
436                  exit(1);
437          }
438 <        if (normalize(curparams.vup) == 0)
438 >        if (normalize(curparams.vup) == 0) {
439                  if (fabs(curparams.nrm[2]) < .7)
440                          curparams.vup[2] = 1;
441                  else
442                          curparams.vup[1] = 1;
443 +        }
444                                          /* determine sample type/bin */
445          if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') {
446 <                binv = "0";             /* uniform sampling -- one bin */
446 >                sprintf(sbuf, "if(-Dx*%g-Dy*%g-Dz*%g,0,-1)",
447 >                        curparams.nrm[0], curparams.nrm[1], curparams.nrm[2]);
448 >                binv = savqstr(sbuf);
449 >                nbins = "1";            /* uniform sampling -- one bin */
450                  uniform = 1;
451          } else if (tolower(curparams.hemis[0]) == 's' &&
452                                  tolower(curparams.hemis[1]) == 'c') {
# Line 419 | Line 457 | finish_receiver(void)
457                          exit(1);
458                  }
459                  calfn = shirchiufn; shirchiufn = NULL;
460 <                sprintf(sbuf, "SCdim=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
460 >                sprintf(sbuf, "SCdim=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g,RHS=%c1",
461                                  curparams.hsiz,
462                          curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
463 <                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
463 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2],
464 >                        curparams.sign);
465                  params = savqstr(sbuf);
466                  binv = "scbin";
467                  nbins = "SCdim*SCdim";
468          } else if ((tolower(curparams.hemis[0]) == 'r') |
469                          (tolower(curparams.hemis[0]) == 't')) {
470                  calfn = reinhfn; reinhfn = NULL;
471 <                sprintf(sbuf, "MF=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g",
471 >                sprintf(sbuf, "MF=%d,rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g,RHS=%c1",
472                                  curparams.hsiz,
473                          curparams.nrm[0], curparams.nrm[1], curparams.nrm[2],
474 <                        curparams.vup[0], curparams.vup[1], curparams.vup[2]);
474 >                        curparams.vup[0], curparams.vup[1], curparams.vup[2],
475 >                        curparams.sign);
476                  params = savqstr(sbuf);
477                  binv = "rbin";
478                  nbins = "Nrbins";
# Line 460 | Line 500 | finish_receiver(void)
500                                  progname, curparams.hemis);
501                  exit(1);
502          }
503 +        if (tolower(curparams.hemis[0]) == 'k') {
504 +                sprintf(sbuf, "RHS=%c1", curparams.sign);
505 +                params = savqstr(sbuf);
506 +        }
507          if (!uniform & (curparams.slist->styp == ST_SOURCE)) {
508                  SURF    *sp;
509                  for (sp = curparams.slist; sp != NULL; sp = sp->next)
# Line 507 | Line 551 | make_axes(FVECT uva[2], const FVECT nrm)
551   {
552          int     i;
553  
554 <        uva[1][0] = 0.5 - frandom();
511 <        uva[1][1] = 0.5 - frandom();
512 <        uva[1][2] = 0.5 - frandom();
513 <        for (i = 3; i--; )
514 <                if ((-0.6 < nrm[i]) & (nrm[i] < 0.6))
515 <                        break;
516 <        if (i < 0) {
554 >        if (!getperpendicular(uva[0], nrm, 1)) {
555                  fputs(progname, stderr);
556                  fputs(": bad surface normal in make_axes!\n", stderr);
557                  exit(1);
558          }
559 <        uva[1][i] = 1.0;
522 <        VCROSS(uva[0], uva[1], nrm);
523 <        normalize(uva[0]);
524 <        VCROSS(uva[1], nrm, uva[0]);
559 >        fcross(uva[1], nrm, uva[0]);
560   }
561  
562   /* Illegal sender surfaces end up here */
# Line 660 | Line 695 | sample_origin(PARAMS *p, FVECT orig, const FVECT rdir,
695                                          /* special case for lone surface */
696          if (p->nsurfs == 1) {
697                  sp = p->slist;
698 <                if (DOT(sp->snrm, rdir) >= -FTINY) {
698 >                if (DOT(sp->snrm, rdir) >= FTINY) {
699                          fprintf(stderr,
700                                  "%s: internal - sample behind sender '%s'\n",
701                                          progname, sp->sname);
# Line 783 | Line 818 | sample_reinhart(PARAMS *p, int b, FILE *fp)
818                  alt = (row+samp3[1])*RAH;
819                  azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row);
820                  duvw[2] = cos(alt);     /* measured from horizon */
821 <                duvw[0] = tcos(azi)*duvw[2];
822 <                duvw[1] = tsin(azi)*duvw[2];
821 >                duvw[0] = tsin(azi)*duvw[2];
822 >                duvw[1] = tcos(azi)*duvw[2];
823                  duvw[2] = sqrt(1. - duvw[2]*duvw[2]);
824                  for (i = 3; i--; )
825                          orig_dir[1][i] = -duvw[0]*p->udir[i] -
# Line 835 | Line 870 | sample_klems(PARAMS *p, int b, FILE *fp)
870  
871          while (n--) {                   /* stratified sampling */
872                  SDmultiSamp(samp2, 2, (n+frandom())/sampcnt);
873 <                if (!bo_getvec(duvw, b+samp2[1], kbasis[bi]))
873 >                if (!fo_getvec(duvw, b+samp2[1], kbasis[bi]))
874                          return(0);
875                  for (i = 3; i--; )
876 <                        orig_dir[1][i] = duvw[0]*p->udir[i] +
877 <                                                duvw[1]*p->vdir[i] +
876 >                        orig_dir[1][i] = -duvw[0]*p->udir[i] -
877 >                                                duvw[1]*p->vdir[i] -
878                                                  duvw[2]*p->nrm[i] ;
879                  if (!sample_origin(p, orig_dir[0], orig_dir[1], samp2[0]))
880                          return(0);
# Line 858 | Line 893 | prepare_sampler(void)
893                  fputs(": no sender surface!\n", stderr);
894                  return(-1);
895          }
896 <        if (curparams.outfn != NULL)    /* misplaced output file spec. */
896 >                                        /* misplaced output file spec. */
897 >        if ((curparams.outfn != NULL) & (verbose >= 0))
898                  fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n",
899                                  progname, curparams.outfn);
900                                          /* check/set basis hemisphere */
# Line 872 | Line 908 | prepare_sampler(void)
908                  fputs(": undefined normal for sender sampling\n", stderr);
909                  return(-1);
910          }
911 <        if (normalize(curparams.vup) == 0)
911 >        if (normalize(curparams.vup) == 0) {
912                  if (fabs(curparams.nrm[2]) < .7)
913                          curparams.vup[2] = 1;
914                  else
915                          curparams.vup[1] = 1;
916 <        VCROSS(curparams.udir, curparams.vup, curparams.nrm);
916 >        }
917 >        fcross(curparams.udir, curparams.vup, curparams.nrm);
918          if (normalize(curparams.udir) == 0) {
919                  fputs(progname, stderr);
920                  fputs(": up vector coincides with sender normal\n", stderr);
921                  return(-1);
922          }
923 <        VCROSS(curparams.vdir, curparams.nrm, curparams.udir);
923 >        fcross(curparams.vdir, curparams.nrm, curparams.udir);
924 >        if (curparams.sign == '-') {    /* left-handed coordinate system? */
925 >                curparams.udir[0] *= -1.;
926 >                curparams.udir[1] *= -1.;
927 >                curparams.udir[2] *= -1.;
928 >        }
929          if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1')
930                  curparams.sample_basis = sample_uniform;
931          else if (tolower(curparams.hemis[0]) == 's' &&
# Line 1008 | Line 1050 | add_surface(int st, const char *oname, FILE *fp)
1050                  snew->area *= PI*snew->area;
1051                  break;
1052          }
1053 <        if (snew->area <= FTINY) {
1053 >        if ((snew->area <= FTINY) & (verbose >= 0)) {
1054                  fprintf(stderr, "%s: warning - zero area for surface '%s'\n",
1055                                  progname, oname);
1056                  free(snew);
# Line 1066 | Line 1108 | add_recv_object(FILE *fp)
1108                                          /* else skip arguments */
1109          if (!fscanf(fp, "%d", &n)) return(0);
1110          while (n-- > 0) fscanf(fp, "%*s");
1111 <        if (!fscanf(fp, "%d", &n)) return;
1111 >        if (!fscanf(fp, "%d", &n)) return(0);
1112          while (n-- > 0) fscanf(fp, "%*d");
1113 <        if (!fscanf(fp, "%d", &n)) return;
1113 >        if (!fscanf(fp, "%d", &n)) return(0);
1114          while (n-- > 0) fscanf(fp, "%*f");
1115          return(0);
1116   }
# Line 1078 | Line 1120 | static int
1120   add_send_object(FILE *fp)
1121   {
1122          int             st;
1123 <        char            otype[32], oname[128];
1123 >        char            thismod[128], otype[32], oname[128];
1124          int             n;
1125  
1126 <        if (fscanf(fp, "%*s %s %s", otype, oname) != 2)
1126 >        if (fscanf(fp, "%s %s %s", thismod, otype, oname) != 3)
1127                  return(0);              /* must have hit EOF! */
1128          if (!strcmp(otype, "alias")) {
1129                  fscanf(fp, "%*s");      /* skip alias */
# Line 1094 | Line 1136 | add_send_object(FILE *fp)
1136                          fputs(": cannot use source as a sender!\n", stderr);
1137                          return(-1);
1138                  }
1139 +                if (strcmp(thismod, curmod)) {
1140 +                        if (curmod[0]) {
1141 +                                fputs(progname, stderr);
1142 +                                fputs(": warning - multiple modifiers in sender\n",
1143 +                                                stderr);
1144 +                        }
1145 +                        strcpy(curmod, thismod);
1146 +                }
1147                  parse_params(&curparams, newparams);
1148                  newparams[0] = '\0';
1149                  add_surface(st, oname, fp);     /* read & store surface */
# Line 1102 | Line 1152 | add_send_object(FILE *fp)
1152                                          /* else skip arguments */
1153          if (!fscanf(fp, "%d", &n)) return(0);
1154          while (n-- > 0) fscanf(fp, "%*s");
1155 <        if (!fscanf(fp, "%d", &n)) return;
1155 >        if (!fscanf(fp, "%d", &n)) return(0);
1156          while (n-- > 0) fscanf(fp, "%*d");
1157 <        if (!fscanf(fp, "%d", &n)) return;
1157 >        if (!fscanf(fp, "%d", &n)) return(0);
1158          while (n-- > 0) fscanf(fp, "%*f");
1159          return(0);
1160   }
# Line 1147 | Line 1197 | load_scene(const char *inspec, int (*ocb)(FILE *))
1197                                          strcat(newparams, inpbuf);
1198                                  continue;
1199                          }
1200 <                        while ((c = getc(fp)) != EOF && c != '\n');
1200 >                        while ((c = getc(fp)) != EOF && c != '\n')
1201                                  ;       /* else skipping comment */
1202                          continue;
1203                  }
# Line 1172 | Line 1222 | main(int argc, char *argv[])
1222   {
1223          char    fmtopt[6] = "-faa";     /* default output is ASCII */
1224          char    *xrs=NULL, *yrs=NULL, *ldopt=NULL;
1225 <        int     wantIrradiance = 0;
1225 >        char    *iropt = NULL;
1226          char    *sendfn;
1227          char    sampcntbuf[32], nsbinbuf[32];
1228          FILE    *rcfp;
# Line 1180 | Line 1230 | main(int argc, char *argv[])
1230          int     a, i;
1231                                          /* screen rcontrib options */
1232          progname = argv[0];
1233 <        for (a = 1; a < argc-2 && argv[a][0] == '-'; a++) {
1234 <                int     na = 1;         /* !! Keep consistent !! */
1235 <                switch (argv[a][1]) {
1233 >        for (a = 1; a < argc-2; a++) {
1234 >                int     na;
1235 >                                        /* check for argument expansion */
1236 >                while ((na = expandarg(&argc, &argv, a)) > 0)
1237 >                        ;
1238 >                if (na < 0) {
1239 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
1240 >                                        progname, argv[a]);
1241 >                        return(1);
1242 >                }
1243 >                if (argv[a][0] != '-' || !argv[a][1])
1244 >                        break;
1245 >                na = 1;
1246 >                switch (argv[a][1]) {   /* !! Keep consistent !! */
1247                  case 'v':               /* verbose mode */
1248 <                        verbose = !verbose;
1248 >                        verbose = 1;
1249                          na = 0;
1250                          continue;
1251                  case 'f':               /* special case for -fo, -ff, etc. */
# Line 1221 | Line 1282 | main(int argc, char *argv[])
1282                          na = 0;         /* we re-add this later */
1283                          continue;
1284                  case 'I':               /* only for pass-through mode */
1285 <                        wantIrradiance = 1;
1285 >                case 'i':
1286 >                        iropt = argv[a];
1287                          na = 0;
1288                          continue;
1289 <                case 'V':               /* options without arguments */
1290 <                case 'w':
1289 >                case 'w':               /* options without arguments */
1290 >                        if (argv[a][2] != '+') verbose = -1;
1291 >                case 'V':
1292                  case 'u':
1230                case 'i':
1293                  case 'h':
1294                  case 'r':
1295                          break;
# Line 1251 | Line 1313 | main(int argc, char *argv[])
1313                          if (argv[a][2] != 'v') na = 2;
1314                          break;
1315                  case 'a':               /* special case */
1316 <                        na = (argv[a][2] == 'v') ? 4 : 2;
1316 >                        if (argv[a][2] == 'p') {
1317 >                                na = 2; /* photon map [+ bandwidth(s)] */
1318 >                                if (a < argc-3 && atoi(argv[a+1]) > 0)
1319 >                                        na += 1 + (a < argc-4 && atoi(argv[a+2]) > 0);
1320 >                        } else
1321 >                                na = (argv[a][2] == 'v') ? 4 : 2;
1322                          break;
1323                  case 'm':               /* special case */
1324                          if (!argv[a][2]) goto userr;
1325                          na = (argv[a][2] == 'e') | (argv[a][2] == 'a') ? 4 : 2;
1326                          break;
1260                case '\0':              /* pass-through mode */
1261                        goto done_opts;
1327                  default:                /* anything else is verbotten */
1328                          goto userr;
1329                  }
# Line 1268 | Line 1333 | main(int argc, char *argv[])
1333                  while (--na)            /* + arguments if any */
1334                          rcarg[nrcargs++] = argv[++a];
1335          }
1271 done_opts:
1336          if (a > argc-2)
1337                  goto userr;             /* check at end of options */
1338          sendfn = argv[a++];             /* assign sender & receiver inputs */
1339          if (sendfn[0] == '-') {         /* user wants pass-through mode? */
1340                  if (sendfn[1]) goto userr;
1341                  sendfn = NULL;
1342 <                if (wantIrradiance) {
1342 >                if (iropt) {
1343                          CHECKARGC(1);
1344 <                        rcarg[nrcargs++] = "-I";
1344 >                        rcarg[nrcargs++] = iropt;
1345                  }
1346                  if (xrs) {
1347                          CHECKARGC(2);
# Line 1295 | Line 1359 | done_opts:
1359                  }
1360                  if (sampcnt <= 0) sampcnt = 1;
1361          } else {                        /* else in sampling mode */
1362 <                if (wantIrradiance) {
1362 >                if (iropt) {
1363                          fputs(progname, stderr);
1364 <                        fputs(": -I supported for pass-through only\n", stderr);
1364 >                        fputs(": -i, -I supported for pass-through only\n", stderr);
1365                          return(1);
1366                  }
1367                  fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
# Line 1319 | Line 1383 | done_opts:
1383                  return(my_exec(rcarg)); /* rcontrib does everything */
1384          }
1385          clear_params(&curparams, 0);    /* else load sender surface & params */
1386 +        curmod[0] = '\0';
1387          if (load_scene(sendfn, add_send_object) < 0)
1388                  return(1);
1389          if ((nsbins = prepare_sampler()) <= 0)
# Line 1336 | Line 1401 | done_opts:
1401   #ifdef getc_unlocked
1402          flockfile(rcfp);
1403   #endif
1404 <        if (verbose) {
1404 >        if (verbose > 0) {
1405                  fprintf(stderr, "%s: sampling %d directions", progname, nsbins);
1406                  if (curparams.nsurfs > 1)
1407                          fprintf(stderr, " (%d elements)\n", curparams.nsurfs);
# Line 1346 | Line 1411 | done_opts:
1411          for (i = 0; i < nsbins; i++)    /* send rcontrib ray samples */
1412                  if (!(*curparams.sample_basis)(&curparams, i, rcfp))
1413                          return(1);
1414 <        return(pclose(rcfp) == 0);      /* all finished! */
1414 >        return(pclose(rcfp) < 0);       /* all finished! */
1415   userr:
1416          if (a < argc-2)
1417                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1418 <        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1418 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n",
1419                                  progname);
1420          return(1);
1421   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines