11 |
|
#include "octree.h" |
12 |
|
#include "object.h" |
13 |
|
#include "cone.h" |
14 |
+ |
#include "plocate.h" |
15 |
|
|
16 |
|
#define ROOT3 1.732050808 |
17 |
|
|
30 |
|
|
31 |
|
extern double mincusize; /* minimum cube size */ |
32 |
|
|
33 |
< |
static double findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p); |
33 |
> |
static int findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p); |
34 |
|
|
35 |
|
|
36 |
|
|
58 |
|
p[i] = cu->cuorg[i] + r; |
59 |
|
r *= ROOT3; /* bounding radius for cube */ |
60 |
|
|
61 |
< |
if (findcseg(ep0, ep1, co, p) > 0.0) { |
61 |
> |
if (findcseg(ep0, ep1, co, p)) { |
62 |
|
/* check min. distance to cone */ |
63 |
|
if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY)) |
64 |
|
return(O_MISS); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
< |
static double |
96 |
> |
static int |
97 |
|
findcseg( /* find line segment from cone closest to p */ |
98 |
|
FVECT ep0, |
99 |
|
FVECT ep1, |
105 |
|
FVECT v; |
106 |
|
register int i; |
107 |
|
/* find direction from axis to point */ |
108 |
< |
for (i = 0; i < 3; i++) |
108 |
< |
v[i] = p[i] - CO_P0(co)[i]; |
108 |
> |
VSUB(v, p, CO_P0(co)); |
109 |
|
d = DOT(v, co->ad); |
110 |
|
for (i = 0; i < 3; i++) |
111 |
< |
v[i] = v[i] - d*co->ad[i]; |
112 |
< |
d = normalize(v); |
113 |
< |
if (d > 0.0) /* find endpoints of segment */ |
114 |
< |
for (i = 0; i < 3; i++) { |
115 |
< |
ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i]; |
116 |
< |
ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i]; |
117 |
< |
} |
118 |
< |
return(d); /* return distance from axis */ |
111 |
> |
v[i] -= d*co->ad[i]; |
112 |
> |
if (normalize(v) == 0.0) |
113 |
> |
return(0); |
114 |
> |
/* find endpoints of segment */ |
115 |
> |
for (i = 0; i < 3; i++) { |
116 |
> |
ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i]; |
117 |
> |
ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i]; |
118 |
> |
} |
119 |
> |
return(1); /* return distance from axis */ |
120 |
|
} |