Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
7
#
include
"qssgbounds3_p.h"
8
#
include
<
private
/
qssgutils_p
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
void
QSSGBounds3::include(
const
QVector3D &v)
13
{
14
minimum = QSSGUtils::vec3::minimum(minimum, v);
15
maximum = QSSGUtils::vec3::maximum(maximum, v);
16
}
17
18
void
QSSGBounds3::include(
const
QSSGBounds3 &b)
19
{
20
minimum = QSSGUtils::vec3::minimum(minimum, b.minimum);
21
maximum = QSSGUtils::vec3::maximum(maximum, b.maximum);
22
}
23
24
bool
QSSGBounds3::isFinite()
const
25
{
26
return
QSSGUtils::vec3::isFinite(minimum) && QSSGUtils::vec3::isFinite(maximum);
27
}
28
29
QSSGBounds3 QSSGBounds3::boundsOfPoints(
const
QVector3D &v0,
const
QVector3D &v1)
30
{
31
return
QSSGBounds3(QSSGUtils::vec3::minimum(v0, v1), QSSGUtils::vec3::maximum(v0, v1));
32
}
33
34
QSSGBounds3 QSSGBounds3::basisExtent(
const
QVector3D ¢er,
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
51
QSSGBounds3 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
58
void
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
68
QVector3D 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
76
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
utils
qssgbounds3.cpp
Generated on
for Qt by
1.18.0