52 Set( aPbMin, aPbMax );
70 m_min.x = fminf( aPbMin.x, aPbMax.x );
71 m_min.y = fminf( aPbMin.y, aPbMax.y );
72 m_min.z = fminf( aPbMin.z, aPbMax.z );
74 m_max.x = fmaxf( aPbMin.x, aPbMax.x );
75 m_max.y = fmaxf( aPbMin.y, aPbMax.y );
76 m_max.z = fmaxf( aPbMin.z, aPbMax.z );
90 return !( ( FLT_MAX ==
m_min.x ) || ( FLT_MAX ==
m_min.y ) || ( FLT_MAX ==
m_min.z )
91 || ( -FLT_MAX ==
m_max.x ) || ( -FLT_MAX ==
m_max.y ) || ( -FLT_MAX ==
m_max.z ) );
140 wxASSERT( aAxis < 3 );
141 return (
m_max[aAxis] +
m_min[aAxis] ) * 0.5f;
153 unsigned int result = 0;
157 if( extent.y > extent.x )
160 if( extent.z > extent.y )
170 return std::max( std::max( extent.x, extent.y ), extent.z );
178 return 2.0f * ( extent.x * extent.z + extent.x * extent.y + extent.y * extent.z );
189 m_min = (
m_min - centerV ) * scaleV + centerV;
190 m_max = (
m_max - centerV ) * scaleV + centerV;
227 return ( x && y && z );
235 return ( aPoint.x >=
m_min.x ) && ( aPoint.x <=
m_max.x ) &&
236 ( aPoint.y >=
m_min.y ) && ( aPoint.y <=
m_max.y ) &&
237 ( aPoint.z >=
m_min.z ) && ( aPoint.z <=
m_max.z );
257 return extent.x * extent.y * extent.z;
270 wxASSERT( aOutHitt0 );
271 wxASSERT( aOutHitt1 );
281 if( ( tmin > tymax ) || ( tymin > tmax ) )
284 tmin = ( tymin > tmin ) ? tymin : tmin;
285 tmax = ( tymax < tmax ) ? tymax : tmax;
291 if( ( tmin > tzmax ) || ( tzmin > tmax ) )
294 tmin = (tzmin > tmin)? tzmin : tmin;
295 tmin = ( tmin < 0.0f)? 0.0f : tmin;
297 tmax = (tzmax < tmax)? tzmax : tmax;
Defines math related functions.
float NextFloatDown(float v)
float NextFloatUp(float v)
Bounding Box class definition.
Manage a bounding box defined by two SFVEC3F min max points.
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
BBOX_3D()
Create with default values a bounding box (not initialized)
const SFVEC3F GetExtent() const
bool Intersect(const RAY &aRay, float *t) const
void Union(const SFVEC3F &aPoint)
Recalculate the bounding box adding a point.
SFVEC3F m_min
(12) point of the lower position of the bounding box
SFVEC3F GetCenter() const
Return the center point of the bounding box.
const SFVEC3F & Min() const
Return the minimum vertex pointer.
SFVEC3F Offset(const SFVEC3F &p) const
SFVEC3F m_max
(12) point of the higher position of the bounding box
const SFVEC3F & Max() const
Return the maximum vertex pointer.
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
void Reset()
Reset the bounding box to zero and de-initialize it.
void ApplyTransformation(glm::mat4 aTransformMatrix)
Apply a transformation matrix to the box points.
unsigned int MaxDimension() const
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
float SurfaceArea() const
float Volume() const
Calculate the volume of a bounding box.
float GetMaxDimension() const
void ScaleNextDown()
Scale a bounding box to the next float representation making it smaller.
bool IsInitialized() const
Check if this bounding box is already initialized.
bool Inside(const SFVEC3F &aPoint) const
Check if a point is inside this bounding box.
void Scale(float aScale)
Scales a bounding box by its center.
unsigned int m_dirIsNeg[3]