Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssgbounds3.cpp
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#include "qssgbounds3_p.h"
6#include <private/qssgutils_p.h>
7
9
15
21
26
31
32QSSGBounds3 QSSGBounds3::basisExtent(const QVector3D &center, const QMatrix3x3 &basis, const QVector3D &extent)
33{
34 // extended basis vectors
35 QVector3D c0 = QVector3D(basis(0, 0), basis(1, 0), basis(2, 0)) * extent.x();
36 QVector3D c1 = QVector3D(basis(0, 1), basis(1, 1), basis(2, 1)) * extent.y();
37 QVector3D c2 = QVector3D(basis(0, 2), basis(1, 2), basis(2, 2)) * extent.z();
38
40 // find combination of base vectors that produces max. distance for each component = sum of
41 // abs()
42 w.setX(qAbs(c0.x()) + qAbs(c1.x()) + qAbs(c2.x()));
43 w.setY(qAbs(c0.y()) + qAbs(c1.y()) + qAbs(c2.y()));
44 w.setZ(qAbs(c0.z()) + qAbs(c1.z()) + qAbs(c2.z()));
45
46 return QSSGBounds3(center - w, center + w);
47}
48
50{
51 return bounds.isEmpty()
52 ? bounds
54}
55
57{
58 if (!isEmpty()) {
59 const auto pointsPrevious = toQSSGBoxPointsNoEmptyCheck();
60 setEmpty();
61 for (const QVector3D& point : pointsPrevious)
62 include(inMatrix.map(point));
63 }
64}
65
67{
68 const QVector3D halfExtents = extents();
69 return QVector3D(direction.x() > 0 ? halfExtents.x() : -halfExtents.x(),
70 direction.y() > 0 ? halfExtents.y() : -halfExtents.y(),
71 direction.z() > 0 ? halfExtents.z() : -halfExtents.z()) + center();
72}
73
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
Class representing 3D range or axis aligned bounding box.
bool isFinite() const
static Q_ALWAYS_INLINE QSSGBounds3 boundsOfPoints(const QVector3D &v0, const QVector3D &v1)
returns the AABB containing v0 and v1.
Q_ALWAYS_INLINE float extents(quint32 axis) const
get component of the box's extents along a given axis
Q_DECL_CONSTEXPR Q_ALWAYS_INLINE QSSGBounds3()
Default constructor, using empty bounds.
Q_ALWAYS_INLINE QVector3D extents() const
returns the extents, which are half of the width/height/depth.
Q_ALWAYS_INLINE QVector3D center() const
returns the center of this axis aligned box.
QVector3D getSupport(const QVector3D &direction) const
Q_ALWAYS_INLINE void setEmpty()
Sets empty to true.
Q_ALWAYS_INLINE QSSGBoxPoints toQSSGBoxPointsNoEmptyCheck() const
QVector3D minimum
void include(const QVector3D &v)
expands the volume to include v
static Q_ALWAYS_INLINE QSSGBounds3 basisExtent(const QVector3D &center, const QMatrix3x3 &basis, const QVector3D &extent)
Construct from center, extent, and (not necessarily orthogonal) basis.
Q_ALWAYS_INLINE bool isEmpty() const
QVector3D maximum
static QSSGBounds3 transform(const QMatrix3x3 &matrix, const QSSGBounds3 &bounds)
gets the transformed bounds of the passed AABB (resulting in a bigger AABB).
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
Definition qvectornd.h:674
constexpr float y() const noexcept
Returns the y coordinate of this point.
Definition qvectornd.h:671
constexpr float x() const noexcept
Returns the x coordinate of this point.
Definition qvectornd.h:670
constexpr float z() const noexcept
Returns the z coordinate of this point.
Definition qvectornd.h:672
direction
QVector3D Q_QUICK3DUTILS_EXPORT transform(const QMatrix3x3 &m, const QVector3D &v)
Definition qssgutils.cpp:43
QVector3D minimum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
Definition qssgutils_p.h:54
QVector3D maximum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
Definition qssgutils_p.h:55
bool Q_QUICK3DUTILS_EXPORT isFinite(const QVector3D &v)
Definition qssgutils.cpp:18
Combined button and popup list for selecting options.
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLint GLfloat v0
GLint GLfloat GLfloat v1
GLuint GLenum matrix
MyCustomStruct c2