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
qabstractcollisionshape.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
7#include <QtQml/QQmlListReference>
8
10
12
13/*!
14 \qmltype CollisionShape
15 \inherits Node
16 \inqmlmodule QtQuick3D.Physics
17 \since 6.4
18 \brief Base type for collision shapes.
19
20 This is the base type for all collision shapes. A collision shape
21 is used to define the physical shape and extent of an object for the
22 purposes of the physics simulation.
23
24 \sa {Qt Quick 3D Physics Shapes and Bodies}{Shapes and Bodies overview documentation}
25*/
26
27/*!
28 \qmlproperty bool CollisionShape::enableDebugDraw
29 This property enables drawing the shape's debug view.
30
31 Default value: \c{false}
32*/
33
34QAbstractCollisionShape::QAbstractCollisionShape(QQuick3DNode *parent) : QQuick3DNode(parent)
35{
36 connect(this, &QQuick3DNode::sceneScaleChanged, this,
37 &QAbstractCollisionShape::handleScaleChange);
38}
39
40QAbstractCollisionShape::~QAbstractCollisionShape() = default;
41
42bool QAbstractCollisionShape::enableDebugDraw() const
43{
44 return m_enableDebugDraw;
45}
46
47void QAbstractCollisionShape::setEnableDebugDraw(bool enableDebugDraw)
48{
49 if (m_enableDebugDraw == enableDebugDraw)
50 return;
51
52 if (auto world = QPhysicsWorld::getWorld(this); world != nullptr && enableDebugDraw)
53 world->setHasIndividualDebugDraw();
54
55 m_enableDebugDraw = enableDebugDraw;
56 emit enableDebugDrawChanged(m_enableDebugDraw);
57}
58
59void QAbstractCollisionShape::handleScaleChange()
60{
61 auto newScale = sceneScale();
62 if (!qFuzzyCompare(newScale, m_prevScale)) {
63 m_prevScale = newScale;
64 m_scaleDirty = true;
65 emit needsRebuild(this); // TODO: remove signal argument?
66 }
67}
68
69QT_END_NAMESPACE
Combined button and popup list for selecting options.