Qt 6.x
The Qt SDK
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
32QBoxShape::QBoxShape() = default;
34{
35 delete m_physXGeometry;
36}
37
39{
40 return m_extents;
41}
42
43physx::PxGeometry *QBoxShape::getPhysXGeometry()
44{
45 if (!m_physXGeometry || m_scaleDirty) {
46 updatePhysXGeometry();
47 }
48 return m_physXGeometry;
49}
50
52{
53 if (m_extents == extents)
54 return;
55
56 m_extents = extents;
57 updatePhysXGeometry();
58
59 emit needsRebuild(this);
60 emit extentsChanged(m_extents);
61}
62
63void QBoxShape::updatePhysXGeometry()
64{
65 delete m_physXGeometry;
66 const QVector3D half = m_extents * sceneScale() * 0.5f;
67 m_physXGeometry = new physx::PxBoxGeometry(half.x(), half.y(), half.z());
68 m_scaleDirty = false;
69}
70
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:43
void setExtents(QVector3D extents)
Definition qboxshape.cpp:51
QVector3D sceneScale
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
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
Combined button and popup list for selecting options.
#define emit