--- ray/src/util/rfluxmtx.c 2017/04/13 22:47:17 2.44 +++ ray/src/util/rfluxmtx.c 2019/12/10 19:18:43 2.50 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rfluxmtx.c,v 2.44 2017/04/13 22:47:17 greg Exp $"; +static const char RCSid[] = "$Id: rfluxmtx.c,v 2.50 2019/12/10 19:18:43 greg Exp $"; #endif /* * Calculate flux transfer matrix or matrices using rcontrib @@ -18,7 +18,9 @@ static const char RCSid[] = "$Id: rfluxmtx.c,v 2.44 20 #include "triangulate.h" #include "platform.h" -#define MAXRCARG 512 +#ifndef MAXRCARG +#define MAXRCARG 10000 +#endif char *progname; /* global argv[0] */ @@ -139,15 +141,23 @@ oconv_command(int ac, char *av[]) if (ac-- <= 0) return(NULL); if (verbose < 0) { /* turn off warnings */ - strcpy(cp, "-w- "); - cp += 4; + strcpy(cp, "-w "); + cp += 3; } - while (ac-- > 0) { - strcpy(cp, *av++); - while (*cp) cp++; - *cp++ = ' '; - if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) + while (ac-- > 0) { /* copy each argument */ + int len = strlen(*av); + if (cp+len+4 >= oconvbuf+sizeof(oconvbuf)) goto overrun; + if (matchany(*av, SPECIALS)) { + *cp++ = QUOTCHAR; + strcpy(cp, *av++); + cp += len; + *cp++ = QUOTCHAR; + } else { + strcpy(cp, *av++); + cp += len; + } + *cp++ = ' '; } /* receiver goes last */ if (matchany(recv, SPECIALS)) { @@ -659,7 +669,7 @@ sample_origin(PARAMS *p, FVECT orig, const FVECT rdir, projsa[i] = -DOT(sp->snrm, rdir) * sp->area; tarea += projsa[i] *= (double)(projsa[i] > FTINY); } - if (tarea <= FTINY) { /* wrong side of sender? */ + if (tarea < 0) { /* wrong side of sender? */ fputs(progname, stderr); fputs(": internal - sample behind all sender elements!\n", stderr); @@ -760,11 +770,13 @@ sample_reinhart(PARAMS *p, int b, FILE *fp) } while (n--) { /* stratified sampling */ SDmultiSamp(samp3, 3, (n+frandom())/sampcnt); + if (row >= RowMax-1) /* avoid crowding at zenith */ + samp3[1] *= samp3[1]; alt = (row+samp3[1])*RAH; azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row); duvw[2] = cos(alt); /* measured from horizon */ duvw[0] = tsin(azi)*duvw[2]; - duvw[1] = tcos(azi)*duvw[2]; + duvw[1] = -tcos(azi)*duvw[2]; duvw[2] = sqrt(1. - duvw[2]*duvw[2]); for (i = 3; i--; ) orig_dir[1][i] = -duvw[0]*p->udir[i] - @@ -1232,7 +1244,9 @@ main(int argc, char *argv[]) na = 0; continue; case 'w': /* options without arguments */ - if (argv[a][2] != '+') verbose = -1; + if (!argv[a][2] || strchr("+1tTyY", argv[a][2]) == NULL) + verbose = -1; + break; case 'V': case 'u': case 'h':