1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QPHYSICSMATERIAL_H
5#define QPHYSICSMATERIAL_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 <QtQml/QQmlEngine>
20
21QT_BEGIN_NAMESPACE
22
23class Q_QUICK3DPHYSICS_EXPORT QPhysicsMaterial : public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY(float staticFriction READ staticFriction WRITE setStaticFriction NOTIFY
27 staticFrictionChanged)
28 Q_PROPERTY(float dynamicFriction READ dynamicFriction WRITE setDynamicFriction NOTIFY
29 dynamicFrictionChanged)
30 Q_PROPERTY(float restitution READ restitution WRITE setRestitution NOTIFY restitutionChanged)
31 QML_NAMED_ELEMENT(PhysicsMaterial)
32public:
33 explicit QPhysicsMaterial(QObject *parent = nullptr);
34
35 float staticFriction() const;
36 void setStaticFriction(float staticFriction);
37
38 float dynamicFriction() const;
39 void setDynamicFriction(float dynamicFriction);
40
41 float restitution() const;
42 void setRestitution(float restitution);
43
44 static constexpr float defaultStaticFriction = 0.5f;
45 static constexpr float defaultDynamicFriction = 0.5f;
46 static constexpr float defaultRestitution = 0.5f;
47
48Q_SIGNALS:
49 void staticFrictionChanged();
50 void dynamicFrictionChanged();
51 void restitutionChanged();
52
53private:
54 float m_staticFriction = defaultStaticFriction;
55 float m_dynamicFriction = defaultDynamicFriction;
56 float m_restitution = defaultRestitution;
57};
58
59QT_END_NAMESPACE
60
61#endif // QPHYSICSMATERIAL_H
62

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