--- ray/src/util/rfluxmtx.c 2014/08/26 19:10:10 2.18 +++ ray/src/util/rfluxmtx.c 2015/03/12 15:36:11 2.24 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rfluxmtx.c,v 2.18 2014/08/26 19:10:10 greg Exp $"; +static const char RCSid[] = "$Id: rfluxmtx.c,v 2.24 2015/03/12 15:36:11 greg Exp $"; #endif /* * Calculate flux transfer matrix or matrices using rcontrib @@ -362,8 +362,8 @@ parse_params(PARAMS *p, char *pargs) case ' ': case '\t': case '\r': - continue; case '\n': + continue; case '\0': return(nparams); default: @@ -417,7 +417,10 @@ finish_receiver(void) } /* determine sample type/bin */ if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') { - binv = "0"; /* uniform sampling -- one bin */ + sprintf(sbuf, "if(-Dx*%g-Dy*%g-Dz*%g,0,-1)", + curparams.nrm[0], curparams.nrm[1], curparams.nrm[2]); + binv = savqstr(sbuf); + nbins = "1"; /* uniform sampling -- one bin */ uniform = 1; } else if (tolower(curparams.hemis[0]) == 's' && tolower(curparams.hemis[1]) == 'c') { @@ -516,21 +519,12 @@ make_axes(FVECT uva[2], const FVECT nrm) { int i; - uva[1][0] = 0.5 - frandom(); - uva[1][1] = 0.5 - frandom(); - uva[1][2] = 0.5 - frandom(); - for (i = 3; i--; ) - if ((-0.6 < nrm[i]) & (nrm[i] < 0.6)) - break; - if (i < 0) { + if (!getperpendicular(uva[0], nrm)) { fputs(progname, stderr); fputs(": bad surface normal in make_axes!\n", stderr); exit(1); } - uva[1][i] = 1.0; - VCROSS(uva[0], uva[1], nrm); - normalize(uva[0]); - VCROSS(uva[1], nrm, uva[0]); + fcross(uva[1], nrm, uva[0]); } /* Illegal sender surfaces end up here */ @@ -1089,10 +1083,10 @@ static int add_send_object(FILE *fp) { int st; - char otype[32], oname[128]; + char thismod[128], otype[32], oname[128]; int n; - if (fscanf(fp, "%*s %s %s", otype, oname) != 2) + if (fscanf(fp, "%s %s %s", thismod, otype, oname) != 2) return(0); /* must have hit EOF! */ if (!strcmp(otype, "alias")) { fscanf(fp, "%*s"); /* skip alias */ @@ -1105,6 +1099,14 @@ add_send_object(FILE *fp) fputs(": cannot use source as a sender!\n", stderr); return(-1); } + if (strcmp(thismod, curmod)) { + if (curmod[0]) { + fputs(progname, stderr); + fputs(": warning - multiple modifiers in sender\n", + stderr); + } + strcpy(curmod, thismod); + } parse_params(&curparams, newparams); newparams[0] = '\0'; add_surface(st, oname, fp); /* read & store surface */ @@ -1339,6 +1341,7 @@ main(int argc, char *argv[]) return(my_exec(rcarg)); /* rcontrib does everything */ } clear_params(&curparams, 0); /* else load sender surface & params */ + curmod[0] = '\0'; if (load_scene(sendfn, add_send_object) < 0) return(1); if ((nsbins = prepare_sampler()) <= 0) @@ -1356,7 +1359,7 @@ main(int argc, char *argv[]) #ifdef getc_unlocked flockfile(rcfp); #endif - if (verbose) { + if (verbose > 0) { fprintf(stderr, "%s: sampling %d directions", progname, nsbins); if (curparams.nsurfs > 1) fprintf(stderr, " (%d elements)\n", curparams.nsurfs); @@ -1366,7 +1369,7 @@ main(int argc, char *argv[]) for (i = 0; i < nsbins; i++) /* send rcontrib ray samples */ if (!(*curparams.sample_basis)(&curparams, i, rcfp)) return(1); - return(pclose(rcfp) == 0); /* all finished! */ + return(pclose(rcfp) < 0); /* all finished! */ userr: if (a < argc-2) fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);