| 7 |
|
|
| 8 |
|
#include "ray.h" |
| 9 |
|
#include "random.h" |
| 10 |
+ |
#include "paths.h" |
| 11 |
|
#include "resolu.h" |
| 12 |
|
|
| 13 |
|
#define NTRUNKBR 4 /* number of branches at trunk */ |
| 30 |
|
COLOR intens; /* output times solid angle */ |
| 31 |
|
} LOSTLIGHT; |
| 32 |
|
|
| 32 |
– |
extern char *progname; |
| 33 |
– |
|
| 33 |
|
FVECT scene_cent; /* center of octree cube */ |
| 34 |
|
RREAL scene_rad; /* radius to get outside cube from center */ |
| 35 |
|
|
| 115 |
|
VCOPY(myray.rdir, sdir); |
| 116 |
|
myray.rmax = 0.; |
| 117 |
|
ray_trace(&myray); |
| 118 |
< |
setcolr(leaf->val, colval(myray.rcol,RED), |
| 120 |
< |
colval(myray.rcol,GRN), |
| 121 |
< |
colval(myray.rcol,BLU)); |
| 118 |
> |
scolor_colr(leaf->val, myray.rcol); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
/* Initialize a branch node contained in the given spherical triangle */ |
| 184 |
|
|
| 185 |
|
/* Sample sphere using triangular geodesic mesh */ |
| 186 |
|
TRITREE * |
| 187 |
< |
geosample(int nsamps) |
| 187 |
> |
geosample(long nsamps) |
| 188 |
|
{ |
| 189 |
|
int depth; |
| 190 |
|
TRITREE *tree; |
| 193 |
|
/* figure out depth */ |
| 194 |
|
if ((nsamps -= 4) < 0) |
| 195 |
|
error(USER, "minimum number of samples is 4"); |
| 196 |
< |
nsamps = nsamps*3/NTRUNKBR; /* round up */ |
| 196 |
> |
nsamps = nsamps*(NTRUNKBR-1)/NTRUNKBR; /* round up */ |
| 197 |
|
for (depth = 0; nsamps > 1; depth++) |
| 198 |
|
nsamps >>= 2; |
| 199 |
|
/* make base tetrahedron */ |
| 239 |
|
double |
| 240 |
|
get_threshold(const TRITREE *tree) |
| 241 |
|
{ |
| 242 |
+ |
long samptotal = 0; |
| 243 |
|
long exphisto[256]; |
| 246 |
– |
long samptotal; |
| 244 |
|
int i; |
| 245 |
|
/* compute sample histogram */ |
| 246 |
< |
memset((void *)exphisto, 0, sizeof(exphisto)); |
| 246 |
> |
memset(exphisto, 0, sizeof(exphisto)); |
| 247 |
|
for (i = 0; i < NTRUNKBR; i++) |
| 248 |
|
get_ehisto(&tree->kid[i], exphisto); |
| 249 |
|
/* use 98th percentile */ |
| 352 |
|
if (remaining) |
| 353 |
|
return; |
| 354 |
|
/* consolidate empties */ |
| 355 |
< |
free((void *)node->kid); node->kid = NULL; |
| 355 |
> |
free(node->kid); node->kid = NULL; |
| 356 |
|
copycolr(node->val, blkclr); |
| 357 |
|
node->sd = node->gdv[0]; /* doesn't really matter */ |
| 358 |
|
} |
| 384 |
|
if (fdir2diff(thisp->sd,cent) <= maxr2) { |
| 385 |
|
LOSTLIGHT *mynext = thisp->next; |
| 386 |
|
addcolor(intens, thisp->intens); |
| 387 |
< |
free((void *)thisp); |
| 387 |
> |
free(thisp); |
| 388 |
|
lastp->next = mynext; |
| 389 |
|
} else |
| 390 |
|
lastp = thisp; |
| 395 |
|
void |
| 396 |
|
mksources(TRITREE *samptree, double thresh, double maxang) |
| 397 |
|
{ |
| 398 |
+ |
#define MAXITER 100 |
| 399 |
|
const int ethresh = (int)(log(thresh)/log(2.) + (COLXS+.5)); |
| 400 |
|
const double maxomega = 2.*PI*(1. - cos(PI/180./2.*maxang)); |
| 401 |
|
const double minintens = .05*thresh*maxomega; |
| 402 |
+ |
int niter = MAXITER; |
| 403 |
|
int nsrcs = 0; |
| 404 |
|
LOSTLIGHT *lostlightlist = NULL; |
| 405 |
|
int emax; |
| 425 |
|
*/ |
| 426 |
|
if (thresh <= FTINY) |
| 427 |
|
return; |
| 428 |
< |
for ( ; ; ) { |
| 428 |
> |
while (niter--) { |
| 429 |
|
emax = ethresh; /* find brightest unclaimed */ |
| 430 |
|
startleaf = NULL; |
| 431 |
|
for (i = 0; i < NTRUNKBR; i++) { |
| 456 |
|
thisethresh); |
| 457 |
|
if (normalize(vsum) == .0) |
| 458 |
|
break; |
| 459 |
< |
movedist = acos(DOT(vsum,curcent)); |
| 459 |
> |
movedist = Acos(DOT(vsum,curcent)); |
| 460 |
|
if (movedist > growstep) { |
| 461 |
|
VSUB(vsum, vsum, curcent); |
| 462 |
|
movedist = growstep/VLEN(vsum); |
| 488 |
|
printf("0\n0\n4 %f %f %f %f\n", |
| 489 |
|
curcent[0], curcent[1], curcent[2], |
| 490 |
|
2.*180./PI*currad); |
| 491 |
+ |
niter = MAXITER; |
| 492 |
|
} |
| 493 |
+ |
#undef MAXITER |
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
int |
| 501 |
|
TRITREE *samptree; |
| 502 |
|
double thresh = 0; |
| 503 |
|
int i; |
| 504 |
< |
|
| 505 |
< |
progname = argv[0]; |
| 504 |
> |
|
| 505 |
> |
fixargv0(argv[0]); /* sets global progname */ |
| 506 |
> |
|
| 507 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 508 |
|
switch (argv[i][1]) { |
| 509 |
|
case 'd': /* number of samples */ |
| 556 |
|
} |
| 557 |
|
|
| 558 |
|
void |
| 559 |
< |
eputs(char *s) |
| 559 |
> |
eputs(const char *s) |
| 560 |
|
{ |
| 561 |
|
static int midline = 0; |
| 562 |
|
|
| 574 |
|
} |
| 575 |
|
|
| 576 |
|
void |
| 577 |
< |
wputs(char *s) |
| 577 |
> |
wputs(const char *s) |
| 578 |
|
{ |
| 579 |
|
/* no warnings */ |
| 580 |
|
} |