SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLAABBox.cpp
Go to the documentation of this file.
1 /**
2  * \file SLAABBox.cpp
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #include <SLAABBox.h>
11 #include <SLRay.h>
12 #include <SLScene.h>
13 #include <SLGLState.h>
14 
15 //-----------------------------------------------------------------------------
16 //! Default constructor with default zero vector initialization
18 {
19  reset();
20 }
21 //-----------------------------------------------------------------------------
22 //! Resets initial state without contents
24 {
28  _radiusWS = 0;
29 
33  _radiusOS = 0;
34 
35  _sqrViewDist = 0;
40  _isVisible = true;
41 
42  _rectSS.setZero();
43 }
44 //-----------------------------------------------------------------------------
45 //! Recalculate min and max after transformation in world coords
46 void SLAABBox::fromOStoWS(const SLVec3f& minOS,
47  const SLVec3f& maxOS,
48  const SLMat4f& wm)
49 {
50  // Do not transform empty AABB (such as from the camera)
52  return;
53 
54  _minOS.set(minOS);
55  _maxOS.set(maxOS);
56  _minWS.set(minOS);
57  _maxWS.set(maxOS);
58 
59  // we need to transform all 8 corners for a non-optimal bounding box
60  SLVec3f vCorner[8];
61  SLint i;
62 
63  vCorner[0].set(_minWS);
64  vCorner[1].set(_maxWS.x, _minWS.y, _minWS.z);
65  vCorner[2].set(_maxWS.x, _minWS.y, _maxWS.z);
66  vCorner[3].set(_minWS.x, _minWS.y, _maxWS.z);
67  vCorner[4].set(_maxWS.x, _maxWS.y, _minWS.z);
68  vCorner[5].set(_minWS.x, _maxWS.y, _minWS.z);
69  vCorner[6].set(_minWS.x, _maxWS.y, _maxWS.z);
70  vCorner[7].set(_maxWS);
71 
72  // apply world transform
73  for (i = 0; i < 8; ++i)
74  vCorner[i] = wm.multVec(vCorner[i]);
75 
76  // sets the minimum and maximum of the vertex components of the 8 corners
77  _minWS.set(vCorner[0]);
78  _maxWS.set(vCorner[0]);
79  for (i = 1; i < 8; ++i)
80  {
81  _minWS.setMin(vCorner[i]);
82  _maxWS.setMax(vCorner[i]);
83  }
84 
85  // set coordinate axis in world space
90 
91  // Delete OpenGL vertex array
92  if (_vao.vaoID()) _vao.clearAttribs();
93 }
94 //-----------------------------------------------------------------------------
95 //! Recalculate min and max before transformation in object coords
96 void SLAABBox::fromWStoOS(const SLVec3f& minWS,
97  const SLVec3f& maxWS,
98  const SLMat4f& wmI)
99 {
100  _minOS.set(minWS);
101  _maxOS.set(maxWS);
102  _minWS.set(minWS);
103  _maxWS.set(maxWS);
104 
105  // we need to transform all 8 corners for a non-optimal bounding box
106  SLVec3f vCorner[8];
107  SLint i;
108 
109  vCorner[0].set(_minOS);
110  vCorner[1].set(_maxOS.x, _minOS.y, _minOS.z);
111  vCorner[2].set(_maxOS.x, _minOS.y, _maxOS.z);
112  vCorner[3].set(_minOS.x, _minOS.y, _maxOS.z);
113  vCorner[4].set(_maxOS.x, _maxOS.y, _minOS.z);
114  vCorner[5].set(_minOS.x, _maxOS.y, _minOS.z);
115  vCorner[6].set(_minOS.x, _maxOS.y, _maxOS.z);
116  vCorner[7].set(_maxOS);
117 
118  // apply world transform
119  for (i = 0; i < 8; ++i)
120  vCorner[i] = wmI.multVec(vCorner[i]);
121 
122  // sets the minimum and maximum of the vertex components of the 8 corners
123  _minOS.set(vCorner[0]);
124  _maxOS.set(vCorner[0]);
125  for (i = 1; i < 8; ++i)
126  {
127  _minOS.setMin(vCorner[i]);
128  _maxOS.setMax(vCorner[i]);
129  }
130 
131  // Delete OpenGL vertex array
132  if (_vao.vaoID()) _vao.clearAttribs();
133 
134  // Set center & radius of the bounding sphere around the AABB
135  _centerOS.set((_minOS + _maxOS) * 0.5f);
136  SLVec3f extent(_maxOS - _centerOS);
137  _radiusOS = extent.length();
138 }
139 //-----------------------------------------------------------------------------
140 //! Updates the axis of the owning node
142 {
143  // set coordinate axis in world space
148 
149  // Delete OpenGL vertex array
150  if (_vao.vaoID()) _vao.clearAttribs();
151 }
152 //-----------------------------------------------------------------------------
153 //! Updates joints axis and the bone line from the parent to us
154 /*! If the node has a skeleton assigned the method updates the axis and bone
155 visualization lines of the joint. Note that joints bone line is drawn by its
156 children. So the bone line in here is the bone from the parent to us.
157 If this parent bone direction is not along the parents Y axis we interpret the
158 connection not as a bone but as an offset displacement. Bones will be drawn in
159 SLAABBox::drawBoneWS in yellow and displacements in magenta.
160 If the joint has no parent (the root) no line is drawn.
161 */
162 void SLAABBox::updateBoneWS(const SLMat4f& parentWM,
163  const SLbool isRoot,
164  const SLMat4f& nodeWM)
165 {
166  // set coordinate axis centre point
167  _axis0WS = nodeWM.multVec(SLVec3f::ZERO);
168 
169  // set scale factor for coordinate axis
170  SLfloat axisScaleFactor = 0.03f;
171 
172  if (!isRoot)
173  {
174  // build the parent pos in WM
175  _parent0WS = parentWM.multVec(SLVec3f::ZERO);
176 
177  // set the axis scale factor depending on the length of the parent bone
178  SLVec3f parentToMe = _axis0WS - _parent0WS;
179  axisScaleFactor = std::max(parentToMe.length() / 10.0f, axisScaleFactor);
180 
181  // check if the parent to me direction is parallel to the parents actual y-axis
182  parentToMe.normalize();
183  SLVec3f parentY = parentWM.axisY();
184  parentY.normalize();
185  _boneIsOffset = parentToMe.dot(parentY) < (1.0f - FLT_EPSILON);
186  }
187  else
188  {
189  // for the root node don't draw a parent bone
191  _boneIsOffset = false;
192  }
193 
194  // set coordinate axis end points
195  _axisXWS = nodeWM.multVec(SLVec3f::AXISX * axisScaleFactor);
196  _axisYWS = nodeWM.multVec(SLVec3f::AXISY * axisScaleFactor);
197  _axisZWS = nodeWM.multVec(SLVec3f::AXISZ * axisScaleFactor);
198 
199  // Delete OpenGL vertex array
200  if (_vao.vaoID()) _vao.clearAttribs();
201 }
202 //-----------------------------------------------------------------------------
203 //! Calculates center & radius of the bounding sphere around the AABB
205 {
206  _centerWS.set((_minWS + _maxWS) * 0.5f);
207  SLVec3f ext(_maxWS - _centerWS);
208  _radiusWS = ext.length();
209 }
210 //-----------------------------------------------------------------------------
211 //! Generates the vertex buffer for the line visualization
213 {
214  SLVVec3f P; // vertex positions
215 
216  // Bounding box lines in world space
217  P.push_back(SLVec3f(_minWS.x, _minWS.y, _minWS.z)); // lower rect
218  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _minWS.z));
219  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _minWS.z));
220  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _maxWS.z));
221  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _maxWS.z));
222  P.push_back(SLVec3f(_minWS.x, _minWS.y, _maxWS.z));
223  P.push_back(SLVec3f(_minWS.x, _minWS.y, _maxWS.z));
224  P.push_back(SLVec3f(_minWS.x, _minWS.y, _minWS.z));
225 
226  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _minWS.z)); // upper rect
227  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _minWS.z));
228  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _minWS.z));
229  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _maxWS.z));
230  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _maxWS.z));
231  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _maxWS.z));
232  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _maxWS.z));
233 
234  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _minWS.z)); // vertical lines
235  P.push_back(SLVec3f(_minWS.x, _minWS.y, _minWS.z));
236  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _minWS.z));
237  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _minWS.z));
238  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _minWS.z));
239  P.push_back(SLVec3f(_maxWS.x, _minWS.y, _maxWS.z));
240  P.push_back(SLVec3f(_maxWS.x, _maxWS.y, _maxWS.z));
241  P.push_back(SLVec3f(_minWS.x, _minWS.y, _maxWS.z));
242  P.push_back(SLVec3f(_minWS.x, _maxWS.y, _maxWS.z)); // 24
243 
244  // Axis lines in world space
245  P.push_back(SLVec3f(_axis0WS.x, _axis0WS.y, _axis0WS.z)); // x-axis
246  P.push_back(SLVec3f(_axisXWS.x, _axisXWS.y, _axisXWS.z));
247  P.push_back(SLVec3f(_axis0WS.x, _axis0WS.y, _axis0WS.z)); // y-axis
248  P.push_back(SLVec3f(_axisYWS.x, _axisYWS.y, _axisYWS.z));
249  P.push_back(SLVec3f(_axis0WS.x, _axis0WS.y, _axis0WS.z)); // z-axis
250  P.push_back(SLVec3f(_axisZWS.x, _axisZWS.y, _axisZWS.z)); // 30
251 
252  // Bone points in world space
253  P.push_back(SLVec3f(_parent0WS.x, _parent0WS.y, _parent0WS.z));
254  P.push_back(SLVec3f(_axis0WS.x, _axis0WS.y, _axis0WS.z));
255 
257 }
258 //-----------------------------------------------------------------------------
259 //! Draws the AABB in world space with lines in a color
260 void SLAABBox::drawWS(const SLCol4f& color)
261 {
262  if (!_vao.vaoID()) generateVAO();
264  color,
265  1.0f,
266  0,
267  24);
268 }
269 //-----------------------------------------------------------------------------
270 //! Draws the axis in world space with lines in a color
272 {
273  if (!_vao.vaoID()) generateVAO();
275  SLCol4f::RED,
276  2.0f,
277  24,
278  2);
281  2.0f,
282  26,
283  2);
286  2.0f,
287  28,
288  2);
289 }
290 //-----------------------------------------------------------------------------
291 //! Draws the joint axis and the parent bone in world space
292 /*! The joints x-axis is drawn in red, the y-axis in green and the z-axis in
293 blue. If the parent displacement is a bone it is drawn in yellow, if it is a
294 an offset displacement in magenta. See also SLAABBox::updateBoneWS.
295 */
297 {
298  if (!_vao.vaoID()) generateVAO();
300  SLCol4f::RED,
301  2.0f,
302  24,
303  2);
306  2.0f,
307  26,
308  2);
311  2.0f,
312  28,
313  2);
314 
315  // draw either an offset line or a bone line as the parent
316  if (!_boneIsOffset)
319  1.0f,
320  30,
321  2);
322  else
325  1.0f,
326  30,
327  2);
328 }
329 //-----------------------------------------------------------------------------
330 //! SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space
332 {
333  // See: "An Efficient and Robust Ray Box Intersection Algorithm"
334  // by Amy L. Williams, Steve Barrus, R. Keith Morley, Peter Shirley
335  // This test is about 10% faster than the test from Woo
336  // It need the pre computed values invDir and sign in SLRay
337 
338  SLVec3f params[2] = {_minOS, _maxOS};
339  SLfloat tymin, tymax, tzmin, tzmax;
340 
341  ray->tmin = (params[ray->signOS[0]].x - ray->originOS.x) * ray->invDirOS.x;
342  ray->tmax = (params[1 - ray->signOS[0]].x - ray->originOS.x) * ray->invDirOS.x;
343  tymin = (params[ray->signOS[1]].y - ray->originOS.y) * ray->invDirOS.y;
344  tymax = (params[1 - ray->signOS[1]].y - ray->originOS.y) * ray->invDirOS.y;
345 
346  if ((ray->tmin > tymax) || (tymin > ray->tmax)) return false;
347  if (tymin > ray->tmin) ray->tmin = tymin;
348  if (tymax < ray->tmax) ray->tmax = tymax;
349 
350  tzmin = (params[ray->signOS[2]].z - ray->originOS.z) * ray->invDirOS.z;
351  tzmax = (params[1 - ray->signOS[2]].z - ray->originOS.z) * ray->invDirOS.z;
352 
353  if ((ray->tmin > tzmax) || (tzmin > ray->tmax)) return false;
354  if (tzmin > ray->tmin) ray->tmin = tzmin;
355  if (tzmax < ray->tmax) ray->tmax = tzmax;
356 
357  return ((ray->tmin < ray->length) && (ray->tmax > 0));
358 }
359 //-----------------------------------------------------------------------------
360 //! SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space
362 {
363  // See: "An Efficient and Robust Ray Box Intersection Algorithm"
364  // by Amy L. Williams, Steve Barrus, R. Keith Morley, Peter Shirley
365  // This test is about 10% faster than the test from Woo
366  // It needs the pre-computed values invDir and sign in SLRay
367  SLVec3f params[2] = {_minWS, _maxWS};
368  SLfloat tymin, tymax, tzmin, tzmax;
369 
370  ray->tmin = (params[ray->sign[0]].x - ray->origin.x) * ray->invDir.x;
371  ray->tmax = (params[1 - ray->sign[0]].x - ray->origin.x) * ray->invDir.x;
372  tymin = (params[ray->sign[1]].y - ray->origin.y) * ray->invDir.y;
373  tymax = (params[1 - ray->sign[1]].y - ray->origin.y) * ray->invDir.y;
374 
375  if ((ray->tmin > tymax) || (tymin > ray->tmax)) return false;
376  if (tymin > ray->tmin) ray->tmin = tymin;
377  if (tymax < ray->tmax) ray->tmax = tymax;
378 
379  tzmin = (params[ray->sign[2]].z - ray->origin.z) * ray->invDir.z;
380  tzmax = (params[1 - ray->sign[2]].z - ray->origin.z) * ray->invDir.z;
381 
382  if ((ray->tmin > tzmax) || (tzmin > ray->tmax)) return false;
383  if (tzmin > ray->tmin) ray->tmin = tzmin;
384  if (tzmax < ray->tmax) ray->tmax = tzmax;
385 
386  return ((ray->tmin < ray->length) && (ray->tmax > 0));
387 }
388 //-----------------------------------------------------------------------------
389 //! Merges the bounding box bb to this one by extending this one axis aligned
391 {
392  if (bb.minWS() != SLVec3f::ZERO && bb.maxWS() != SLVec3f::ZERO)
393  {
394  _minWS.setMin(bb.minWS());
395  _maxWS.setMax(bb.maxWS());
396  }
397 }
398 //-----------------------------------------------------------------------------
399 //! Calculates the AABBs min. and max. corners in screen space
401 {
402  SLVec3f corners[8];
403 
404  // Back corners in world space
405  corners[0] = _minWS;
406  corners[1] = SLVec3f(_maxWS.x, _minWS.y, _minWS.z);
407  corners[2] = SLVec3f(_minWS.x, _maxWS.y, _minWS.z);
408  corners[3] = SLVec3f(_maxWS.x, _maxWS.y, _minWS.z);
409 
410  // Front corners in world space
411  corners[4] = SLVec3f(_minWS.x, _minWS.y, _maxWS.z);
412  corners[5] = SLVec3f(_maxWS.x, _minWS.y, _maxWS.z);
413  corners[6] = SLVec3f(_minWS.x, _maxWS.y, _maxWS.z);
414  corners[7] = _maxWS;
415 
416  // build view-projection-viewport matrix
417  SLGLState* stateGL = SLGLState::instance();
418  SLMat4f vpvpMat = stateGL->viewportMatrix() *
419  stateGL->projectionMatrix *
420  stateGL->viewMatrix;
421 
422  // transform corners from world to screen space
423  for (SLint i = 0; i < 8; ++i)
424  corners[i] = vpvpMat.multVec(corners[i]);
425 
426  // Build min. and max. in screen space
427  SLVec2f minSS(FLT_MAX, FLT_MAX);
428  SLVec2f maxSS(FLT_MIN, FLT_MIN);
429 
430  for (SLint i = 0; i < 8; ++i)
431  {
432  minSS.x = std::min(minSS.x, corners[i].x);
433  minSS.y = std::min(minSS.y, corners[i].y);
434  maxSS.x = std::max(maxSS.x, corners[i].x);
435  maxSS.y = std::max(maxSS.y, corners[i].y);
436  }
437 
438  _rectSS.set(minSS.x,
439  minSS.y,
440  maxSS.x - minSS.x,
441  maxSS.y - minSS.y);
442  //_rectSS.print("_rectSS: ");
443 }
444 //-----------------------------------------------------------------------------
445 //! Calculates the bounding rectangle in screen space and returns coverage in SS
447 {
448  calculateRectSS();
449 
450  SLGLState* stateGL = SLGLState::instance();
451  SLfloat areaSS = _rectSS.width * _rectSS.height;
452  SLVec4i vp = stateGL->viewport();
453  SLfloat areaFullScreen = (float)vp.z * (float)vp.w;
454  SLfloat coverage = areaSS / areaFullScreen;
455  return coverage;
456 }
457 //-----------------------------------------------------------------------------
float SLfloat
Definition: SL.h:173
bool SLbool
Definition: SL.h:175
int SLint
Definition: SL.h:170
@ PT_lines
Definition: SLGLEnums.h:32
Singleton class for global render state.
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
Defines an axis aligned bounding box.
Definition: SLAABBox.h:34
SLVec3f minWS()
Definition: SLAABBox.h:48
SLfloat rectCoverageInSS()
Calculates the bounding rectangle in screen space and returns coverage in SS.
Definition: SLAABBox.cpp:446
SLGLVertexArrayExt _vao
Vertex array object for rendering.
Definition: SLAABBox.h:101
void generateVAO()
Generates the vertex buffer for the line visualization.
Definition: SLAABBox.cpp:212
SLVec3f _centerOS
Center of AABB in object space.
Definition: SLAABBox.h:89
void reset()
Resets initial state without contents.
Definition: SLAABBox.cpp:23
SLVec3f _minOS
Min. corner in object space.
Definition: SLAABBox.h:85
SLVec3f _axisZWS
World space z-axis vector.
Definition: SLAABBox.h:96
SLfloat _radiusWS
Radius of sphere around AABB in WS.
Definition: SLAABBox.h:90
void mergeWS(SLAABBox &bb)
Merges the bounding box bb to this one by extending this one axis aligned.
Definition: SLAABBox.cpp:390
SLVec3f _parent0WS
World space vector to the parent position.
Definition: SLAABBox.h:98
SLbool isHitInWS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.
Definition: SLAABBox.cpp:361
SLRectf _rectSS
Bounding rectangle in screen space.
Definition: SLAABBox.h:100
SLVec3f _maxWS
Max. corner in world space.
Definition: SLAABBox.h:86
SLVec3f _axisXWS
World space x-axis vector.
Definition: SLAABBox.h:94
SLAABBox()
Default constructor with default zero vector initialization.
Definition: SLAABBox.cpp:17
void fromOStoWS(const SLVec3f &minOS, const SLVec3f &maxOS, const SLMat4f &wm)
Recalculate min and max after transformation in world coords.
Definition: SLAABBox.cpp:46
void calculateRectSS()
Calculates the AABBs min. and max. corners in screen space.
Definition: SLAABBox.cpp:400
SLVec3f _maxOS
Max. corner in object space.
Definition: SLAABBox.h:87
SLfloat _sqrViewDist
Squared dist. from center to viewpoint.
Definition: SLAABBox.h:92
SLVec3f _axisYWS
World space y-axis vector.
Definition: SLAABBox.h:95
SLVec3f _centerWS
Center of AABB in world space.
Definition: SLAABBox.h:88
void minWS(const SLVec3f &minC)
Definition: SLAABBox.h:39
void drawAxisWS()
Draws the axis in world space with lines in a color.
Definition: SLAABBox.cpp:271
SLVec3f _axis0WS
World space axis center point.
Definition: SLAABBox.h:93
SLfloat _radiusOS
Radius of sphere around AABB in OS.
Definition: SLAABBox.h:91
void drawWS(const SLCol4f &color)
Draws the AABB in world space with lines in a color.
Definition: SLAABBox.cpp:260
void fromWStoOS(const SLVec3f &minWS, const SLVec3f &maxWS, const SLMat4f &wmI)
Recalculate min and max before transformation in object coords.
Definition: SLAABBox.cpp:96
SLVec3f maxOS()
Definition: SLAABBox.h:53
void maxWS(const SLVec3f &maxC)
Definition: SLAABBox.h:40
void updateAxisWS(const SLMat4f &wm)
Updates the axis of the owning node.
Definition: SLAABBox.cpp:141
void updateBoneWS(const SLMat4f &parentWM, SLbool isRoot, const SLMat4f &nodeWM)
Updates joints axis and the bone line from the parent to us.
Definition: SLAABBox.cpp:162
SLbool _boneIsOffset
Flag if the connection parent to us is a bone or an offset.
Definition: SLAABBox.h:97
void drawBoneWS()
Draws the joint axis and the parent bone in world space.
Definition: SLAABBox.cpp:296
SLbool isHitInOS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.
Definition: SLAABBox.cpp:331
SLbool _isVisible
Flag if AABB is in the view frustum.
Definition: SLAABBox.h:99
SLVec3f minOS()
Definition: SLAABBox.h:52
void setCenterAndRadiusWS()
Calculates center & radius of the bounding sphere around the AABB.
Definition: SLAABBox.cpp:204
SLVec3f _minWS
Min. corner in world space.
Definition: SLAABBox.h:84
SLVec3f maxWS()
Definition: SLAABBox.h:49
Singleton class holding all OpenGL states.
Definition: SLGLState.h:71
void viewport(SLint x, SLint y, SLsizei width, SLsizei height)
Definition: SLGLState.cpp:378
static SLGLState * instance()
Public static instance getter for singleton pattern.
Definition: SLGLState.h:74
SLMat4f viewMatrix
matrix for the active cameras view transform
Definition: SLGLState.h:91
SLMat4f viewportMatrix()
Definition: SLGLState.h:143
SLMat4f projectionMatrix
matrix for projection transform
Definition: SLGLState.h:90
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
void clearAttribs()
Clears the attribute definition.
SLuint vaoID() const
Returns either the VAO id or the VBO id.
SLVec3< T > axisY() const
Definition: SLMat4.h:186
SLVec3< T > multVec(SLVec3< T > v) const
Definition: SLMat4.h:576
Ray class with ray and intersection properties.
Definition: SLRay.h:40
SLfloat tmax
max. dist. of last AABB intersection
Definition: SLRay.h:121
SLint sign[3]
Sign of invDir for fast AABB hit in WS.
Definition: SLRay.h:118
SLVec3f origin
Vector to the origin of ray in WS.
Definition: SLRay.h:75
SLVec3f invDirOS
Inverse ray dir for fast AABB hit in OS.
Definition: SLRay.h:117
SLfloat tmin
min. dist. of last AABB intersection
Definition: SLRay.h:120
SLfloat length
length from origin to an intersection
Definition: SLRay.h:77
SLint signOS[3]
Sign of invDir for fast AABB hit in OS.
Definition: SLRay.h:119
SLVec3f invDir
Inverse ray dir for fast AABB hit in WS.
Definition: SLRay.h:116
SLVec3f originOS
Vector to the origin of ray in OS.
Definition: SLRay.h:80
T width
Definition: SLRect.h:29
void set(const T X, const T Y, const T WIDTH, const T HEIGHT)
Definition: SLRect.h:42
T height
Definition: SLRect.h:29
void setZero()
Definition: SLRect.h:49
T y
Definition: SLVec2.h:30
T x
Definition: SLVec2.h:30
void setMax(const SLVec3 &v)
Definition: SLVec3.h:147
T y
Definition: SLVec3.h:43
static SLVec3 AXISY
Definition: SLVec3.h:298
T x
Definition: SLVec3.h:43
SLVec3 & normalize()
Definition: SLVec3.h:124
T length() const
Definition: SLVec3.h:122
static SLVec3 AXISX
Definition: SLVec3.h:297
void set(const T X, const T Y, const T Z)
Definition: SLVec3.h:59
T dot(const SLVec3 &v) const
Definition: SLVec3.h:117
T z
Definition: SLVec3.h:43
void setMin(const SLVec3 &v)
Definition: SLVec3.h:144
static SLVec3 AXISZ
Definition: SLVec3.h:299
static SLVec3 ZERO
Definition: SLVec3.h:285
T w
Definition: SLVec4.h:32
T z
Definition: SLVec4.h:32
static SLVec4 GREEN
Definition: SLVec4.h:217
static SLVec4 YELLOW
Definition: SLVec4.h:219
static SLVec4 MAGENTA
Definition: SLVec4.h:221
static SLVec4 RED
Definition: SLVec4.h:216
static SLVec4 BLUE
Definition: SLVec4.h:218