1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QPHYSICSCOMMANDS_H
5#define QPHYSICSCOMMANDS_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
20#include <QtCore/QList>
21#include <QtGui/QVector3D>
22#include <QQuaternion>
23
24namespace physx {
25class PxRigidBody;
26}
27
28QT_BEGIN_NAMESPACE
29
30class QDynamicRigidBody;
31
32class QPhysicsCommand
33{
34public:
35 virtual ~QPhysicsCommand() = default;
36 virtual void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) = 0;
37};
38
39class QPhysicsCommandApplyCentralForce : public QPhysicsCommand
40{
41public:
42 QPhysicsCommandApplyCentralForce(const QVector3D &inForce);
43 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
44
45private:
46 QVector3D force;
47};
48
49class QPhysicsCommandApplyForce : public QPhysicsCommand
50{
51public:
52 QPhysicsCommandApplyForce(const QVector3D &inForce, const QVector3D &inPosition);
53 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
54
55private:
56 QVector3D force;
57 QVector3D position;
58};
59
60class QPhysicsCommandApplyTorque : public QPhysicsCommand
61{
62public:
63 QPhysicsCommandApplyTorque(const QVector3D &inTorque);
64 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
65
66private:
67 QVector3D torque;
68};
69
70class QPhysicsCommandApplyCentralImpulse : public QPhysicsCommand
71{
72public:
73 QPhysicsCommandApplyCentralImpulse(const QVector3D &inImpulse);
74 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
75
76private:
77 QVector3D impulse;
78};
79
80class QPhysicsCommandApplyImpulse : public QPhysicsCommand
81{
82public:
83 QPhysicsCommandApplyImpulse(const QVector3D &inImpulse, const QVector3D &inPosition);
84 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
85
86private:
87 QVector3D impulse;
88 QVector3D position;
89};
90
91class QPhysicsCommandApplyTorqueImpulse : public QPhysicsCommand
92{
93public:
94 QPhysicsCommandApplyTorqueImpulse(const QVector3D &inImpulse);
95 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
96
97private:
98 QVector3D impulse;
99};
100
101class QPhysicsCommandSetAngularVelocity : public QPhysicsCommand
102{
103public:
104 QPhysicsCommandSetAngularVelocity(const QVector3D &inAngularVelocity);
105 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
106
107private:
108 QVector3D angularVelocity;
109};
110
111class QPhysicsCommandSetLinearVelocity : public QPhysicsCommand
112{
113public:
114 QPhysicsCommandSetLinearVelocity(const QVector3D &inLinearVelocity);
115 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
116
117private:
118 QVector3D linearVelocity;
119};
120
121class QPhysicsCommandSetMass : public QPhysicsCommand
122{
123public:
124 QPhysicsCommandSetMass(float inMass);
125 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
126
127private:
128 float mass;
129};
130
131class QPhysicsCommandSetMassAndInertiaTensor : public QPhysicsCommand
132{
133public:
134 QPhysicsCommandSetMassAndInertiaTensor(float inMass, const QVector3D &inInertia);
135 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
136
137private:
138 float mass;
139 QVector3D inertia;
140};
141
142class QPhysicsCommandSetMassAndInertiaMatrix : public QPhysicsCommand
143{
144public:
145 QPhysicsCommandSetMassAndInertiaMatrix(float inMass, const QMatrix3x3 &inInertia);
146 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
147
148private:
149 float mass;
150 QMatrix3x3 inertia;
151};
152
153class QPhysicsCommandSetDensity : public QPhysicsCommand
154{
155public:
156 QPhysicsCommandSetDensity(float inDensity);
157 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
158
159private:
160 float density;
161};
162
163class QPhysicsCommandSetIsKinematic : public QPhysicsCommand
164{
165public:
166 QPhysicsCommandSetIsKinematic(bool inIsKinematic);
167 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
168
169private:
170 bool isKinematic;
171};
172
173class QPhysicsCommandSetGravityEnabled : public QPhysicsCommand
174{
175public:
176 QPhysicsCommandSetGravityEnabled(bool inGravityEnabled);
177 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
178
179private:
180 bool gravityEnabled;
181};
182
183class QPhysicsCommandReset : public QPhysicsCommand
184{
185public:
186 QPhysicsCommandReset(QVector3D inPosition, QVector3D inEulerRotation);
187 void execute(const QDynamicRigidBody &rigidBody, physx::PxRigidBody &body) override;
188
189private:
190 QVector3D position;
191 QVector3D eulerRotation;
192};
193
194QT_END_NAMESPACE
195
196#endif // QPHYSICSCOMMANDS_H
197

source code of qtquick3dphysics/src/quick3dphysics/qphysicscommands_p.h