Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
CHARACTERCONTROLLER_H
6
#
define
CHARACTERCONTROLLER_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtQuick3DPhysics
/
qtquick3dphysicsglobal
.
h
>
20
#
include
<
QtQuick3DPhysics
/
private
/
qabstractphysicsbody_p
.
h
>
21
#
include
<
QtQml
/
QQmlEngine
>
22
#
include
<
QVector3D
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
Q_QUICK3DPHYSICS_EXPORT
QCharacterController
:
public
QAbstractPhysicsBody
27
{
28
Q_OBJECT
29
Q_PROPERTY(QVector3D movement READ movement WRITE setMovement NOTIFY movementChanged)
30
Q_PROPERTY(QVector3D gravity READ gravity WRITE setGravity NOTIFY gravityChanged)
31
Q_PROPERTY(
bool
midAirControl READ midAirControl WRITE setMidAirControl NOTIFY
32
midAirControlChanged)
33
Q_PROPERTY(Collisions collisions READ collisions NOTIFY collisionsChanged)
34
Q_PROPERTY(
bool
enableShapeHitCallback READ enableShapeHitCallback WRITE
35
setEnableShapeHitCallback NOTIFY enableShapeHitCallbackChanged)
36
QML_NAMED_ELEMENT(CharacterController)
37
public
:
38
QCharacterController();
39
40
enum
class
Collision {
41
None = 0,
42
Side = 1 << 0,
43
Up = 1 << 1,
44
Down = 1 << 2,
45
};
46
Q_DECLARE_FLAGS(Collisions, Collision)
47
Q_FLAG(Collisions)
48
49
const
QVector3D &movement()
const
;
50
void
setMovement(
const
QVector3D &newMovement);
51
const
QVector3D &gravity()
const
;
52
void
setGravity(
const
QVector3D &newGravity);
53
QVector3D getDisplacement(
float
deltaTime);
54
bool
getTeleport(QVector3D &position);
55
56
bool
midAirControl()
const
;
57
void
setMidAirControl(
bool
newMidAirControl);
58
59
Q_INVOKABLE
void
teleport(
const
QVector3D &position);
60
61
const
Collisions &collisions()
const
;
62
void
setCollisions(
const
Collisions &newCollisions);
63
QAbstractPhysXNode *createPhysXBackend() final;
64
65
Q_REVISION(6, 6)
bool
enableShapeHitCallback()
const
;
66
Q_REVISION(6, 6)
void
setEnableShapeHitCallback(
bool
newEnableShapeHitCallback);
67
68
signals:
69
void
movementChanged();
70
void
gravityChanged();
71
72
void
midAirControlChanged();
73
74
void
collisionsChanged();
75
void
enableShapeHitCallbackChanged();
76
void
shapeHit(QAbstractPhysicsNode *body,
const
QVector3D &position,
const
QVector3D &impulse,
77
const
QVector3D &normal);
78
79
private
:
80
QVector3D m_movement;
81
QVector3D m_gravity;
82
bool
m_midAirControl =
true
;
83
84
QVector3D m_freeFallVelocity;
// actual speed at start of next tick, if free fall
85
86
QVector3D m_teleportPosition;
87
bool
m_teleport =
false
;
88
Collisions m_collisions;
89
bool
m_enableShapeHitCallback =
false
;
90
};
91
92
Q_DECLARE_OPERATORS_FOR_FLAGS(QCharacterController::Collisions)
93
94
QT_END_NAMESPACE
95
96
#
endif
// CHARACTERCONTROLLER_H
QAbstractPhysXNode
Definition
qabstractphysxnode_p.h:58
QAbstractPhysXNode::cleanup
virtual void cleanup(QPhysXWorld *)
Definition
qabstractphysxnode.cpp:118
QAbstractPhysXNode::updateMaterial
bool updateMaterial()
Definition
qabstractphysxnode.cpp:66
QAbstractPhysXNode::detachFrontend
virtual void detachFrontend()
Definition
qabstractphysxnode.cpp:167
QCapsuleShape
Definition
qcapsuleshape_p.h:30
QCharacterController
Definition
qcharactercontroller_p.h:27
QPhysXCharacterController
Definition
qphysxcharactercontroller_p.h:32
QPhysXCharacterController::QPhysXCharacterController
QPhysXCharacterController(QCharacterController *frontEnd)
Definition
qphysxcharactercontroller.cpp:62
QPhysXCharacterController::debugGeometryCapability
bool debugGeometryCapability() override
Definition
qphysxcharactercontroller.cpp:229
QPhysXCharacterController::qtMaterial
QPhysicsMaterial * qtMaterial() const override
Definition
qphysxcharactercontroller.cpp:224
QPhysXCharacterController::detachFrontend
void detachFrontend() override
Definition
qphysxcharactercontroller.cpp:239
QPhysXCharacterController::getDebugDrawBodyType
DebugDrawBodyType getDebugDrawBodyType() override
Definition
qphysxcharactercontroller.cpp:234
QPhysXCharacterController::init
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
Definition
qphysxcharactercontroller.cpp:75
QPhysXCharacterController::cleanup
void cleanup(QPhysXWorld *physX) override
Definition
qphysxcharactercontroller.cpp:67
QPhysXCharacterController::sync
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
Definition
qphysxcharactercontroller.cpp:136
QPhysXWorld
Definition
qphysxworld_p.h:33
physx
Definition
qphysxactorbody_p.h:22
PHYSX_RELEASE
#define PHYSX_RELEASE(x)
Definition
qabstractphysxnode.cpp:15
DebugDrawBodyType
DebugDrawBodyType
Definition
qabstractphysxnode_p.h:42
DebugDrawBodyType::Character
@ Character
Definition
qabstractphysxnode_p.h:47
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
Definition
qtconfigmacros.h:161
QT_END_NAMESPACE
#define QT_END_NAMESPACE
Definition
qtconfigmacros.h:162
qtquick3dphysics
src
quick3dphysics
qcharactercontroller_p.h
Generated on
for Qt by
1.18.0