1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qabstractphysicsbody_p.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \qmltype PhysicsBody
10 \inherits PhysicsNode
11 \inqmlmodule QtQuick3D.Physics
12 \since 6.4
13 \brief Base type for all concrete physical bodies.
14
15 PhysicsBody is the base type for all objects that have a physical presence. These objects
16 interact with other bodies. Some types are not influenced by the simulation, such as
17 StaticRigidBody: They only influence other bodies. Other bodies are fully governed by the
18 simulation.
19
20 \sa {Qt Quick 3D Physics Shapes and Bodies}{Shapes and Bodies overview documentation}
21*/
22
23/*!
24 \qmlproperty PhysicsMaterial PhysicsBody::physicsMaterial
25 This property defines how the body behaves when it collides with or slides against other bodies in the simulation.
26*/
27
28/*!
29 \qmlproperty bool PhysicsBody::simulationEnabled
30 This property defines if the body will partake in the physical simulation.
31
32 Default value: \c{true}
33*/
34
35QAbstractPhysicsBody::QAbstractPhysicsBody()
36{
37 m_physicsMaterial = new QPhysicsMaterial(this);
38}
39
40QPhysicsMaterial *QAbstractPhysicsBody::physicsMaterial() const
41{
42 return m_physicsMaterial;
43}
44
45void QAbstractPhysicsBody::setPhysicsMaterial(QPhysicsMaterial *newPhysicsMaterial)
46{
47 if (m_physicsMaterial == newPhysicsMaterial)
48 return;
49 m_physicsMaterial = newPhysicsMaterial;
50 emit physicsMaterialChanged();
51}
52
53bool QAbstractPhysicsBody::simulationEnabled() const
54{
55 return m_simulationEnabled;
56}
57
58void QAbstractPhysicsBody::setSimulationEnabled(bool newSimulationEnabled)
59{
60 if (m_simulationEnabled == newSimulationEnabled)
61 return;
62 m_simulationEnabled = newSimulationEnabled;
63 emit simulationEnabledChanged();
64}
65
66QT_END_NAMESPACE
67

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtquick3dphysics/src/quick3dphysics/qabstractphysicsbody.cpp