362 |
|
case ' ': |
363 |
|
case '\t': |
364 |
|
case '\r': |
365 |
– |
continue; |
365 |
|
case '\n': |
366 |
+ |
continue; |
367 |
|
case '\0': |
368 |
|
return(nparams); |
369 |
|
default: |
417 |
|
} |
418 |
|
/* determine sample type/bin */ |
419 |
|
if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') { |
420 |
< |
binv = "0"; /* uniform sampling -- one bin */ |
420 |
> |
sprintf(sbuf, "if(-Dx*%g-Dy*%g-Dz*%g,0,-1)", |
421 |
> |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2]); |
422 |
> |
binv = savqstr(sbuf); |
423 |
> |
nbins = "1"; /* uniform sampling -- one bin */ |
424 |
|
uniform = 1; |
425 |
|
} else if (tolower(curparams.hemis[0]) == 's' && |
426 |
|
tolower(curparams.hemis[1]) == 'c') { |
519 |
|
{ |
520 |
|
int i; |
521 |
|
|
522 |
< |
uva[1][0] = 0.5 - frandom(); |
520 |
< |
uva[1][1] = 0.5 - frandom(); |
521 |
< |
uva[1][2] = 0.5 - frandom(); |
522 |
< |
for (i = 3; i--; ) |
523 |
< |
if ((-0.6 < nrm[i]) & (nrm[i] < 0.6)) |
524 |
< |
break; |
525 |
< |
if (i < 0) { |
522 |
> |
if (!getperpendicular(uva[0], nrm)) { |
523 |
|
fputs(progname, stderr); |
524 |
|
fputs(": bad surface normal in make_axes!\n", stderr); |
525 |
|
exit(1); |
526 |
|
} |
527 |
< |
uva[1][i] = 1.0; |
531 |
< |
VCROSS(uva[0], uva[1], nrm); |
532 |
< |
normalize(uva[0]); |
533 |
< |
VCROSS(uva[1], nrm, uva[0]); |
527 |
> |
fcross(uva[1], nrm, uva[0]); |
528 |
|
} |
529 |
|
|
530 |
|
/* Illegal sender surfaces end up here */ |
786 |
|
alt = (row+samp3[1])*RAH; |
787 |
|
azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row); |
788 |
|
duvw[2] = cos(alt); /* measured from horizon */ |
789 |
< |
duvw[0] = tcos(azi)*duvw[2]; |
790 |
< |
duvw[1] = tsin(azi)*duvw[2]; |
789 |
> |
duvw[0] = tsin(azi)*duvw[2]; |
790 |
> |
duvw[1] = tcos(azi)*duvw[2]; |
791 |
|
duvw[2] = sqrt(1. - duvw[2]*duvw[2]); |
792 |
|
for (i = 3; i--; ) |
793 |
|
orig_dir[1][i] = -duvw[0]*p->udir[i] - |
1083 |
|
add_send_object(FILE *fp) |
1084 |
|
{ |
1085 |
|
int st; |
1086 |
< |
char otype[32], oname[128]; |
1086 |
> |
char thismod[128], otype[32], oname[128]; |
1087 |
|
int n; |
1088 |
|
|
1089 |
< |
if (fscanf(fp, "%*s %s %s", otype, oname) != 2) |
1089 |
> |
if (fscanf(fp, "%s %s %s", thismod, otype, oname) != 2) |
1090 |
|
return(0); /* must have hit EOF! */ |
1091 |
|
if (!strcmp(otype, "alias")) { |
1092 |
|
fscanf(fp, "%*s"); /* skip alias */ |
1099 |
|
fputs(": cannot use source as a sender!\n", stderr); |
1100 |
|
return(-1); |
1101 |
|
} |
1102 |
+ |
if (strcmp(thismod, curmod)) { |
1103 |
+ |
if (curmod[0]) { |
1104 |
+ |
fputs(progname, stderr); |
1105 |
+ |
fputs(": warning - multiple modifiers in sender\n", |
1106 |
+ |
stderr); |
1107 |
+ |
} |
1108 |
+ |
strcpy(curmod, thismod); |
1109 |
+ |
} |
1110 |
|
parse_params(&curparams, newparams); |
1111 |
|
newparams[0] = '\0'; |
1112 |
|
add_surface(st, oname, fp); /* read & store surface */ |
1341 |
|
return(my_exec(rcarg)); /* rcontrib does everything */ |
1342 |
|
} |
1343 |
|
clear_params(&curparams, 0); /* else load sender surface & params */ |
1344 |
+ |
curmod[0] = '\0'; |
1345 |
|
if (load_scene(sendfn, add_send_object) < 0) |
1346 |
|
return(1); |
1347 |
|
if ((nsbins = prepare_sampler()) <= 0) |
1359 |
|
#ifdef getc_unlocked |
1360 |
|
flockfile(rcfp); |
1361 |
|
#endif |
1362 |
< |
if (verbose) { |
1362 |
> |
if (verbose > 0) { |
1363 |
|
fprintf(stderr, "%s: sampling %d directions", progname, nsbins); |
1364 |
|
if (curparams.nsurfs > 1) |
1365 |
|
fprintf(stderr, " (%d elements)\n", curparams.nsurfs); |
1369 |
|
for (i = 0; i < nsbins; i++) /* send rcontrib ray samples */ |
1370 |
|
if (!(*curparams.sample_basis)(&curparams, i, rcfp)) |
1371 |
|
return(1); |
1372 |
< |
return(pclose(rcfp) == 0); /* all finished! */ |
1372 |
> |
return(pclose(rcfp) < 0); /* all finished! */ |
1373 |
|
userr: |
1374 |
|
if (a < argc-2) |
1375 |
|
fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]); |