16 |
|
#endif |
17 |
|
/* maximum allowed angle difference (deg.) */ |
18 |
|
#ifndef MAXANG |
19 |
< |
#define MAXANG 20. |
19 |
> |
#define MAXANG 20 |
20 |
|
#endif |
21 |
+ |
#if MAXANG>0 |
22 |
+ |
#define MAXDIFF2 ( MAXANG*MAXANG * (PI*PI/180./180.)) |
23 |
+ |
#endif |
24 |
|
|
22 |
– |
#define MAXDIFF2 (PI*PI/180./180.* MAXANG*MAXANG ) |
23 |
– |
|
25 |
|
#define abs(i) ((i) < 0 ? -(i) : (i)) |
26 |
|
|
27 |
|
RTREE qtrunk; /* our quadtree trunk */ |
207 |
|
#define FXNEG 01 |
208 |
|
#define FYNEG 02 |
209 |
|
#define FZNEG 04 |
210 |
< |
#define FXACT 010 |
211 |
< |
#define FZACT 020 |
210 |
> |
#define F1X 010 |
211 |
> |
#define F2Z 020 |
212 |
|
#define F1SFT 5 |
213 |
|
#define F2SFT 18 |
214 |
|
#define FMASK 0x1fff |
228 |
|
} else |
229 |
|
cd[i] = dv[i] * DCSCALE; |
230 |
|
if (cd[0] <= cd[1]) { |
231 |
< |
dc |= FXACT | cd[0] << F1SFT; |
231 |
> |
dc |= F1X | cd[0] << F1SFT; |
232 |
|
cm = cd[1]; |
233 |
|
} else { |
234 |
|
dc |= cd[1] << F1SFT; |
235 |
|
cm = cd[0]; |
236 |
|
} |
237 |
|
if (cd[2] <= cm) |
238 |
< |
dc |= FZACT | cd[2] << F2SFT; |
238 |
> |
dc |= F2Z | cd[2] << F2SFT; |
239 |
|
else |
240 |
|
dc |= cm << F2SFT; |
241 |
|
return(dc); |
244 |
|
|
245 |
|
static |
246 |
|
decodedir(dv, dc) /* decode a normalized direction vector */ |
247 |
< |
FVECT dv; /* returned */ |
247 |
> |
register FVECT dv; /* returned */ |
248 |
|
register int4 dc; |
249 |
|
{ |
250 |
|
double d1, d2, der; |
252 |
|
d1 = ((dc>>F1SFT & FMASK)+.5)/DCSCALE; |
253 |
|
d2 = ((dc>>F2SFT & FMASK)+.5)/DCSCALE; |
254 |
|
der = sqrt(1. - d1*d1 - d2*d2); |
255 |
< |
if (dc & FXACT) { |
255 |
> |
if (dc & F1X) { |
256 |
|
dv[0] = d1; |
257 |
< |
if (dc & FZACT) { dv[1] = der; dv[2] = d2; } |
257 |
> |
if (dc & F2Z) { dv[1] = der; dv[2] = d2; } |
258 |
|
else { dv[1] = d2; dv[2] = der; } |
259 |
|
} else { |
260 |
|
dv[1] = d1; |
261 |
< |
if (dc & FZACT) { dv[0] = der; dv[2] = d2; } |
261 |
> |
if (dc & F2Z) { dv[0] = der; dv[2] = d2; } |
262 |
|
else { dv[0] = d2; dv[2] = der; } |
263 |
|
} |
264 |
|
if (dc & FXNEG) dv[0] = -dv[0]; |
347 |
|
viewloc(ip, &odev.v, wp); |
348 |
|
if (ip[2] <= 0. || ip[0] < 0. || ip[0] >= 1. |
349 |
|
|| ip[1] < 0. || ip[1] >= 1.) |
350 |
< |
return(0); /* behind or outside view */ |
350 |
> |
return(-1); /* behind or outside view */ |
351 |
|
#ifdef DEBUG |
352 |
|
if (odev.v.type == VT_PAR | odev.v.vfore > FTINY) |
353 |
|
error(INTERNAL, "bad view assumption in addleaf"); |
355 |
|
for (q = 0; q < 3; q++) |
356 |
|
vd[q] = (wp[q] - odev.v.vp[q])/ip[2]; |
357 |
|
d2 = fdir2diff(qtL.wd[li], vd); |
358 |
+ |
#ifdef MAXDIFF2 |
359 |
|
if (d2 > MAXDIFF2) |
360 |
|
return(0); /* leaf dir. too far off */ |
361 |
+ |
#endif |
362 |
|
x = ip[0] * odev.hres; |
363 |
|
y = ip[1] * odev.vres; |
364 |
|
z = ip[2]; |