diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-08-09 00:53:06 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-08-10 01:24:22 +0000 |
commit | d5a2e2f3e36c7dc0ddffbfae703a4d3072f9717d (patch) | |
tree | e2f3039c7b2ca5cbe0c36ac387118e2ecb8fdc47 | |
parent | 97263c5d8ebb6755191f4fac642ac9ea0eec3238 (diff) |
Add QAbstractCollider type
Provides an interface for colliders.
Change-Id: Icfb34bc2da6c6b4c35d2ac237c991a91f2ec6710
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/collision/collision.pri | 7 | ||||
-rw-r--r-- | src/collision/qabstractcollider.cpp | 88 | ||||
-rw-r--r-- | src/collision/qabstractcollider.h | 77 | ||||
-rw-r--r-- | src/collision/qabstractcollider_p.h | 61 | ||||
-rw-r--r-- | src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp | 2 |
5 files changed, 233 insertions, 2 deletions
diff --git a/src/collision/collision.pri b/src/collision/collision.pri index 20f05ff7a..5a9291fe4 100644 --- a/src/collision/collision.pri +++ b/src/collision/collision.pri @@ -11,11 +11,14 @@ HEADERS += \ $$PWD/qcapsulecollider.h \ $$PWD/qcapsulecollider_p.h \ $$PWD/qgeometrycollider.h \ - $$PWD/qgeometrycollider_p.h + $$PWD/qgeometrycollider_p.h \ + $$PWD/qabstractcollider.h \ + $$PWD/qabstractcollider_p.h SOURCES += \ $$PWD/qcollisionaspect.cpp \ $$PWD/qspherecollider.cpp \ $$PWD/qboxcollider.cpp \ $$PWD/qcapsulecollider.cpp \ - $$PWD/qgeometrycollider.cpp + $$PWD/qgeometrycollider.cpp \ + $$PWD/qabstractcollider.cpp diff --git a/src/collision/qabstractcollider.cpp b/src/collision/qabstractcollider.cpp new file mode 100644 index 000000000..2233ecfc3 --- /dev/null +++ b/src/collision/qabstractcollider.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qabstractcollider.h" +#include "qabstractcollider_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +/*! + \class Qt3D::QAbstractColliderPrivate + \internal +*/ +QAbstractColliderPrivate::QAbstractColliderPrivate() + : QComponentPrivate() +{ +} + +/*! \internal */ +QAbstractCollider::QAbstractCollider(QAbstractColliderPrivate &dd, QNode *parent) + : QComponent(dd, parent) +{ +} + +QAbstractCollider::~QAbstractCollider() +{ + QNode::cleanup(); +} + +void QAbstractCollider::onEntered(QCollisionEvent *e) +{ + // TODO: Emit with other collider (or event for more info about the collision) + Q_UNUSED(e); + emit entered(Q_NULLPTR); +} + +void QAbstractCollider::onCollidingWith(QCollisionEvent *e) +{ + // TODO: Emit with other collider (or event for more info about the collision) + Q_UNUSED(e); + emit collidingWith(Q_NULLPTR); +} + +void QAbstractCollider::onExited(QCollisionEvent *e) +{ + // TODO: Emit with other collider (or event for more info about the collision) + Q_UNUSED(e); + emit exited(Q_NULLPTR); +} + +QT_END_NAMESPACE + +} // namespace Qt3D + diff --git a/src/collision/qabstractcollider.h b/src/collision/qabstractcollider.h new file mode 100644 index 000000000..63dd23e52 --- /dev/null +++ b/src/collision/qabstractcollider.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3D_QABSTRACTCOLLIDER_H +#define QT3D_QABSTRACTCOLLIDER_H + +#include <Qt3DCore/qcomponent.h> +#include <Qt3DCollision/qt3dcollision_global.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +class QAbstractColliderPrivate; +class QCollisionEvent; + +class QT3DCOLLISIONSHARED_EXPORT QAbstractCollider : public QComponent +{ + Q_OBJECT + +public: + ~QAbstractCollider(); + +Q_SIGNALS: + void entered(QAbstractCollider *other); + void collidingWith(QAbstractCollider *other); + void exited(QAbstractCollider *other); + +protected: + QAbstractCollider(QAbstractColliderPrivate &dd, QNode *parent = 0); + + virtual void onEntered(QCollisionEvent *e); + virtual void onCollidingWith(QCollisionEvent *e); + virtual void onExited(QCollisionEvent *e); + +private: + Q_DECLARE_PRIVATE(QAbstractCollider) +}; + +} // namespace Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QABSTRACTCOLLIDER_H diff --git a/src/collision/qabstractcollider_p.h b/src/collision/qabstractcollider_p.h new file mode 100644 index 000000000..8bdda19d6 --- /dev/null +++ b/src/collision/qabstractcollider_p.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3D_QABSTRACTCOLLIDER_P_H +#define QT3D_QABSTRACTCOLLIDER_P_H + +#include <Qt3DCore/private/qcomponent_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +class QAbstractCollider; + +class QAbstractColliderPrivate : public QComponentPrivate +{ +public: + QAbstractColliderPrivate(); + + Q_DECLARE_PUBLIC(QAbstractCollider) +}; + +} // namespace Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QABSTRACTCOLLIDER_P_H + diff --git a/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp b/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp index 214cfa292..650a77bd4 100644 --- a/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp +++ b/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp @@ -35,6 +35,7 @@ ****************************************************************************/ #include <QtQml> +#include <Qt3DCollision/qabstractcollider.h> #include <Qt3DCollision/qboxcollider.h> #include <Qt3DCollision/qcapsulecollider.h> #include <Qt3DCollision/qgeometrycollider.h> @@ -45,6 +46,7 @@ QT_BEGIN_NAMESPACE void Qt3DQuick3DCollisionPlugin::registerTypes(const char *uri) { + qmlRegisterUncreatableType<Qt3D::QAbstractCollider>(uri, 2, 0, "AbstractCollider", "AbstractColliders are only used for references"); qmlRegisterType<Qt3D::QBoxCollider>(uri, 2, 0, "BoxCollider"); qmlRegisterType<Qt3D::QCapsuleCollider>(uri, 2, 0, "CapsuleCollider"); qmlRegisterType<Qt3D::QGeometryCollider>(uri, 2, 0, "GeometryCollider"); |