Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
5
6
8#include <private/qssgutils_p.h>
9
11
12void QSSGBounds3::include(const QVector3D &v)
13{
14 minimum = QSSGUtils::vec3::minimum(minimum, v);
15 maximum = QSSGUtils::vec3::maximum(maximum, v);
16}
17
18void QSSGBounds3::include(const QSSGBounds3 &b)
19{
20 minimum = QSSGUtils::vec3::minimum(minimum, b.minimum);
21 maximum = QSSGUtils::vec3::maximum(maximum, b.maximum);
22}
23
24bool QSSGBounds3::isFinite() const
25{
26 return QSSGUtils::vec3::isFinite(minimum) && QSSGUtils::vec3::isFinite(maximum);
27}
28
29QSSGBounds3 QSSGBounds3::boundsOfPoints(const QVector3D &v0, const QVector3D &v1)
30{
31 return QSSGBounds3(QSSGUtils::vec3::minimum(v0, v1), QSSGUtils::vec3::maximum(v0, v1));
32}
33
34QSSGBounds3 QSSGBounds3::basisExtent(const QVector3D &center, const QMatrix3x3 &basis, const QVector3D &extent)
35{
36 // extended basis vectors
37 QVector3D c0 = QVector3D(basis(0, 0), basis(1, 0), basis(2, 0)) * extent.x();
38 QVector3D c1 = QVector3D(basis(0, 1), basis(1, 1), basis(2, 1)) * extent.y();
39 QVector3D c2 = QVector3D(basis(0, 2), basis(1, 2), basis(2, 2)) * extent.z();
40
41 QVector3D w;
42 // find combination of base vectors that produces max. distance for each component = sum of
43 // abs()
44 w.setX(qAbs(c0.x()) + qAbs(c1.x()) + qAbs(c2.x()));
45 w.setY(qAbs(c0.y()) + qAbs(c1.y()) + qAbs(c2.y()));
46 w.setZ(qAbs(c0.z()) + qAbs(c1.z()) + qAbs(c2.z()));
47
48 return QSSGBounds3(center - w, center + w);
49}
50
51QSSGBounds3 QSSGBounds3::transform(const QMatrix3x3 &matrix, const QSSGBounds3 &bounds)
52{
53 return bounds.isEmpty()
54 ? bounds
55 : QSSGBounds3::basisExtent(QSSGUtils::mat33::transform(matrix, bounds.center()), matrix, bounds.extents());
56}
57
58void QSSGBounds3::transform(const QMatrix4x4 &inMatrix)
59{
60 if (!isEmpty()) {
61 const auto pointsPrevious = toQSSGBoxPointsNoEmptyCheck();
62 setEmpty();
63 for (const QVector3D& point : pointsPrevious)
64 include(inMatrix.map(point));
65 }
66}
67
68QVector3D QSSGBounds3::getSupport(const QVector3D &direction) const
69{
70 const QVector3D halfExtents = extents();
71 return QVector3D(direction.x() > 0 ? halfExtents.x() : -halfExtents.x(),
72 direction.y() > 0 ? halfExtents.y() : -halfExtents.y(),
73 direction.z() > 0 ? halfExtents.z() : -halfExtents.z()) + center();
74}
75
76QT_END_NAMESPACE
Combined button and popup list for selecting options.