aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick3dphysics/qphysicsmaterial_p.h
blob: 7599245909c50f19c984e958b757b25ae85e161f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QPHYSICSMATERIAL_H
#define QPHYSICSMATERIAL_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
#include <QtQml/QQmlEngine>

QT_BEGIN_NAMESPACE

class Q_QUICK3DPHYSICS_EXPORT QPhysicsMaterial : public QObject
{
    Q_OBJECT
    Q_PROPERTY(float staticFriction READ staticFriction WRITE setStaticFriction NOTIFY
                       staticFrictionChanged)
    Q_PROPERTY(float dynamicFriction READ dynamicFriction WRITE setDynamicFriction NOTIFY
                       dynamicFrictionChanged)
    Q_PROPERTY(float restitution READ restitution WRITE setRestitution NOTIFY restitutionChanged)
    QML_NAMED_ELEMENT(PhysicsMaterial)
public:
    explicit QPhysicsMaterial(QObject *parent = nullptr);

    float staticFriction() const;
    void setStaticFriction(float staticFriction);

    float dynamicFriction() const;
    void setDynamicFriction(float dynamicFriction);

    float restitution() const;
    void setRestitution(float restitution);

    static constexpr float defaultStaticFriction = 0.5f;
    static constexpr float defaultDynamicFriction = 0.5f;
    static constexpr float defaultRestitution = 0.5f;

Q_SIGNALS:
    void staticFrictionChanged();
    void dynamicFrictionChanged();
    void restitutionChanged();

private:
    float m_staticFriction = defaultStaticFriction;
    float m_dynamicFriction = defaultDynamicFriction;
    float m_restitution = defaultRestitution;
};

QT_END_NAMESPACE

#endif // QPHYSICSMATERIAL_H