29 #include "../precompiled.h"
44 for ( i = 0; i < 3; i++ ) {
66 for ( i = 0; i < 3; i++ ) {
87 center = (
b[0] +
b[1] ) * 0.5
f;
94 if ( d1 - d2 > 0.0
f ) {
97 if ( d1 + d2 < 0.0
f ) {
112 center = (
b[0] +
b[1] ) * 0.5
f;
119 if ( d1 - d2 > epsilon ) {
122 if ( d1 + d2 < -epsilon ) {
138 idVec3 extents =
b[1] - center;
140 idVec3 lineCenter = start + lineDir;
141 idVec3 dir = lineCenter - center;
160 if (
idMath::Fabs( cross[0] ) > extents[1] * ld[2] + extents[2] * ld[1] ) {
164 if (
idMath::Fabs( cross[1] ) > extents[0] * ld[2] + extents[2] * ld[0] ) {
168 if (
idMath::Fabs( cross[2] ) > extents[0] * ld[1] + extents[1] * ld[0] ) {
185 int i, ax0, ax1, ax2, side, inside;
191 for ( i = 0; i < 3; i++ ) {
192 if ( start[i] <
b[0][i] ) {
195 else if ( start[i] >
b[1][i] ) {
202 if ( dir[i] == 0.0f ) {
205 f = ( start[
i] -
b[side][
i] );
207 scale = - ( f / dir[
i] );
215 return ( inside == 3 );
220 hit[ax1] = start[ax1] + scale * dir[ax1];
221 hit[ax2] = start[ax2] + scale * dir[ax2];
223 return ( hit[ax1] >=
b[0][ax1] && hit[ax1] <=
b[1][ax1] &&
224 hit[ax2] >=
b[0][ax2] && hit[ax2] <=
b[1][ax2] );
234 idVec3 center, extents, rotatedExtents;
236 center = (bounds[0] + bounds[1]) * 0.5
f;
237 extents = bounds[1] - center;
239 for ( i = 0; i < 3; i++ ) {
240 rotatedExtents[
i] =
idMath::Fabs( extents[0] * axis[0][i] ) +
245 center = origin + center * axis;
246 b[0] = center - rotatedExtents;
247 b[1] = center + rotatedExtents;
271 for ( i = 0; i < 3; i++ ) {
272 if ( translation[i] < 0.0
f ) {
273 b[0][
i] = point[
i] + translation[
i];
278 b[1][
i] = point[
i] + translation[
i];
297 b[0] = bounds[0] + origin;
298 b[1] = bounds[1] + origin;
300 for ( i = 0; i < 3; i++ ) {
301 if ( translation[i] < 0.0
f ) {
302 b[0][
i] += translation[
i];
305 b[1][
i] += translation[
i];
324 end = start * rotation;
325 axis = rotation.GetVec();
326 origin = rotation.GetOrigin() + axis * ( axis * ( start - rotation.GetOrigin() ) );
327 radiusSqr = ( start - origin ).LengthSqr();
328 v1 = ( start - origin ).Cross( axis );
329 v2 = ( end - origin ).Cross( axis );
331 for ( i = 0; i < 3; i++ ) {
333 if ( ( v1[i] > 0.0
f && v2[i] < 0.0
f ) || ( v1[
i] < 0.0f && v2[
i] > 0.0f ) ) {
334 if ( ( 0.5
f * (start[i] + end[i]) - origin[
i] ) > 0.0
f ) {
335 bounds[0][
i] =
Min( start[i], end[i] );
336 bounds[1][
i] = origin[
i] +
idMath::Sqrt( radiusSqr * ( 1.0
f - axis[i] * axis[i] ) );
339 bounds[0][
i] = origin[
i] -
idMath::Sqrt( radiusSqr * ( 1.0
f - axis[i] * axis[i] ) );
340 bounds[1][
i] =
Max( start[i], end[i] );
343 else if ( start[i] > end[i] ) {
344 bounds[0][
i] = end[
i];
345 bounds[1][
i] = start[
i];
348 bounds[0][
i] = start[
i];
349 bounds[1][
i] = end[
i];
371 radius = ( point - rotation.
GetOrigin() ).Length();
374 b[0].Set( -radius, -radius, -radius );
375 b[1].Set( radius, radius, radius );
395 for ( i = 1; i < 8; i++ ) {
396 point[0] = bounds[(i^(i>>1))&1][0];
397 point[1] = bounds[(i>>1)&1][1];
398 point[2] = bounds[(i>>2)&1][2];
404 point = (bounds[1] - bounds[0]) * 0.5
f;
405 radius = (bounds[1] - point).Length() + (point - rotation.
GetOrigin()).Length();
408 b[0].Set( -radius, -radius, -radius );
409 b[1].Set( radius, radius, radius );
419 for (
int i = 0;
i < 8;
i++ ) {
420 points[
i][0] =
b[(
i^(
i>>1))&1][0];
421 points[
i][1] =
b[(
i>>1)&1][1];
422 points[
i][2] =
b[(
i>>2)&1][2];
GLsizei const GLfloat * points
void cross(float a[], float b[], float c[])
const idVec3 & Normal(void) const
void FromPointRotation(const idVec3 &point, const idRotation &rotation)
bool RayIntersection(const idVec3 &start, const idVec3 &dir, float &scale) const
ID_INLINE T Max(T x, T y)
GLenum GLenum GLenum GLenum GLenum scale
float Distance(const idVec3 &v) const
idBounds bounds_zero(vec3_zero, vec3_zero)
static float Sqrt(float x)
float GetRadius(void) const
idBounds BoundsForPointRotation(const idVec3 &start, const idRotation &rotation)
bool IsRotated(void) const
void FromBoundsRotation(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idRotation &rotation)
void FromBoundsTranslation(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idVec3 &translation)
GLfloat GLfloat GLfloat v2
float GetAngle(void) const
virtual void VPCALL MinMax(float &min, float &max, const float *src, const int count)=0
void FromPointTranslation(const idVec3 &point, const idVec3 &translation)
static float Fabs(float f)
float PlaneDistance(const idPlane &plane) const
void FromTransformedBounds(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis)
bool LineIntersection(const idVec3 &start, const idVec3 &end) const
void ToPoints(idVec3 points[8]) const
const idVec3 & GetOrigin(void) const
int PlaneSide(const idPlane &plane, const float epsilon=ON_EPSILON) const
void FromPoints(const idVec3 *points, const int numPoints)
ID_INLINE T Min(T x, T y)
idSIMDProcessor * SIMDProcessor