1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef CAPSULESHAPE_H
5#define CAPSULESHAPE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
19#include <QtQuick3DPhysics/private/qabstractcollisionshape_p.h>
20#include <QtQml/QQmlEngine>
21
22namespace physx {
23class PxCapsuleGeometry;
24}
25
26QT_BEGIN_NAMESPACE
27
28class Q_QUICK3DPHYSICS_EXPORT QCapsuleShape : public QAbstractCollisionShape
29{
30 Q_OBJECT
31 QML_NAMED_ELEMENT(CapsuleShape)
32 Q_PROPERTY(float diameter READ diameter WRITE setDiameter NOTIFY diameterChanged)
33 Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
34public:
35 QCapsuleShape();
36 ~QCapsuleShape();
37
38 float diameter() const;
39 void setDiameter(float newDiameter);
40
41 float height() const;
42 void setHeight(float newHeight);
43
44 physx::PxGeometry *getPhysXGeometry() override;
45 bool isStaticShape() const override { return false; }
46
47Q_SIGNALS:
48 void diameterChanged();
49 void heightChanged();
50
51private:
52 void updatePhysXGeometry();
53 physx::PxCapsuleGeometry *m_physXGeometry = nullptr;
54 float m_diameter = 100.0f;
55 float m_height = 100.0f;
56};
57
58QT_END_NAMESPACE
59
60#endif // CAPSULESHAPE_H
61

source code of qtquick3dphysics/src/quick3dphysics/qcapsuleshape_p.h