50 |
|
static RTREE * |
51 |
|
newtwig(void) /* allocate a twig */ |
52 |
|
{ |
53 |
< |
register int bi; |
53 |
> |
int bi; |
54 |
|
|
55 |
|
if (twigbundle == NULL) { /* initialize */ |
56 |
|
twigbundle = (RTREE **)malloc(sizeof(RTREE *)); |
82 |
|
int really |
83 |
|
) |
84 |
|
{ |
85 |
< |
register int i; |
85 |
> |
int i; |
86 |
|
|
87 |
|
qtrunk.flgs = CH_ANY; /* chop down tree */ |
88 |
|
if (twigbundle == NULL) |
103 |
|
|
104 |
|
|
105 |
|
#define LEAFSIZ (3*sizeof(float)+sizeof(int32)+\ |
106 |
< |
sizeof(TMbright)+6*sizeof(BYTE)) |
106 |
> |
sizeof(TMbright)+6*sizeof(uby8)) |
107 |
|
|
108 |
< |
extern int |
108 |
> |
int |
109 |
|
qtAllocLeaves( /* allocate space for n leaves */ |
110 |
< |
register int n |
110 |
> |
int n |
111 |
|
) |
112 |
|
{ |
113 |
|
unsigned nbytes; |
114 |
< |
register unsigned i; |
114 |
> |
unsigned i; |
115 |
|
|
116 |
|
qtFreeTree(0); /* make sure tree is empty */ |
117 |
|
if (n <= 0) |
132 |
|
qtL.wp = (float (*)[3])qtL.base; |
133 |
|
qtL.wd = (int32 *)(qtL.wp + n); |
134 |
|
qtL.brt = (TMbright *)(qtL.wd + n); |
135 |
< |
qtL.chr = (BYTE (*)[3])(qtL.brt + n); |
136 |
< |
qtL.rgb = (BYTE (*)[3])(qtL.chr + n); |
135 |
> |
qtL.chr = (uby8 (*)[3])(qtL.brt + n); |
136 |
> |
qtL.rgb = (uby8 (*)[3])(qtL.chr + n); |
137 |
|
qtL.nl = n; |
138 |
|
qtL.tml = qtL.bl = qtL.tl = 0; |
139 |
|
falleaves = -1; |
143 |
|
#undef LEAFSIZ |
144 |
|
|
145 |
|
|
146 |
< |
extern void |
146 |
> |
void |
147 |
|
qtFreeLeaves(void) /* free our allocated leaves and twigs */ |
148 |
|
{ |
149 |
|
qtFreeTree(1); /* free tree also */ |
157 |
|
|
158 |
|
static void |
159 |
|
shaketree( /* shake dead leaves from tree */ |
160 |
< |
register RTREE *tp |
160 |
> |
RTREE *tp |
161 |
|
) |
162 |
|
{ |
163 |
< |
register int i, li; |
163 |
> |
int i, li; |
164 |
|
|
165 |
|
for (i = 0; i < 4; i++) |
166 |
|
if (tp->flgs & BRF(i)) { |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
< |
extern int |
178 |
> |
int |
179 |
|
qtCompost( /* free up some leaves */ |
180 |
|
int pct |
181 |
|
) |
182 |
|
{ |
183 |
< |
register int32 *fl; |
183 |
> |
int32 *fl; |
184 |
|
int nused, nclear, nmapped; |
185 |
|
/* figure out how many leaves to clear */ |
186 |
|
nclear = qtL.nl * pct / 100; |
210 |
|
} |
211 |
|
|
212 |
|
|
213 |
< |
extern int |
213 |
> |
int |
214 |
|
qtFindLeaf( /* find closest leaf to (x,y) */ |
215 |
|
int x, |
216 |
|
int y |
217 |
|
) |
218 |
|
{ |
219 |
< |
register RTREE *tp = &qtrunk; |
219 |
> |
RTREE *tp = &qtrunk; |
220 |
|
int li = -1; |
221 |
|
int x0=0, y0=0, x1=odev.hres, y1=odev.vres; |
222 |
|
int mx, my; |
223 |
< |
register int q; |
223 |
> |
int q; |
224 |
|
/* check limits */ |
225 |
|
if (x < 0 || x >= odev.hres || y < 0 || y >= odev.vres) |
226 |
|
return(-1); |
251 |
|
|
252 |
|
static int |
253 |
|
putleaf( /* put a leaf in our tree */ |
254 |
< |
register int li, |
254 |
> |
int li, |
255 |
|
int drop |
256 |
|
) |
257 |
|
{ |
258 |
< |
register RTREE *tp = &qtrunk; |
258 |
> |
RTREE *tp = &qtrunk; |
259 |
|
int x0=0, y0=0, x1=odev.hres, y1=odev.vres; |
260 |
< |
register int lo = -1; |
260 |
> |
int lo = -1; |
261 |
|
double d2; |
262 |
|
int x, y, mx, my; |
263 |
|
double z; |
264 |
|
FVECT ip, wp, vd; |
265 |
< |
register int q; |
265 |
> |
int q; |
266 |
|
/* check for dead leaf */ |
267 |
|
if (!qtL.chr[li][1] && !(qtL.chr[li][0] | qtL.chr[li][2])) |
268 |
|
return(0); |
269 |
|
/* compute leaf location in view */ |
270 |
|
VCOPY(wp, qtL.wp[li]); |
271 |
< |
viewloc(ip, &odev.v, wp); |
272 |
< |
if (ip[2] <= 0. || ip[0] < 0. || ip[0] >= 1. |
273 |
< |
|| ip[1] < 0. || ip[1] >= 1.) |
271 |
> |
if (viewloc(ip, &odev.v, wp) != 1) |
272 |
|
goto dropit; /* behind or outside view */ |
273 |
|
#ifdef DEBUG |
274 |
|
if (odev.v.type == VT_PAR | odev.v.vfore > FTINY) |
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
< |
extern void |
348 |
> |
void |
349 |
|
dev_value( /* add a pixel value to our quadtree */ |
350 |
|
COLR c, |
351 |
|
FVECT d, |
352 |
|
FVECT p |
353 |
|
) |
354 |
|
{ |
355 |
< |
register int li; |
355 |
> |
int li; |
356 |
|
int mapit; |
357 |
|
/* grab a leaf */ |
358 |
|
if (!imm_mode && falleaves >= 0) { /* check for fallen leaves */ |
377 |
|
tmCvColrs(tmGlobal, &qtL.brt[li], qtL.chr[li], (COLR *)c, 1); |
378 |
|
if (putleaf(li, 1)) { |
379 |
|
if (mapit) |
380 |
< |
tmMapPixels(tmGlobal, (BYTE *)(qtL.rgb+li), qtL.brt+li, |
381 |
< |
(BYTE *)(qtL.chr+li), 1); |
380 |
> |
tmMapPixels(tmGlobal, (uby8 *)(qtL.rgb+li), qtL.brt+li, |
381 |
> |
(uby8 *)(qtL.chr+li), 1); |
382 |
|
if (--rayqleft == 0) |
383 |
|
dev_flush(); /* flush output */ |
384 |
|
} |
385 |
|
} |
386 |
|
|
387 |
|
|
388 |
< |
extern void |
388 |
> |
void |
389 |
|
qtReplant(void) /* replant our tree using new view */ |
390 |
|
{ |
391 |
< |
register int i; |
391 |
> |
int i; |
392 |
|
/* anything to replant? */ |
393 |
|
if (qtL.bl == qtL.tl) |
394 |
|
return; |
401 |
|
} |
402 |
|
|
403 |
|
|
404 |
< |
extern int |
404 |
> |
int |
405 |
|
qtMapLeaves( /* map our leaves to RGB */ |
406 |
|
int redo |
407 |
|
) |
432 |
|
if (tmComputeMapping(tmGlobal, 0., 0., 0.) != TM_E_OK) |
433 |
|
return(0); |
434 |
|
} |
435 |
< |
if (tmMapPixels(tmGlobal, (BYTE *)(qtL.rgb+aorg), qtL.brt+aorg, |
436 |
< |
(BYTE *)(qtL.chr+aorg), alen) != TM_E_OK) |
435 |
> |
if (tmMapPixels(tmGlobal, (uby8 *)(qtL.rgb+aorg), qtL.brt+aorg, |
436 |
> |
(uby8 *)(qtL.chr+aorg), alen) != TM_E_OK) |
437 |
|
return(0); |
438 |
|
if (blen > 0) |
439 |
< |
tmMapPixels(tmGlobal, (BYTE *)(qtL.rgb+borg), qtL.brt+borg, |
440 |
< |
(BYTE *)(qtL.chr+borg), blen); |
439 |
> |
tmMapPixels(tmGlobal, (uby8 *)(qtL.rgb+borg), qtL.brt+borg, |
440 |
> |
(uby8 *)(qtL.chr+borg), blen); |
441 |
|
qtL.tml = qtL.tl; |
442 |
|
return(1); |
443 |
|
} |