KiCad PCB EDA Suite
CBBOX Struct Reference

Class CBBOX manages a bounding box defined by two SFVEC3F min max points. More...

#include <cbbox.h>

Public Member Functions

 CBBOX ()
 Constructor CBBOX Create with default values a bounding box (not inizialized) More...
 
 CBBOX (const SFVEC3F &aPbInit)
 Constructor CBBOX Initialize a bounding box with a given point. More...
 
 CBBOX (const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
 Constructor CBBOX Initialize a bounding box with a minimon and a maximun point. More...
 
 ~CBBOX ()
 
void Set (const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
 Function Set Set bounding box with new parameters. More...
 
void Set (const CBBOX &aBBox)
 
void Set (const SFVEC3F &aPoint)
 Set. More...
 
void Union (const SFVEC3F &aPoint)
 Function Union recalculate the bounding box adding a point. More...
 
void Union (const CBBOX &aBBox)
 Function Union recalculate the bounding box adding other bounding box. More...
 
void Scale (float aScale)
 Function Scale scales a bounding box by its center. More...
 
void ScaleNextUp ()
 Function ScaleNextUp scales a bounding box to the next float representation making it larger. More...
 
void ScaleNextDown ()
 Function ScaleNextDown scales a bounding box to the next float representation making it smaller. More...
 
bool Intersects (const CBBOX &aBBox) const
 Function Intersects test if a bounding box intersects this box. More...
 
bool Inside (const SFVEC3F &aPoint) const
 Function Inside check is a point is inside this bounding box. More...
 
void ApplyTransformation (glm::mat4 aTransformMatrix)
 Function ApplyTransformation apply a transformation matrix to the box points. More...
 
void ApplyTransformationAA (glm::mat4 aTransformMatrix)
 Function ApplyTransformationAA apply a transformation matrix to the box points and recalculate it to fit an axis aligned bounding box. More...
 
float Volume () const
 Function Volume calculate the volume of a bounding box. More...
 
void debug () const
 Function debug output to stdout. More...
 
bool IsInitialized () const
 Function IsInitialized check if this bounding box is already initialized. More...
 
void Reset ()
 Function Reset reset the bounding box to zero and de-initialized it. More...
 
SFVEC3F GetCenter () const
 Function GetCenter return the center point of the bounding box. More...
 
float GetCenter (unsigned int aAxis) const
 Function GetCenter return the center point of the bounding box for one Axis (0, 1 or 2) More...
 
SFVEC3F Offset (const SFVEC3F &p) const
 Function Offset. More...
 
const SFVEC3F GetExtent () const
 Function GetExtent. More...
 
const SFVEC3FMin () const
 Function Min return the minimun vertex pointer. More...
 
const SFVEC3FMax () const
 Function Max return the maximum vertex pointer. More...
 
unsigned int MaxDimension () const
 Function MaxDimension. More...
 
float GetMaxDimension () const
 GetMaxDimension. More...
 
float SurfaceArea () const
 Function SurfaceArea. More...
 
bool Intersect (const RAY &aRay, float *t) const
 Function Intersect. More...
 
bool Intersect (const RAY &aRay) const
 
bool Intersect (const RAY &aRay, float *aOutHitt0, float *aOutHitt1) const
 Function Intersect - Useful for get the enter and exit position If the ray starts inside the bbox, it will return aOutHitt0 = 0.0. More...
 

Private Attributes

SFVEC3F m_min
 (12) point of the lower position of the bounding box More...
 
SFVEC3F m_max
 (12) point of the higher position of the bounding box More...
 

Detailed Description

Class CBBOX manages a bounding box defined by two SFVEC3F min max points.

Definition at line 40 of file cbbox.h.

Constructor & Destructor Documentation

CBBOX::CBBOX ( )

Constructor CBBOX Create with default values a bounding box (not inizialized)

Definition at line 36 of file cbbox.cpp.

References Reset().

Referenced by ApplyTransformationAA().

37 {
38  Reset();
39 }
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:98
CBBOX::CBBOX ( const SFVEC3F aPbInit)
explicit

Constructor CBBOX Initialize a bounding box with a given point.

Parameters
aPbInita point for the bounding box initialization

Definition at line 42 of file cbbox.cpp.

References m_max, and m_min.

43 {
44  m_min = aPbInit;
45  m_max = aPbInit;
46 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
CBBOX::CBBOX ( const SFVEC3F aPbMin,
const SFVEC3F aPbMax 
)

Constructor CBBOX Initialize a bounding box with a minimon and a maximun point.

Parameters
aPbMinthe minimun point to initialize the bounding box
aPbMaxthe maximun point to initialize the bounding box

Definition at line 49 of file cbbox.cpp.

References Set().

50 {
51  Set( aPbMin, aPbMax );
52 }
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox.cpp:67
CBBOX::~CBBOX ( )

Definition at line 55 of file cbbox.cpp.

56 {
57 }

Member Function Documentation

void CBBOX::ApplyTransformation ( glm::mat4  aTransformMatrix)

Function ApplyTransformation apply a transformation matrix to the box points.

Parameters
aTransformMatrixmatrix to apply to the points of the bounding box

Definition at line 351 of file cbbox.cpp.

References IsInitialized(), m_max, m_min, Reset(), and Union().

352 {
353  wxASSERT( IsInitialized() );
354 
355  const SFVEC3F v1 = SFVEC3F( aTransformMatrix *
356  glm::vec4( m_min.x, m_min.y, m_min.z, 1.0f ) );
357 
358  const SFVEC3F v2 = SFVEC3F( aTransformMatrix *
359  glm::vec4( m_max.x, m_max.y, m_max.z, 1.0f ) );
360 
361  Reset();
362  Union( v1 );
363  Union( v2 );
364 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
void Union(const SFVEC3F &aPoint)
Function Union recalculate the bounding box adding a point.
Definition: cbbox.cpp:105
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:98
void CBBOX::ApplyTransformationAA ( glm::mat4  aTransformMatrix)

Function ApplyTransformationAA apply a transformation matrix to the box points and recalculate it to fit an axis aligned bounding box.

Parameters
aTransformMatrixmatrix to apply to the points of the bounding box

Definition at line 367 of file cbbox.cpp.

References CBBOX(), IsInitialized(), m_max, m_min, and Union().

368 {
369  wxASSERT( IsInitialized() );
370 
371  // apply the transformation matrix for each of vertices of the bounding box
372  // and make a union with all vertices
373  CBBOX tmpBBox = CBBOX(
374  SFVEC3F( aTransformMatrix *
375  glm::vec4( m_min.x, m_min.y, m_min.z, 1.0f ) ) );
376  tmpBBox.Union( SFVEC3F( aTransformMatrix *
377  glm::vec4( m_max.x, m_min.y, m_min.z, 1.0f ) ) );
378  tmpBBox.Union( SFVEC3F( aTransformMatrix *
379  glm::vec4( m_min.x, m_max.y, m_min.z, 1.0f ) ) );
380  tmpBBox.Union( SFVEC3F( aTransformMatrix *
381  glm::vec4( m_min.x, m_min.y, m_max.z, 1.0f ) ) );
382  tmpBBox.Union( SFVEC3F( aTransformMatrix *
383  glm::vec4( m_min.x, m_max.y, m_max.z, 1.0f ) ) );
384  tmpBBox.Union( SFVEC3F( aTransformMatrix *
385  glm::vec4( m_max.x, m_max.y, m_min.z, 1.0f ) ) );
386  tmpBBox.Union( SFVEC3F( aTransformMatrix *
387  glm::vec4( m_max.x, m_min.y, m_max.z, 1.0f ) ) );
388  tmpBBox.Union( SFVEC3F( aTransformMatrix *
389  glm::vec4( m_max.x, m_max.y, m_max.z, 1.0f ) ) );
390 
391  m_min = tmpBBox.m_min;
392  m_max = tmpBBox.m_max;
393 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
CBBOX()
Constructor CBBOX Create with default values a bounding box (not inizialized)
Definition: cbbox.cpp:36
void Union(const SFVEC3F &aPoint)
Function Union recalculate the bounding box adding a point.
Definition: cbbox.cpp:105
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
void CBBOX::debug ( ) const

Function debug output to stdout.

Definition at line 396 of file cbbox.cpp.

References m_max, and m_min.

397 {
398  printf( "min(%f, %f, %f) - max(%f, %f, %f)\n", m_min.x, m_min.y, m_min.z,
399  m_max.x, m_max.y, m_max.z );
400 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
SFVEC3F CBBOX::GetCenter ( ) const

Function GetCenter return the center point of the bounding box.

Returns
SFVEC3F - the position of the center of this bounding box

Definition at line 135 of file cbbox.cpp.

References m_max, and m_min.

Referenced by CDUMMYBLOCK::CDUMMYBLOCK(), CROUNDSEG::CROUNDSEG(), CVCYLINDER::CVCYLINDER(), CXYPLANE::CXYPLANE(), C3D_MODEL_VIEWER::OnPaint(), HLBVH_SAH_Evaluator::operator()(), CTRIANGLE::pre_calc_const(), CBVH_PBRT::recursiveBuild(), C3D_RENDER_RAYTRACING::reload(), and Scale().

136 {
137  return (m_max + m_min) * 0.5f;
138 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float CBBOX::GetCenter ( unsigned int  aAxis) const

Function GetCenter return the center point of the bounding box for one Axis (0, 1 or 2)

Returns
float - the position of the center of this bounding box for the axis

Definition at line 141 of file cbbox.cpp.

References m_max, and m_min.

142 {
143  wxASSERT( aAxis < 3 );
144  return (m_max[aAxis] + m_min[aAxis]) * 0.5f;
145 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
const SFVEC3F CBBOX::GetExtent ( ) const

Function GetExtent.

Returns
SFVEC3F - max-min

Definition at line 148 of file cbbox.cpp.

References m_max, and m_min.

Referenced by CXYPLANE::CXYPLANE(), GetMaxDimension(), MaxDimension(), SurfaceArea(), and Volume().

149 {
150  return m_max - m_min;
151 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float CBBOX::GetMaxDimension ( ) const

GetMaxDimension.

Returns
the max dimension

Definition at line 169 of file cbbox.cpp.

References GetExtent().

Referenced by C3D_MODEL_VIEWER::OnPaint().

170 {
171  unsigned int max_dimensions_idx = 0;
172 
173  SFVEC3F extent = GetExtent();
174 
175  if( extent.y > extent.x )
176  max_dimensions_idx = 1;
177  if( extent.z > extent.y )
178  max_dimensions_idx = 2;
179 
180  return extent[max_dimensions_idx];
181 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const SFVEC3F GetExtent() const
Function GetExtent.
Definition: cbbox.cpp:148
bool CBBOX::Inside ( const SFVEC3F aPoint) const

Function Inside check is a point is inside this bounding box.

Parameters
aPointpoint to test

Definition at line 243 of file cbbox.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by CLAYERITEM::Intersect().

244 {
245  wxASSERT( IsInitialized() );
246 
247  return (( aPoint.x >= m_min.x ) && ( aPoint.x <= m_max.x ) &&
248  ( aPoint.y >= m_min.y ) && ( aPoint.y <= m_max.y ) &&
249  ( aPoint.z >= m_min.z ) && ( aPoint.z <= m_max.z ));
250 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
bool CBBOX::Intersect ( const RAY aRay,
float *  t 
) const

Function Intersect.

Parameters
aRay= ray to intersect the box
t= distance point of the ray of the intersection (if true)
Returns
true if the ray hits the box

Definition at line 46 of file cbbox_ray.cpp.

References RAY::c_xy, RAY::c_xz, RAY::c_yx, RAY::c_yz, RAY::c_zx, RAY::c_zy, RAY::ibyj, RAY::ibyk, RAY::jbyi, RAY::jbyk, RAY::kbyi, RAY::kbyj, RAY::m_Classification, RAY::m_InvDir, m_max, m_min, RAY::m_Origin, MMM, MMO, MMP, MOM, MOO, MOP, MPM, MPO, MPP, OMM, OMO, OMP, OOM, OOP, OPM, OPO, OPP, PMM, PMO, PMP, POM, POO, POP, PPM, PPO, and PPP.

Referenced by getFirstHit(), getLastHit(), CDUMMYBLOCK::Intersect(), CLAYERITEM::Intersect(), CCONTAINER::Intersect(), CBVH_PBRT::Intersect(), CDUMMYBLOCK::IntersectP(), CLAYERITEM::IntersectP(), CBVH_PBRT::IntersectP(), and EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position().

47 {
48  switch( aRay.m_Classification )
49  {
50  case MMM:
51  {
52  if( ( aRay.m_Origin.x < m_min.x )
53  || ( aRay.m_Origin.y < m_min.y )
54  || ( aRay.m_Origin.z < m_min.z )
55  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
56  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
57  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
58  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0)
59  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
60  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
61  )
62  return false;
63 
64  // compute the intersection distance
65 
66  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
67 
68  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
69 
70  if( t1 > *t )
71  *t = t1;
72 
73  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
74 
75  if( t2 > *t )
76  *t = t2;
77 
78  return true;
79  }
80 
81 
82  case MMP:
83  {
84  if( ( aRay.m_Origin.x < m_min.x )
85  || ( aRay.m_Origin.y < m_min.y )
86  || ( aRay.m_Origin.z > m_max.z )
87  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
88  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
89  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
90  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
91  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
92  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
93  )
94  return false;
95 
96  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
97 
98  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
99 
100  if( t1 > *t )
101  *t = t1;
102 
103  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
104 
105  if( t2 > *t )
106  *t = t2;
107 
108  return true;
109  }
110 
111  case MPM:
112  {
113  if( ( aRay.m_Origin.x < m_min.x )
114  || ( aRay.m_Origin.y > m_max.y )
115  || ( aRay.m_Origin.z < m_min.z )
116  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
117  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
118  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
119  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
120  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
121  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
122  )
123  return false;
124 
125  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
126 
127  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
128 
129  if( t1 > *t )
130  *t = t1;
131 
132  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
133 
134  if( t2 > *t )
135  *t = t2;
136 
137  return true;
138  }
139 
140  case MPP:
141  {
142  if( ( aRay.m_Origin.x < m_min.x )
143  || ( aRay.m_Origin.y > m_max.y )
144  || ( aRay.m_Origin.z > m_max.z )
145  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
146  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
147  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
148  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
149  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
150  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
151  )
152  return false;
153 
154  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
155 
156  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
157 
158  if( t1 > *t )
159  *t = t1;
160 
161  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
162 
163  if( t2 > *t )
164  *t = t2;
165 
166  return true;
167  }
168 
169  case PMM:
170  {
171  if( ( aRay.m_Origin.x > m_max.x )
172  || ( aRay.m_Origin.y < m_min.y )
173  || ( aRay.m_Origin.z < m_min.z )
174  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
175  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
176  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
177  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0)
178  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
179  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
180  )
181  return false;
182 
183  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
184 
185  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
186 
187  if( t1 > *t )
188  *t = t1;
189 
190  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
191 
192  if( t2 > *t )
193  *t = t2;
194 
195  return true;
196  }
197 
198 
199  case PMP:
200  {
201  if( ( aRay.m_Origin.x > m_max.x )
202  || ( aRay.m_Origin.y < m_min.y )
203  || ( aRay.m_Origin.z > m_max.z )
204  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
205  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
206  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
207  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
208  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
209  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
210  )
211  return false;
212 
213  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
214 
215  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
216 
217  if( t1 > *t )
218  *t = t1;
219 
220  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
221 
222  if( t2 > *t )
223  *t = t2;
224 
225  return true;
226  }
227 
228  case PPM:
229  {
230  if( ( aRay.m_Origin.x > m_max.x )
231  || ( aRay.m_Origin.y > m_max.y )
232  || ( aRay.m_Origin.z < m_min.z )
233  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
234  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
235  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
236  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
237  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
238  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
239  )
240  return false;
241 
242  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
243 
244  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
245 
246  if( t1 > *t )
247  *t = t1;
248 
249  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
250 
251  if( t2 > *t )
252  *t = t2;
253 
254  return true;
255  }
256 
257  case PPP:
258  {
259  if( ( aRay.m_Origin.x > m_max.x )
260  || ( aRay.m_Origin.y > m_max.y )
261  || ( aRay.m_Origin.z > m_max.z )
262  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
263  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
264  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
265  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
266  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
267  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
268  )
269  return false;
270 
271  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
272 
273  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
274 
275  if( t1 > *t )
276  *t = t1;
277 
278  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
279 
280  if( t2 > *t )
281  *t = t2;
282 
283  return true;
284  }
285 
286  case OMM:
287  {
288  if( ( aRay.m_Origin.x < m_min.x )
289  || ( aRay.m_Origin.x > m_max.x )
290  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.z < m_min.z)
291  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
292  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0)
293  )
294  return false;
295 
296  *t = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
297 
298  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
299 
300  if( t2 > *t )
301  *t = t2;
302 
303  return true;
304  }
305 
306  case OMP:
307  {
308  if( ( aRay.m_Origin.x < m_min.x )
309  || ( aRay.m_Origin.x > m_max.x )
310  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.z > m_max.z)
311  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
312  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
313  )
314  return false;
315 
316  *t = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
317 
318  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
319 
320  if( t2 > *t )
321  *t = t2;
322 
323  return true;
324  }
325 
326  case OPM:
327  {
328  if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
329  || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z < m_min.z)
330  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
331  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
332  )
333  return false;
334 
335  *t = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
336 
337  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
338 
339  if( t2 > *t )
340  *t = t2;
341 
342  return true;
343  }
344 
345  case OPP:
346  {
347  if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
348  || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z > m_max.z)
349  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
350  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
351  )
352  return false;
353 
354  *t = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
355 
356  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
357 
358  if( t2 > *t )
359  *t = t2;
360 
361  return true;
362  }
363 
364 
365  case MOM:
366  {
367  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
368  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z < m_min.z)
369  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
370  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
371  )
372  return false;
373 
374  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
375 
376  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
377 
378  if( t2 > *t )
379  *t = t2;
380 
381  return true;
382  }
383 
384 
385  case MOP:
386  {
387  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
388  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z > m_max.z)
389  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
390  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
391  )
392  return false;
393 
394  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
395 
396  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
397 
398  if( t2 > *t )
399  *t = t2;
400 
401  return true;
402  }
403 
404  case POM:
405  {
406  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
407  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z < m_min.z)
408  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
409  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
410  )
411  return false;
412 
413  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
414 
415  float t2 = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
416 
417  if( t2 > *t )
418  *t = t2;
419 
420  return true;
421  }
422 
423 
424  case POP:
425  {
426  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
427  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z > m_max.z)
428  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
429  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
430  )
431  return false;
432 
433  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
434 
435  float t2 = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
436 
437  if( t2 > *t )
438  *t = t2;
439 
440  return true;
441  }
442 
443  case MMO:
444  {
445  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
446  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y)
447  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
448  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
449  )
450  return false;
451 
452  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
453 
454  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
455 
456  if( t1 > *t )
457  *t = t1;
458 
459  return true;
460  }
461 
462  case MPO:
463  {
464  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
465  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y > m_max.y)
466  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
467  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
468  )
469  return false;
470 
471  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
472 
473  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
474 
475  if( t1 > *t )
476  *t = t1;
477 
478  return true;
479  }
480 
481 
482  case PMO:
483  {
484  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
485  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y)
486  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
487  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
488  )
489  return false;
490 
491  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
492 
493  float t1 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
494 
495  if( t1 > *t )
496  *t = t1;
497 
498  return true;
499  }
500 
501  case PPO:
502  {
503  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
504  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y)
505  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
506  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
507  )
508  return false;
509 
510  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
511 
512  float t1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
513 
514  if( t1 > *t )
515  *t = t1;
516 
517  return true;
518  }
519 
520 
521  case MOO:
522  {
523  if( ( aRay.m_Origin.x < m_min.x)
524  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
525  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
526  )
527  return false;
528 
529  *t = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
530 
531  return true;
532  }
533 
534  case POO:
535  {
536  if( ( aRay.m_Origin.x > m_max.x)
537  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
538  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
539  )
540  return false;
541 
542  *t = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
543 
544  return true;
545  }
546 
547  case OMO:
548  {
549  if( ( aRay.m_Origin.y < m_min.y)
550  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
551  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
552  )
553  return false;
554 
555  *t = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
556 
557  return true;
558  }
559 
560  case OPO:
561  {
562  if( ( aRay.m_Origin.y > m_max.y)
563  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
564  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
565  )
566  return false;
567 
568  *t = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
569 
570  return true;
571  }
572 
573 
574  case OOM:
575  {
576  if( ( aRay.m_Origin.z < m_min.z)
577  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
578  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
579  )
580  return false;
581 
582  *t = (m_max.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
583 
584  return true;
585  }
586 
587  case OOP:
588  {
589  if( ( aRay.m_Origin.z > m_max.z)
590  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
591  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
592  )
593  return false;
594 
595  *t = (m_min.z - aRay.m_Origin.z) * aRay.m_InvDir.z;
596 
597  return true;
598  }
599  }
600 
601  return false;
602 }
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:38
float c_xy
Definition: ray.h:54
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
Definition: ray.h:39
float c_zy
Definition: ray.h:54
Definition: ray.h:39
float jbyk
Definition: ray.h:53
Definition: ray.h:39
float kbyi
Definition: ray.h:53
float c_yx
Definition: ray.h:54
Definition: ray.h:38
Definition: ray.h:38
SFVEC3F m_InvDir
Definition: ray.h:51
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:39
float kbyj
Definition: ray.h:53
Definition: ray.h:38
Definition: ray.h:39
RAY_CLASSIFICATION m_Classification
Definition: ray.h:49
Definition: ray.h:38
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
Definition: ray.h:39
Definition: ray.h:39
float ibyj
Definition: ray.h:53
float jbyi
Definition: ray.h:53
float c_yz
Definition: ray.h:54
SFVEC3F m_Origin
Definition: ray.h:45
Definition: ray.h:38
Definition: ray.h:38
float c_zx
Definition: ray.h:54
Definition: ray.h:38
Definition: ray.h:38
float c_xz
Definition: ray.h:54
Definition: ray.h:39
Definition: ray.h:38
float ibyk
Definition: ray.h:53
bool CBBOX::Intersect ( const RAY aRay) const

Definition at line 605 of file cbbox_ray.cpp.

References RAY::c_xy, RAY::c_xz, RAY::c_yx, RAY::c_yz, RAY::c_zx, RAY::c_zy, RAY::ibyj, RAY::ibyk, RAY::jbyi, RAY::jbyk, RAY::kbyi, RAY::kbyj, RAY::m_Classification, m_max, m_min, RAY::m_Origin, MMM, MMO, MMP, MOM, MOO, MOP, MPM, MPO, MPP, OMM, OMO, OMP, OOM, OOP, OPM, OPO, OPP, PMM, PMO, PMP, POM, POO, POP, PPM, PPO, and PPP.

606 {
607  switch( aRay.m_Classification )
608  {
609  case MMM:
610  {
611  if( ( aRay.m_Origin.x < m_min.x )
612  || ( aRay.m_Origin.y < m_min.y )
613  || ( aRay.m_Origin.z < m_min.z )
614  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
615  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
616  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
617  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0)
618  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
619  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
620  )
621  return false;
622 
623  return true;
624  }
625 
626 
627  case MMP:
628  {
629  if( ( aRay.m_Origin.x < m_min.x )
630  || ( aRay.m_Origin.y < m_min.y )
631  || ( aRay.m_Origin.z > m_max.z )
632  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
633  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
634  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
635  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
636  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
637  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
638  )
639  return false;
640 
641  return true;
642  }
643 
644  case MPM:
645  {
646  if( ( aRay.m_Origin.x < m_min.x )
647  || ( aRay.m_Origin.y > m_max.y )
648  || ( aRay.m_Origin.z < m_min.z )
649  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
650  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
651  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
652  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
653  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
654  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
655  )
656  return false;
657 
658  return true;
659  }
660 
661  case MPP:
662  {
663  if( ( aRay.m_Origin.x < m_min.x )
664  || ( aRay.m_Origin.y > m_max.y )
665  || ( aRay.m_Origin.z > m_max.z )
666  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
667  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
668  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
669  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
670  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
671  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
672  )
673  return false;
674 
675  return true;
676  }
677 
678  case PMM:
679  {
680  if( ( aRay.m_Origin.x > m_max.x )
681  || ( aRay.m_Origin.y < m_min.y )
682  || ( aRay.m_Origin.z < m_min.z )
683  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
684  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
685  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
686  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0)
687  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
688  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
689  )
690  return false;
691 
692  return true;
693  }
694 
695 
696  case PMP:
697  {
698  if( ( aRay.m_Origin.x > m_max.x )
699  || ( aRay.m_Origin.y < m_min.y )
700  || ( aRay.m_Origin.z > m_max.z )
701  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
702  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
703  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
704  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
705  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
706  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
707  )
708  return false;
709 
710  return true;
711  }
712 
713  case PPM:
714  {
715  if( ( aRay.m_Origin.x > m_max.x )
716  || ( aRay.m_Origin.y > m_max.y )
717  || ( aRay.m_Origin.z < m_min.z )
718  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
719  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
720  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
721  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
722  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
723  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
724  )
725  return false;
726 
727  return true;
728  }
729 
730  case PPP:
731  {
732  if( ( aRay.m_Origin.x > m_max.x )
733  || ( aRay.m_Origin.y > m_max.y )
734  || ( aRay.m_Origin.z > m_max.z )
735  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
736  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
737  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
738  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
739  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
740  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
741  )
742  return false;
743 
744  return true;
745  }
746 
747  case OMM:
748  {
749  if( ( aRay.m_Origin.x < m_min.x )
750  || ( aRay.m_Origin.x > m_max.x )
751  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.z < m_min.z)
752  || ( aRay.jbyk * m_min.z - m_max.y + aRay.c_zy > 0)
753  || ( aRay.kbyj * m_min.y - m_max.z + aRay.c_yz > 0) )
754  return false;
755 
756  return true;
757  }
758 
759  case OMP:
760  {
761  if( ( aRay.m_Origin.x < m_min.x )
762  || ( aRay.m_Origin.x > m_max.x )
763  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.z > m_max.z)
764  || ( aRay.jbyk * m_max.z - m_max.y + aRay.c_zy > 0)
765  || ( aRay.kbyj * m_min.y - m_min.z + aRay.c_yz < 0)
766  )
767  return false;
768 
769  return true;
770  }
771 
772  case OPM:
773  {
774  if( ( aRay.m_Origin.x < m_min.x )
775  || ( aRay.m_Origin.x > m_max.x )
776  || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z < m_min.z)
777  || ( aRay.jbyk * m_min.z - m_min.y + aRay.c_zy < 0)
778  || ( aRay.kbyj * m_max.y - m_max.z + aRay.c_yz > 0)
779  )
780  return false;
781 
782  return true;
783  }
784 
785  case OPP:
786  {
787  if( ( aRay.m_Origin.x < m_min.x )
788  || ( aRay.m_Origin.x > m_max.x )
789  || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z > m_max.z)
790  || ( aRay.jbyk * m_max.z - m_min.y + aRay.c_zy < 0)
791  || ( aRay.kbyj * m_max.y - m_min.z + aRay.c_yz < 0)
792  )
793  return false;
794 
795  return true;
796  }
797 
798 
799  case MOM:
800  {
801  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
802  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z < m_min.z)
803  || ( aRay.kbyi * m_min.x - m_max.z + aRay.c_xz > 0)
804  || ( aRay.ibyk * m_min.z - m_max.x + aRay.c_zx > 0)
805  )
806  return false;
807 
808  return true;
809  }
810 
811 
812  case MOP:
813  {
814  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
815  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z > m_max.z)
816  || ( aRay.kbyi * m_min.x - m_min.z + aRay.c_xz < 0)
817  || ( aRay.ibyk * m_max.z - m_max.x + aRay.c_zx > 0)
818  )
819  return false;
820 
821  return true;
822  }
823 
824  case POM:
825  {
826  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
827  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z < m_min.z)
828  || ( aRay.kbyi * m_max.x - m_max.z + aRay.c_xz > 0)
829  || ( aRay.ibyk * m_min.z - m_min.x + aRay.c_zx < 0)
830  )
831  return false;
832 
833  return true;
834  }
835 
836 
837  case POP:
838  {
839  if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
840  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z > m_max.z)
841  || ( aRay.kbyi * m_max.x - m_min.z + aRay.c_xz < 0)
842  || ( aRay.ibyk * m_max.z - m_min.x + aRay.c_zx < 0)
843  )
844  return false;
845 
846  return true;
847  }
848 
849  case MMO:
850  {
851  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
852  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y)
853  || ( aRay.jbyi * m_min.x - m_max.y + aRay.c_xy > 0)
854  || ( aRay.ibyj * m_min.y - m_max.x + aRay.c_yx > 0)
855  )
856  return false;
857 
858  return true;
859  }
860 
861  case MPO:
862  {
863  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
864  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y > m_max.y)
865  || ( aRay.jbyi * m_min.x - m_min.y + aRay.c_xy < 0)
866  || ( aRay.ibyj * m_max.y - m_max.x + aRay.c_yx > 0)
867  )
868  return false;
869 
870  return true;
871  }
872 
873 
874  case PMO:
875  {
876  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
877  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y)
878  || ( aRay.jbyi * m_max.x - m_max.y + aRay.c_xy > 0)
879  || ( aRay.ibyj * m_min.y - m_min.x + aRay.c_yx < 0)
880  )
881  return false;
882 
883  return true;
884  }
885 
886  case PPO:
887  {
888  if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
889  || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y)
890  || ( aRay.jbyi * m_max.x - m_min.y + aRay.c_xy < 0)
891  || ( aRay.ibyj * m_max.y - m_min.x + aRay.c_yx < 0)
892  )
893  return false;
894 
895  return true;
896  }
897 
898 
899  case MOO:
900  {
901  if( ( aRay.m_Origin.x < m_min.x)
902  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
903  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
904  )
905  return false;
906 
907  return true;
908  }
909 
910  case POO:
911  {
912  if( ( aRay.m_Origin.x > m_max.x)
913  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
914  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
915  )
916  return false;
917 
918  return true;
919  }
920 
921  case OMO:
922  {
923  if( ( aRay.m_Origin.y < m_min.y)
924  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
925  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
926  )
927  return false;
928 
929  return true;
930  }
931 
932  case OPO:
933  {
934  if( ( aRay.m_Origin.y > m_max.y)
935  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
936  || ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z)
937  )
938  return false;
939 
940  return true;
941  }
942 
943 
944  case OOM:
945  {
946  if( ( aRay.m_Origin.z < m_min.z)
947  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
948  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
949  )
950  return false;
951 
952  return true;
953  }
954 
955  case OOP:
956  {
957  if( ( aRay.m_Origin.z > m_max.z)
958  || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x)
959  || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y)
960  )
961  return false;
962 
963  return true;
964  }
965  }
966 
967  return false;
968 }
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:38
float c_xy
Definition: ray.h:54
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
Definition: ray.h:39
float c_zy
Definition: ray.h:54
Definition: ray.h:39
float jbyk
Definition: ray.h:53
Definition: ray.h:39
float kbyi
Definition: ray.h:53
float c_yx
Definition: ray.h:54
Definition: ray.h:38
Definition: ray.h:38
Definition: ray.h:39
Definition: ray.h:38
Definition: ray.h:39
float kbyj
Definition: ray.h:53
Definition: ray.h:38
Definition: ray.h:39
RAY_CLASSIFICATION m_Classification
Definition: ray.h:49
Definition: ray.h:38
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
Definition: ray.h:39
Definition: ray.h:39
float ibyj
Definition: ray.h:53
float jbyi
Definition: ray.h:53
float c_yz
Definition: ray.h:54
SFVEC3F m_Origin
Definition: ray.h:45
Definition: ray.h:38
Definition: ray.h:38
float c_zx
Definition: ray.h:54
Definition: ray.h:38
Definition: ray.h:38
float c_xz
Definition: ray.h:54
Definition: ray.h:39
Definition: ray.h:38
float ibyk
Definition: ray.h:53
bool CBBOX::Intersect ( const RAY aRay,
float *  aOutHitt0,
float *  aOutHitt1 
) const

Function Intersect - Useful for get the enter and exit position If the ray starts inside the bbox, it will return aOutHitt0 = 0.0.

Parameters
aRay= ray to intersect the box
aOutHitt0= distance point of the ray of the intersection (if true)
aOutHitt1= distance point of the ray of the exit (if true)
Returns
true if the ray hits the box

Definition at line 310 of file cbbox.cpp.

References RAY::m_dirIsNeg, RAY::m_InvDir, m_max, m_min, and RAY::m_Origin.

313 {
314  wxASSERT( aOutHitt0 );
315  wxASSERT( aOutHitt1 );
316 
317  const SFVEC3F bounds[2] = {m_min, m_max};
318 
319  // Check for ray intersection against x and y slabs
320  float tmin = (bounds[ aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x) * aRay.m_InvDir.x;
321  float tmax = (bounds[1 - aRay.m_dirIsNeg[0]].x - aRay.m_Origin.x) * aRay.m_InvDir.x;
322  const float tymin = (bounds[ aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y) * aRay.m_InvDir.y;
323  const float tymax = (bounds[1 - aRay.m_dirIsNeg[1]].y - aRay.m_Origin.y) * aRay.m_InvDir.y;
324 
325  if( (tmin > tymax) || (tymin > tmax) )
326  return false;
327 
328  tmin = (tymin > tmin)? tymin : tmin;
329  tmax = (tymax < tmax)? tymax : tmax;
330 
331  // Check for ray intersection against z slab
332  const float tzmin = (bounds[ aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z) * aRay.m_InvDir.z;
333  const float tzmax = (bounds[1 - aRay.m_dirIsNeg[2]].z - aRay.m_Origin.z) * aRay.m_InvDir.z;
334 
335  if( (tmin > tzmax) || (tzmin > tmax) )
336  return false;
337 
338  tmin = (tzmin > tmin)? tzmin : tmin;
339  tmin = ( tmin < 0.0f)? 0.0f : tmin;
340 
341  tmax = (tzmax < tmax)? tzmax : tmax;
342 
343  *aOutHitt0 = tmin;
344  *aOutHitt1 = tmax;
345 
346  return true;
347 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_InvDir
Definition: ray.h:51
unsigned int m_dirIsNeg[3]
Definition: ray.h:56
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
SFVEC3F m_Origin
Definition: ray.h:45
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
bool CBBOX::Intersects ( const CBBOX aBBox) const

Function Intersects test if a bounding box intersects this box.

Parameters
aBBoxthe bounding box to check if it intersects

Definition at line 230 of file cbbox.cpp.

References IsInitialized(), m_max, and m_min.

Referenced by CDUMMYBLOCK::Intersects(), CLAYERITEM::Intersects(), CROUNDSEG::Intersects(), CVCYLINDER::Intersects(), CXYPLANE::Intersects(), and CTRIANGLE::Intersects().

231 {
232  wxASSERT( IsInitialized() );
233  wxASSERT( aBBox.IsInitialized() );
234 
235  bool x = ( m_max.x >= aBBox.m_min.x ) && ( m_min.x <= aBBox.m_max.x );
236  bool y = ( m_max.y >= aBBox.m_min.y ) && ( m_min.y <= aBBox.m_max.y );
237  bool z = ( m_max.z >= aBBox.m_min.z ) && ( m_min.z <= aBBox.m_max.z );
238 
239  return ( x && y && z );
240 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
bool CBBOX::IsInitialized ( ) const

Function IsInitialized check if this bounding box is already initialized.

Returns
bool - return true if it was initialized, false if otherwise

Definition at line 87 of file cbbox.cpp.

References m_max, and m_min.

Referenced by ApplyTransformation(), ApplyTransformationAA(), Inside(), Intersects(), OGL_draw_bbox(), C3D_RENDER_RAYTRACING::reload(), Scale(), Set(), Union(), and Volume().

88 {
89  return !( ( FLT_MAX == m_min.x) ||
90  ( FLT_MAX == m_min.y) ||
91  ( FLT_MAX == m_min.z) ||
92  (-FLT_MAX == m_max.x) ||
93  (-FLT_MAX == m_max.y) ||
94  (-FLT_MAX == m_max.z) );
95 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
const SFVEC3F& CBBOX::Max ( ) const
inline

Function Max return the maximum vertex pointer.

Returns
SFVEC3F - the maximun vertice position

Definition at line 212 of file cbbox.h.

References m_max.

Referenced by CBVH_PBRT::buildUpperSAH(), CROUNDSEG::CROUNDSEG(), CLAYERITEM::Intersect(), CROUNDSEG::Intersect(), CVCYLINDER::Intersect(), CFRUSTUM::Intersect(), CLAYERITEM::IntersectP(), CROUNDSEG::IntersectP(), CVCYLINDER::IntersectP(), CLAYERITEM::Intersects(), OGL_draw_bbox(), CompareToBucket::operator()(), HLBVH_SAH_Evaluator::operator()(), CBVH_PBRT::recursiveBuild(), and Set().

212 { return m_max; }
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
unsigned int CBBOX::MaxDimension ( ) const

Function MaxDimension.

Returns
the index of the max dimention (0=x, 1=y, 2=z)

Definition at line 154 of file cbbox.cpp.

References GetExtent().

Referenced by CBVH_PBRT::buildUpperSAH(), and CBVH_PBRT::recursiveBuild().

155 {
156  unsigned int result = 0;
157 
158  SFVEC3F extent = GetExtent();
159 
160  if( extent.y > extent.x )
161  result = 1;
162  if( extent.z > extent.y )
163  result = 2;
164 
165  return result;
166 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const SFVEC3F GetExtent() const
Function GetExtent.
Definition: cbbox.cpp:148
const SFVEC3F& CBBOX::Min ( ) const
inline

Function Min return the minimun vertex pointer.

Returns
SFVEC3F - the minimun vertice position

Definition at line 205 of file cbbox.h.

References m_min.

Referenced by CBVH_PBRT::buildUpperSAH(), CROUNDSEG::CROUNDSEG(), CLAYERITEM::Intersect(), CROUNDSEG::Intersect(), CVCYLINDER::Intersect(), CFRUSTUM::Intersect(), CLAYERITEM::IntersectP(), CROUNDSEG::IntersectP(), CVCYLINDER::IntersectP(), CLAYERITEM::Intersects(), OGL_draw_bbox(), CompareToBucket::operator()(), HLBVH_SAH_Evaluator::operator()(), CBVH_PBRT::recursiveBuild(), C3D_RENDER_RAYTRACING::reload(), and Set().

205 { return m_min; }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F CBBOX::Offset ( const SFVEC3F p) const

Function Offset.

Returns
SFVEC3F - return the offset relative to max-min

Definition at line 263 of file cbbox.cpp.

References m_max, and m_min.

Referenced by CBVH_PBRT::HLBVHBuild(), and CBVH_PBRT::recursiveBuild().

264 {
265  return (p - m_min) / (m_max - m_min);
266 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
void CBBOX::Reset ( )

Function Reset reset the bounding box to zero and de-initialized it.

Definition at line 98 of file cbbox.cpp.

References m_max, and m_min.

Referenced by ApplyTransformation(), CBVH_PBRT::buildUpperSAH(), BVHPrimitiveInfo::BVHPrimitiveInfo(), C_OGL_3DMODEL::C_OGL_3DMODEL(), CBBOX(), CBVH_PBRT::CBVH_PBRT(), CDUMMYBLOCK::CDUMMYBLOCK(), CGENERICACCELERATOR::CGENERICACCELERATOR(), CGENERICCONTAINER::CGENERICCONTAINER(), CINFO3D_VISU::CINFO3D_VISU(), CLAYERITEM::CLAYERITEM(), CGENERICCONTAINER::Clear(), CROUNDSEG::CROUNDSEG(), CXYPLANE::CXYPLANE(), CBVH_PBRT::emitLBVH(), CBVH_PBRT::HLBVHBuild(), CTRIANGLE::pre_calc_const(), and CBVH_PBRT::recursiveBuild().

99 {
100  m_min = SFVEC3F( FLT_MAX, FLT_MAX, FLT_MAX );
101  m_max = SFVEC3F(-FLT_MAX,-FLT_MAX,-FLT_MAX );
102 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void CBBOX::Scale ( float  aScale)

Function Scale scales a bounding box by its center.

Parameters
aScalescale factor to apply

Definition at line 194 of file cbbox.cpp.

References GetCenter(), IsInitialized(), m_max, and m_min.

Referenced by C3D_RENDER_RAYTRACING::reload().

195 {
196  wxASSERT( IsInitialized() );
197 
198  SFVEC3F scaleV = SFVEC3F( aScale, aScale, aScale );
199  SFVEC3F centerV = GetCenter();
200 
201  m_min = (m_min - centerV) * scaleV + centerV;
202  m_max = (m_max - centerV) * scaleV + centerV;
203 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
SFVEC3F GetCenter() const
Function GetCenter return the center point of the bounding box.
Definition: cbbox.cpp:135
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
void CBBOX::ScaleNextDown ( )

Function ScaleNextDown scales a bounding box to the next float representation making it smaller.

Definition at line 218 of file cbbox.cpp.

References m_max, m_min, NextFloatDown(), and NextFloatUp().

219 {
220  m_min.x = NextFloatUp( m_min.x );
221  m_min.y = NextFloatUp( m_min.y );
222  m_min.z = NextFloatUp( m_min.z );
223 
224  m_max.x = NextFloatDown( m_max.x );
225  m_max.y = NextFloatDown( m_max.y );
226  m_max.z = NextFloatDown( m_max.z );
227 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
void CBBOX::ScaleNextUp ( )

Function ScaleNextUp scales a bounding box to the next float representation making it larger.

Definition at line 206 of file cbbox.cpp.

References m_max, m_min, NextFloatDown(), and NextFloatUp().

Referenced by CLAYERITEM::CLAYERITEM(), CROUNDSEG::CROUNDSEG(), CVCYLINDER::CVCYLINDER(), and CTRIANGLE::pre_calc_const().

207 {
208  m_min.x = NextFloatDown( m_min.x );
209  m_min.y = NextFloatDown( m_min.y );
210  m_min.z = NextFloatDown( m_min.z );
211 
212  m_max.x = NextFloatUp( m_max.x );
213  m_max.y = NextFloatUp( m_max.y );
214  m_max.z = NextFloatUp( m_max.z );
215 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
float NextFloatDown(float v)
Definition: 3d_fastmath.h:157
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float NextFloatUp(float v)
Definition: 3d_fastmath.h:136
void CBBOX::Set ( const SFVEC3F aPbMin,
const SFVEC3F aPbMax 
)

Function Set Set bounding box with new parameters.

Parameters
aPbMinthe minimun point to initialize the bounding box
aPbMaxthe maximun point to initialize the bounding box

Definition at line 67 of file cbbox.cpp.

References m_max, and m_min.

Referenced by CBBOX(), CDUMMYBLOCK::CDUMMYBLOCK(), CLAYERITEM::CLAYERITEM(), CROUNDSEG::CROUNDSEG(), CVCYLINDER::CVCYLINDER(), CXYPLANE::CXYPLANE(), BVHBuildNode::InitInterior(), CTRIANGLE::pre_calc_const(), and Set().

68 {
69  m_min.x = fminf( aPbMin.x, aPbMax.x );
70  m_min.y = fminf( aPbMin.y, aPbMax.y );
71  m_min.z = fminf( aPbMin.z, aPbMax.z );
72 
73  m_max.x = fmaxf( aPbMin.x, aPbMax.x );
74  m_max.y = fmaxf( aPbMin.y, aPbMax.y );
75  m_max.z = fmaxf( aPbMin.z, aPbMax.z );
76 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
void CBBOX::Set ( const CBBOX aBBox)

Definition at line 79 of file cbbox.cpp.

References IsInitialized(), Max(), Min(), and Set().

80 {
81  wxASSERT( aBBox.IsInitialized() );
82 
83  Set( aBBox.Min(), aBBox.Max() );
84 }
const SFVEC3F & Min() const
Function Min return the minimun vertex pointer.
Definition: cbbox.h:205
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Function Set Set bounding box with new parameters.
Definition: cbbox.cpp:67
const SFVEC3F & Max() const
Function Max return the maximum vertex pointer.
Definition: cbbox.h:212
void CBBOX::Set ( const SFVEC3F aPoint)

Set.

Parameters
aPbMin
aPbMax

Definition at line 60 of file cbbox.cpp.

References m_max, and m_min.

61 {
62  m_min = aPoint;
63  m_max = aPoint;
64 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float CBBOX::SurfaceArea ( ) const

Function SurfaceArea.

Returns
the surface are of the box

Definition at line 184 of file cbbox.cpp.

References GetExtent().

Referenced by CBVH_PBRT::buildUpperSAH(), and CBVH_PBRT::recursiveBuild().

185 {
186  SFVEC3F extent = GetExtent();
187 
188  return 2.0f * ( extent.x * extent.z +
189  extent.x * extent.y +
190  extent.y * extent.z );
191 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const SFVEC3F GetExtent() const
Function GetExtent.
Definition: cbbox.cpp:148
void CBBOX::Union ( const SFVEC3F aPoint)

Function Union recalculate the bounding box adding a point.

Parameters
aPointthe point to be bounded

Definition at line 105 of file cbbox.cpp.

References m_max, and m_min.

Referenced by CGENERICCONTAINER::Add(), ApplyTransformation(), ApplyTransformationAA(), CBVH_PBRT::buildUpperSAH(), C_OGL_3DMODEL::C_OGL_3DMODEL(), CBVH_PBRT::emitLBVH(), CBVH_PBRT::HLBVHBuild(), BVHBuildNode::InitInterior(), CTRIANGLE::pre_calc_const(), and CBVH_PBRT::recursiveBuild().

106 {
107  // get the minimun value between the added point and the existent bounding box
108  m_min.x = fminf( m_min.x, aPoint.x );
109  m_min.y = fminf( m_min.y, aPoint.y );
110  m_min.z = fminf( m_min.z, aPoint.z );
111 
112  // get the maximun value between the added point and the existent bounding box
113  m_max.x = fmaxf( m_max.x, aPoint.x );
114  m_max.y = fmaxf( m_max.y, aPoint.y );
115  m_max.z = fmaxf( m_max.z, aPoint.z );
116 }
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
void CBBOX::Union ( const CBBOX aBBox)

Function Union recalculate the bounding box adding other bounding box.

Parameters
aBBoxthe bounding box to be bounded

Definition at line 119 of file cbbox.cpp.

References IsInitialized(), m_max, and m_min.

120 {
121  wxASSERT( aBBox.IsInitialized() );
122 
123  // get the minimun value between the added bounding box and the existent bounding box
124  m_min.x = fmin( m_min.x, aBBox.m_min.x );
125  m_min.y = fmin( m_min.y, aBBox.m_min.y );
126  m_min.z = fmin( m_min.z, aBBox.m_min.z );
127 
128  // get the maximun value between the added bounding box and the existent bounding box
129  m_max.x = fmax( m_max.x, aBBox.m_max.x );
130  m_max.y = fmax( m_max.y, aBBox.m_max.y );
131  m_max.z = fmax( m_max.z, aBBox.m_max.z );
132 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: cbbox.h:255
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: cbbox.h:256
float CBBOX::Volume ( ) const

Function Volume calculate the volume of a bounding box.

Returns
float - volume of this bounding box

Definition at line 253 of file cbbox.cpp.

References GetExtent(), and IsInitialized().

254 {
255  wxASSERT( IsInitialized() );
256 
257  SFVEC3F extent = GetExtent();
258 
259  return extent.x * extent.y * extent.z;
260 }
bool IsInitialized() const
Function IsInitialized check if this bounding box is already initialized.
Definition: cbbox.cpp:87
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const SFVEC3F GetExtent() const
Function GetExtent.
Definition: cbbox.cpp:148

Member Data Documentation

SFVEC3F CBBOX::m_max
private

(12) point of the higher position of the bounding box

Definition at line 256 of file cbbox.h.

Referenced by ApplyTransformation(), ApplyTransformationAA(), CBBOX(), debug(), GetCenter(), GetExtent(), Inside(), Intersect(), Intersects(), IsInitialized(), Max(), Offset(), Reset(), Scale(), ScaleNextDown(), ScaleNextUp(), Set(), and Union().

SFVEC3F CBBOX::m_min
private

(12) point of the lower position of the bounding box

Definition at line 255 of file cbbox.h.

Referenced by ApplyTransformation(), ApplyTransformationAA(), CBBOX(), debug(), GetCenter(), GetExtent(), Inside(), Intersect(), Intersects(), IsInitialized(), Min(), Offset(), Reset(), Scale(), ScaleNextDown(), ScaleNextUp(), Set(), and Union().


The documentation for this struct was generated from the following files: