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
qboxshape.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 "qboxshape_p.h"
5
6#include <QtQuick3D/QQuick3DGeometry>
7#include <extensions/PxExtensionsAPI.h>
8
10
34QBoxShape::QBoxShape() = default;
36{
37 delete m_physXGeometry;
38}
39
41{
42 return m_extents;
43}
44
45physx::PxGeometry *QBoxShape::getPhysXGeometry()
46{
47 if (!m_physXGeometry || m_scaleDirty) {
48 updatePhysXGeometry();
49 }
50 return m_physXGeometry;
51}
52
54{
55 if (m_extents == extents)
56 return;
57
58 m_extents = extents;
59 updatePhysXGeometry();
60
61 emit needsRebuild(this);
62 emit extentsChanged(m_extents);
63}
64
65void QBoxShape::updatePhysXGeometry()
66{
67 delete m_physXGeometry;
68 const QVector3D half = m_extents * sceneScale() * 0.5f;
69 m_physXGeometry = new physx::PxBoxGeometry(half.x(), half.y(), half.z());
70 m_scaleDirty = false;
71}
72
void needsRebuild(QObject *)
QBoxShape()
\qmltype BoxShape \inherits CollisionShape \inqmlmodule QtQuick3D.Physics
QVector3D extents
Definition qboxshape_p.h:33
void extentsChanged(QVector3D extents)
physx::PxGeometry * getPhysXGeometry() override
Definition qboxshape.cpp:45
void setExtents(QVector3D extents)
Definition qboxshape.cpp:53
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.
#define emit