diff options
Diffstat (limited to 'src/physics')
-rw-r--r-- | src/physics/frontend/qcuboidcollisionshape.cpp | 67 | ||||
-rw-r--r-- | src/physics/frontend/qcuboidcollisionshape.h | 15 | ||||
-rw-r--r-- | src/physics/frontend/qcuboidcollisionshape_p.h | 8 |
3 files changed, 86 insertions, 4 deletions
diff --git a/src/physics/frontend/qcuboidcollisionshape.cpp b/src/physics/frontend/qcuboidcollisionshape.cpp index 4882101a1..5caa495e4 100644 --- a/src/physics/frontend/qcuboidcollisionshape.cpp +++ b/src/physics/frontend/qcuboidcollisionshape.cpp @@ -46,6 +46,9 @@ namespace Qt3DPhysics { QCuboidCollisionShapePrivate::QCuboidCollisionShapePrivate() : QAbstractCollisionShapePrivate() + , m_xExtent(1.0f) + , m_yExtent(1.0f) + , m_zExtent(1.0f) { } @@ -63,12 +66,74 @@ QCuboidCollisionShape::~QCuboidCollisionShape() { } +void QCuboidCollisionShape::setXExtent(float xExtent) +{ + Q_D(QCuboidCollisionShape); + if (d->m_xExtent != xExtent) { + d->m_xExtent = xExtent; + emit xExtentChanged(xExtent); + } +} + +void QCuboidCollisionShape::setYExtent(float yExtent) +{ + Q_D(QCuboidCollisionShape); + if (d->m_yExtent != yExtent) { + d->m_yExtent = yExtent; + emit yExtentChanged(yExtent); + } +} + +void QCuboidCollisionShape::setZExtent(float zExtent) +{ + Q_D(QCuboidCollisionShape); + if (d->m_zExtent != zExtent) { + d->m_zExtent = zExtent; + emit zExtentChanged(zExtent); + } +} + +/*! + * \property QCuboidCollisionShape::xExtent + * + * Holds the x extent of the geometry. + */ +float QCuboidCollisionShape::xExtent() const +{ + Q_D(const QCuboidCollisionShape); + return d->m_xExtent; +} + +/*! + * \property QCuboidCollisionShape::yExtent + * + * Holds the y extent of the geometry. + */ +float QCuboidCollisionShape::yExtent() const +{ + Q_D(const QCuboidCollisionShape); + return d->m_yExtent; +} + +/*! + * \property QCuboidCollisionShape::zExtent + * + * Holds the z extent of the geometry. + */ +float QCuboidCollisionShape::zExtent() const +{ + Q_D(const QCuboidCollisionShape); + return d->m_zExtent; +} + Qt3DCore::QNodeCreatedChangeBasePtr QCuboidCollisionShape::createNodeCreationChange() const { auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QCuboidCollisionShapeData>::create(this); auto &data = creationChange->data; Q_D(const QCuboidCollisionShape); - // TODO: Send data members in creation change + data.xExtent = d->m_xExtent; + data.yExtent = d->m_yExtent; + data.zExtent = d->m_zExtent; return creationChange; } diff --git a/src/physics/frontend/qcuboidcollisionshape.h b/src/physics/frontend/qcuboidcollisionshape.h index fedb53eaf..896c0d8ac 100644 --- a/src/physics/frontend/qcuboidcollisionshape.h +++ b/src/physics/frontend/qcuboidcollisionshape.h @@ -52,14 +52,27 @@ class QCuboidCollisionShapePrivate; class QT3DPHYSICSSHARED_EXPORT QCuboidCollisionShape : public QAbstractCollisionShape { Q_OBJECT - // TODO: Add property declarations + Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged) + Q_PROPERTY(float yExtent READ yExtent WRITE setYExtent NOTIFY yExtentChanged) + Q_PROPERTY(float zExtent READ zExtent WRITE setZExtent NOTIFY zExtentChanged) + public: explicit QCuboidCollisionShape(Qt3DCore::QNode *parent = nullptr); ~QCuboidCollisionShape(); + float xExtent() const; + float yExtent() const; + float zExtent() const; + public Q_SLOTS: + void setXExtent(float xExtent); + void setYExtent(float yExtent); + void setZExtent(float zExtent); Q_SIGNALS: + void xExtentChanged(float xExtent); + void yExtentChanged(float yExtent); + void zExtentChanged(float zExtent); protected: QCuboidCollisionShape(QCuboidCollisionShapePrivate &dd, Qt3DCore::QNode *parent = nullptr); diff --git a/src/physics/frontend/qcuboidcollisionshape_p.h b/src/physics/frontend/qcuboidcollisionshape_p.h index 1f50b6bc8..e99a24b11 100644 --- a/src/physics/frontend/qcuboidcollisionshape_p.h +++ b/src/physics/frontend/qcuboidcollisionshape_p.h @@ -64,12 +64,16 @@ public: Q_DECLARE_PUBLIC(QCuboidCollisionShape) - // TODO Add member variables + float m_xExtent; + float m_yExtent; + float m_zExtent; }; struct QCuboidCollisionShapeData { - // TODO: Add members that should be sent to the backend + float xExtent; + float yExtent; + float zExtent; }; } // namespace Qt3DPhysics |