aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick3dphysics/qabstractphysicsbody.cpp
blob: aaf0516e65121534b3a23dcf958d2a0ce0da906d (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
62
63
64
65
66
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "qabstractphysicsbody_p.h"

QT_BEGIN_NAMESPACE

/*!
    \qmltype PhysicsBody
    \inherits PhysicsNode
    \inqmlmodule QtQuick3D.Physics
    \since 6.4
    \brief Base type for all concrete physical bodies.

    PhysicsBody is the base type for all objects that have a physical presence. These objects
    interact with other bodies. Some types are not influenced by the simulation, such as
    StaticRigidBody: They only influence other bodies. Other bodies are fully governed by the
    simulation.

    \sa {Qt Quick 3D Physics Shapes and Bodies}{Shapes and Bodies overview documentation}
*/

/*!
    \qmlproperty PhysicsMaterial PhysicsBody::physicsMaterial
    This property defines how the body behaves when it collides with or slides against other bodies in the simulation.
*/

/*!
    \qmlproperty bool PhysicsBody::simulationEnabled
    This property defines if the body will partake in the physical simulation.

    Default value: \c{true}
*/

QAbstractPhysicsBody::QAbstractPhysicsBody()
{
    m_physicsMaterial = new QPhysicsMaterial(this);
}

QPhysicsMaterial *QAbstractPhysicsBody::physicsMaterial() const
{
    return m_physicsMaterial;
}

void QAbstractPhysicsBody::setPhysicsMaterial(QPhysicsMaterial *newPhysicsMaterial)
{
    if (m_physicsMaterial == newPhysicsMaterial)
        return;
    m_physicsMaterial = newPhysicsMaterial;
    emit physicsMaterialChanged();
}

bool QAbstractPhysicsBody::simulationEnabled() const
{
    return m_simulationEnabled;
}

void QAbstractPhysicsBody::setSimulationEnabled(bool newSimulationEnabled)
{
    if (m_simulationEnabled == newSimulationEnabled)
        return;
    m_simulationEnabled = newSimulationEnabled;
    emit simulationEnabledChanged();
}

QT_END_NAMESPACE