76 |
|
d2 = DOT(v1,v1); |
77 |
|
|
78 |
|
if (d2 > (rad+d1+FTINY)*(rad+d1+FTINY)) /* quick test */ |
79 |
< |
return(0); /* cube outside */ |
79 |
> |
return(O_MISS); /* cube outside */ |
80 |
|
|
81 |
|
/* check sphere interior */ |
82 |
|
if (d1 < rad) { |
83 |
|
if (d2 < (rad-d1-FTINY)*(rad-d1-FTINY)) |
84 |
< |
return(0); /* cube inside sphere */ |
84 |
> |
return(O_MISS); /* cube inside sphere */ |
85 |
|
if (d2 < (rad+FTINY)*(rad+FTINY)) |
86 |
< |
return(1); /* cube center inside */ |
86 |
> |
return(O_HIT); /* cube center inside */ |
87 |
|
} |
88 |
|
/* find closest distance */ |
89 |
|
for (i = 0; i < 3; i++) |
95 |
|
v1[i] = 0; |
96 |
|
/* final intersection check */ |
97 |
|
if (DOT(v1,v1) <= (rad+FTINY)*(rad+FTINY)) |
98 |
< |
return(1); |
98 |
> |
return(O_HIT); |
99 |
|
else |
100 |
< |
return(0); |
100 |
> |
return(O_MISS); |
101 |
|
} |