29 |
|
|
30 |
|
extern double mincusize; /* minimum cube size */ |
31 |
|
|
32 |
< |
static double findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p); |
32 |
> |
static int findcseg(FVECT ep0, FVECT ep1, CONE *co, FVECT p); |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
< |
/* XXX o_cone() is extern, but not declared in any header file */ |
37 |
< |
int |
38 |
< |
o_cone( /* determine if cone intersects cube */ |
36 |
> |
extern int |
37 |
> |
o_cone( /* determine if cone intersects cube */ |
38 |
|
OBJREC *o, |
39 |
|
register CUBE *cu |
40 |
|
) |
57 |
|
p[i] = cu->cuorg[i] + r; |
58 |
|
r *= ROOT3; /* bounding radius for cube */ |
59 |
|
|
60 |
< |
if (findcseg(ep0, ep1, co, p) > 0.0) { |
60 |
> |
if (findcseg(ep0, ep1, co, p)) { |
61 |
|
/* check min. distance to cone */ |
62 |
|
if (dist2lseg(p, ep0, ep1) > (r+FTINY)*(r+FTINY)) |
63 |
|
return(O_MISS); |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
< |
static double |
95 |
> |
static int |
96 |
|
findcseg( /* find line segment from cone closest to p */ |
97 |
|
FVECT ep0, |
98 |
|
FVECT ep1, |
104 |
|
FVECT v; |
105 |
|
register int i; |
106 |
|
/* find direction from axis to point */ |
107 |
< |
for (i = 0; i < 3; i++) |
109 |
< |
v[i] = p[i] - CO_P0(co)[i]; |
107 |
> |
VSUB(v, p, CO_P0(co)); |
108 |
|
d = DOT(v, co->ad); |
109 |
|
for (i = 0; i < 3; i++) |
110 |
< |
v[i] = v[i] - d*co->ad[i]; |
111 |
< |
d = normalize(v); |
112 |
< |
if (d > 0.0) /* find endpoints of segment */ |
113 |
< |
for (i = 0; i < 3; i++) { |
114 |
< |
ep0[i] = CO_R0(co)*v[i] + CO_P0(co)[i]; |
115 |
< |
ep1[i] = CO_R1(co)*v[i] + CO_P1(co)[i]; |
116 |
< |
} |
117 |
< |
return(d); /* return distance from axis */ |
110 |
> |
v[i] -= d*co->ad[i]; |
111 |
> |
if (normalize(v) == 0.0) |
112 |
> |
return(0); |
113 |
> |
/* 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(1); /* return distance from axis */ |
119 |
|
} |