Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qabstractphysicsbody.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9/*!
10 \qmltype PhysicsBody
11 \inherits PhysicsNode
12 \inqmlmodule QtQuick3D.Physics
13 \since 6.4
14 \brief Base type for all concrete physical bodies.
15
16 PhysicsBody is the base type for all objects that have a physical presence. These objects
17 interact with other bodies. Some types are not influenced by the simulation, such as
18 StaticRigidBody: They only influence other bodies. Other bodies are fully governed by the
19 simulation.
20
21 \sa {Qt Quick 3D Physics Shapes, Bodies and Joints}
22*/
23
24/*!
25 \qmlproperty PhysicsMaterial PhysicsBody::physicsMaterial
26 This property defines how the body behaves when it collides with or slides against other bodies in the simulation.
27
28 \note This property currently holds a \l PhysicsMaterial with default values unless another
29 one is assigned, but it may default to \c null in a future version of Qt, so do not rely on
30 it being non-null. Assign a \l PhysicsMaterial explicitly to the bodies whose material you
31 read or modify.
32
33 \sa PhysicsMaterial
34*/
35
36/*!
37 \qmlproperty bool PhysicsBody::simulationEnabled
38 This property defines if the body will partake in the physical simulation.
39
40 Default value: \c{true}
41*/
42
43QAbstractPhysicsBody::QAbstractPhysicsBody()
44{
45 m_physicsMaterial = new QPhysicsMaterial(this);
46}
47
48QPhysicsMaterial *QAbstractPhysicsBody::physicsMaterial() const
49{
50 return m_physicsMaterial;
51}
52
53void QAbstractPhysicsBody::setPhysicsMaterial(QPhysicsMaterial *newPhysicsMaterial)
54{
55 if (m_physicsMaterial == newPhysicsMaterial)
56 return;
57 m_physicsMaterial = newPhysicsMaterial;
58 emit physicsMaterialChanged();
59}
60
61bool QAbstractPhysicsBody::simulationEnabled() const
62{
63 return m_simulationEnabled;
64}
65
66void QAbstractPhysicsBody::setSimulationEnabled(bool newSimulationEnabled)
67{
68 if (m_simulationEnabled == newSimulationEnabled)
69 return;
70 m_simulationEnabled = newSimulationEnabled;
71 emit simulationEnabledChanged();
72}
73
74QT_END_NAMESPACE
Combined button and popup list for selecting options.