Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcharactercontroller_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef CHARACTERCONTROLLER_H
5#define CHARACTERCONTROLLER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
19#include <QtQuick3DPhysics/private/qabstractphysicsbody_p.h>
20#include <QtQml/QQmlEngine>
21#include <QVector3D>
22
24
26{
28 Q_PROPERTY(QVector3D movement READ movement WRITE setMovement NOTIFY movementChanged)
29 Q_PROPERTY(QVector3D gravity READ gravity WRITE setGravity NOTIFY gravityChanged)
30 Q_PROPERTY(bool midAirControl READ midAirControl WRITE setMidAirControl NOTIFY
31 midAirControlChanged)
32 Q_PROPERTY(Collisions collisions READ collisions NOTIFY collisionsChanged)
33 Q_PROPERTY(bool enableShapeHitCallback READ enableShapeHitCallback WRITE
34 setEnableShapeHitCallback NOTIFY enableShapeHitCallbackChanged)
35 QML_NAMED_ELEMENT(CharacterController)
36public:
38
39 enum class Collision {
40 None = 0,
41 Side = 1 << 0,
42 Up = 1 << 1,
43 Down = 1 << 2,
44 };
45 Q_DECLARE_FLAGS(Collisions, Collision)
46 Q_FLAG(Collisions)
47
48 const QVector3D &movement() const;
49 void setMovement(const QVector3D &newMovement);
50 const QVector3D &gravity() const;
51 void setGravity(const QVector3D &newGravity);
52 QVector3D getDisplacement(float deltaTime);
53 bool getTeleport(QVector3D &position);
54
55 bool midAirControl() const;
56 void setMidAirControl(bool newMidAirControl);
57
58 Q_INVOKABLE void teleport(const QVector3D &position);
59
60 const Collisions &collisions() const;
61 void setCollisions(const Collisions &newCollisions);
63
64 Q_REVISION(6, 6) bool enableShapeHitCallback() const;
65 Q_REVISION(6, 6) void setEnableShapeHitCallback(bool newEnableShapeHitCallback);
66
68 void movementChanged();
69 void gravityChanged();
70
71 void midAirControlChanged();
72
73 void collisionsChanged();
74 void enableShapeHitCallbackChanged();
75 void shapeHit(QAbstractPhysicsNode *body, const QVector3D &position, const QVector3D &impulse,
76 const QVector3D &normal);
77
79 QVector3D m_movement;
80 QVector3D m_gravity;
81 bool m_midAirControl = true;
82
83 QVector3D m_freeFallVelocity; // actual speed at start of next tick, if free fall
84
85 QVector3D m_teleportPosition;
86 bool m_teleport = false;
87 Collisions m_collisions;
88 bool m_enableShapeHitCallback = false;
89};
90
92
94
95#endif // CHARACTERCONTROLLER_H
virtual QAbstractPhysXNode * createPhysXBackend()=0
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
@ None
Definition qhash.cpp:531
#define QML_NAMED_ELEMENT(NAME)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_FLAG(x)
#define Q_INVOKABLE
#define signals
#define Q_QUICK3DPHYSICS_EXPORT