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
qcapsuleshape.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qcapsuleshape_p.h"
5
6#include <QtQuick3D/QQuick3DGeometry>
7#include <geometry/PxCapsuleGeometry.h>
8
10
45
47{
48 delete m_physXGeometry;
49}
50
52{
53 if (!m_physXGeometry || m_scaleDirty) {
54 updatePhysXGeometry();
55 }
56
57 return m_physXGeometry;
58}
59
61{
62 return m_diameter;
63}
64
65void QCapsuleShape::setDiameter(float newDiameter)
66{
67 if (qFuzzyCompare(m_diameter, newDiameter))
68 return;
69 m_diameter = newDiameter;
70 updatePhysXGeometry();
71
72 emit needsRebuild(this);
74}
75
77{
78 return m_height;
79}
80
81void QCapsuleShape::setHeight(float newHeight)
82{
83 if (qFuzzyCompare(m_height, newHeight))
84 return;
85 m_height = newHeight;
86 updatePhysXGeometry();
87
88 emit needsRebuild(this);
90}
91
92void QCapsuleShape::updatePhysXGeometry()
93{
94 delete m_physXGeometry;
96 qreal rs = s.y();
97 qreal hs = s.x();
98 m_physXGeometry = new physx::PxCapsuleGeometry(rs * m_diameter * 0.5f, hs * m_height * 0.5f);
99 m_scaleDirty = false;
100}
101
void needsRebuild(QObject *)
void heightChanged()
QCapsuleShape()
\qmltype CapsuleShape \inherits CollisionShape \inqmlmodule QtQuick3D.Physics
void setHeight(float newHeight)
void setDiameter(float newDiameter)
void diameterChanged()
physx::PxGeometry * getPhysXGeometry() override
QVector3D sceneScale
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
GLdouble s
[6]
Definition qopenglext.h:235
#define emit
double qreal
Definition qtypes.h:187