| 606 |
|
} |
| 607 |
|
ptp->ntris = 0; |
| 608 |
|
v2l->p = (void *)ptp; |
| 609 |
< |
if (!polyTriangulate(v2l, add_triangle)) |
| 609 |
> |
if (!polyTriangulate(v2l, add_triangle)) { |
| 610 |
> |
fprintf(stderr, |
| 611 |
> |
"%s: cannot triangulate polygon '%s'\n", |
| 612 |
> |
progname, sp->sname); |
| 613 |
|
return(0); |
| 614 |
+ |
} |
| 615 |
|
for (i = ptp->ntris; i--; ) { |
| 616 |
|
int a = ptp->tri[i].vndx[0]; |
| 617 |
|
int b = ptp->tri[i].vndx[1]; |
| 660 |
|
/* special case for lone surface */ |
| 661 |
|
if (p->nsurfs == 1) { |
| 662 |
|
sp = p->slist; |
| 663 |
< |
if (DOT(sp->snrm, rdir) >= -FTINY) |
| 664 |
< |
return(0); /* behind surface! */ |
| 663 |
> |
if (DOT(sp->snrm, rdir) >= -FTINY) { |
| 664 |
> |
fprintf(stderr, |
| 665 |
> |
"%s: internal - sample behind sender '%s'\n", |
| 666 |
> |
progname, sp->sname); |
| 667 |
> |
return(0); |
| 668 |
> |
} |
| 669 |
|
return((*orig_in_surf[sp->styp])(orig, sp, x)); |
| 670 |
|
} |
| 671 |
|
if (p->nsurfs > nall) { /* (re)allocate surface area cache */ |
| 679 |
|
projsa[i] = -DOT(sp->snrm, rdir) * sp->area; |
| 680 |
|
tarea += projsa[i] *= (double)(projsa[i] > FTINY); |
| 681 |
|
} |
| 682 |
< |
if (tarea <= FTINY) /* wrong side of sender? */ |
| 682 |
> |
if (tarea <= FTINY) { /* wrong side of sender? */ |
| 683 |
> |
fputs(progname, stderr); |
| 684 |
> |
fputs(": internal - sample behind all sender elements!\n", |
| 685 |
> |
stderr); |
| 686 |
|
return(0); |
| 687 |
+ |
} |
| 688 |
|
tarea *= x; /* get surface from list */ |
| 689 |
|
for (i = 0, sp = p->slist; tarea > projsa[i]; sp = sp->next) |
| 690 |
|
tarea -= projsa[i++]; |
| 757 |
|
#define T_NALT 7 |
| 758 |
|
static const int tnaz[T_NALT] = {30, 30, 24, 24, 18, 12, 6}; |
| 759 |
|
const int RowMax = T_NALT*p->hsiz + 1; |
| 760 |
< |
const double RAH = (.25*PI)/(RowMax-.5); |
| 760 |
> |
const double RAH = (.5*PI)/(RowMax-.5); |
| 761 |
|
#define rnaz(r) (r >= RowMax-1 ? 1 : p->hsiz*tnaz[r/p->hsiz]) |
| 762 |
|
int n = sampcnt; |
| 763 |
|
int row, col; |
| 782 |
|
SDmultiSamp(samp3, 3, (n+frandom())/sampcnt); |
| 783 |
|
alt = (row+samp3[1])*RAH; |
| 784 |
|
azi = (2.*PI)*(col+samp3[2]-.5)/rnaz(row); |
| 785 |
< |
duvw[2] = tcos(alt); /* measured from horizon */ |
| 785 |
> |
duvw[2] = cos(alt); /* measured from horizon */ |
| 786 |
|
duvw[0] = tcos(azi)*duvw[2]; |
| 787 |
|
duvw[1] = tsin(azi)*duvw[2]; |
| 788 |
|
duvw[2] = sqrt(1. - duvw[2]*duvw[2]); |
| 1019 |
|
curparams.nsurfs++; |
| 1020 |
|
return; |
| 1021 |
|
badcount: |
| 1022 |
< |
fprintf(stderr, "%s: bad argument count for surface '%s'\n", |
| 1022 |
> |
fprintf(stderr, "%s: bad argument count for surface element '%s'\n", |
| 1023 |
|
progname, oname); |
| 1024 |
|
exit(1); |
| 1025 |
|
badnorm: |
| 1026 |
< |
fprintf(stderr, "%s: bad orientation for surface '%s'\n", |
| 1026 |
> |
fprintf(stderr, "%s: bad orientation for surface element '%s'\n", |
| 1027 |
|
progname, oname); |
| 1028 |
|
exit(1); |
| 1029 |
|
} |
| 1324 |
|
if (verbose) { |
| 1325 |
|
fprintf(stderr, "%s: sampling %d directions", progname, nsbins); |
| 1326 |
|
if (curparams.nsurfs > 1) |
| 1327 |
< |
fprintf(stderr, " (%d surfaces)\n", curparams.nsurfs); |
| 1327 |
> |
fprintf(stderr, " (%d elements)\n", curparams.nsurfs); |
| 1328 |
|
else |
| 1329 |
|
fputc('\n', stderr); |
| 1330 |
|
} |