--- ray/src/rt/colortab.c 1989/10/03 14:06:58 1.4 +++ ray/src/rt/colortab.c 1989/10/12 11:12:48 1.7 @@ -27,7 +27,7 @@ static char SCCSid[] = "$SunId$ LBL"; /* minimum box count for adaptive partition */ #define MINSAMP 7 /* maximum distance^2 before color reassign */ -#define MAXDST2 5 +#define MAXDST2 12 /* maximum frame buffer depth */ #define FBDEPTH 8 /* map a color */ @@ -37,12 +37,13 @@ static char SCCSid[] = "$SunId$ LBL"; #define CNODE short #define set_branch(p,c) ((c)<<2|(p)) #define set_pval(pv) ((pv)<<2|3) +#define is_branch(cn) (((cn)&3)!=3) #define is_pval(cn) (((cn)&3)==3) #define part(cn) ((cn)>>2) #define prim(cn) ((cn)&3) #define pval(cn) ((cn)>>2) /* our color table */ -struct tabent { +static struct tabent { long sum[3]; /* sum of colors using this entry */ long n; /* number of colors */ short ent[3]; /* current table value */ @@ -61,12 +62,14 @@ int new_ctab(ncolors) /* start new color table with max ncolors */ int ncolors; { - if (ncolors < 1 || ncolors > 1< 1< 0; h--) { - if (is_pval(*p.t)) - break; + for (p.t = ctree, h = 0; is_branch(*p.t); h++) if (cv[prim(*p.t)] < part(*p.t)) - p.t++; /* left branch */ + p.t += 1<>1); + cut(tree+(1<>1); /* do right branch */ kb[prim(*tree)][0] = part(*tree); kb[prim(*tree)][1] = box[prim(*tree)][1]; - cut(tree+(1<>1, c1); + cut(tree+(1<<(level+1)), level+1, kb, (c0+c1)>>1, c1); }