8#include <QtQuick3D/QQuick3DGeometry>
9#include <extensions/PxExtensionsAPI.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
30
31
32
33
34
36QBoxShape::QBoxShape() =
default;
37QBoxShape::~QBoxShape()
39 delete m_physXGeometry;
42QVector3D QBoxShape::extents()
const
47physx::PxGeometry *QBoxShape::getPhysXGeometry()
49 if (!m_physXGeometry || m_scaleDirty) {
50 updatePhysXGeometry();
52 return m_physXGeometry;
55void QBoxShape::setExtents(QVector3D extents)
57 if (!QPhysicsUtils::isFinite(extents) || extents.x() <= 0.f || extents.y() <= 0.f
58 || extents.z() <= 0.f) {
59 qWarning() <<
"BoxShape: extents must be finite and greater than zero in every "
65 if (m_extents == extents)
69 updatePhysXGeometry();
71 emit needsRebuild(
this);
72 emit extentsChanged(m_extents);
75void QBoxShape::updatePhysXGeometry()
77 delete m_physXGeometry;
78 m_physXGeometry =
nullptr;
81 const QVector3D half = m_extents * sceneScale() * 0.5f;
82 if (!QPhysicsUtils::isFinite(half) || half.x() <= 0.f || half.y() <= 0.f || half.z() <= 0.f) {
83 qWarning() <<
"BoxShape: extents" << m_extents <<
"scaled by" << sceneScale()
84 <<
"must be finite and greater than zero in every component, ignoring.";
87 m_physXGeometry =
new physx::PxBoxGeometry(half.x(), half.y(), half.z());