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
qphysxgravityfield_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 PHYSXGRAVITYFIELD_H
6#define PHYSXGRAVITYFIELD_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 "physxnode/qphysxactorbody_p.h"
20#include "qfilterdata_p.h"
22
23#include <QtCore/QPointer>
24
25#include <optional>
26
28
29class QAbstractPhysicsNode;
30class QGravityField;
31
33{
34public:
35 QPhysXGravityField(QGravityField *frontEnd);
36 void init(QPhysicsWorld *world, QPhysXWorld *physX) override;
37 void sync(float deltaTime, QHash<QQuick3DNode *, QMatrix4x4> &transformCache) override;
38 bool useTriggerFlag() override { return true; }
40
41 // The gravity of a field without shapes, for the world to apply to the
42 // bodies of the scene.
44 {
47 // Whether the bodies it acts on are to be woken.
48 bool wake = false;
49 };
50
51 // Called by the world each frame, before the bodies are synced. Wakes the
52 // bodies queued for it, and appends to `staleFilters` the filter of the
53 // field as it acted on the whole scene, if it no longer does, so that the
54 // world wakes what it let through. A field with shapes then applies its
55 // gravity to the bodies inside them; one without returns its gravity.
56 std::optional<SceneGravity> applyGravity(QList<QFilterData> &staleFilters);
57
58 // Called as the field is destroyed: hands to its backend what the world
59 // is to wake as the backend is deregistered, which is what the field last
60 // acted on.
61 static void fieldDestroyed(QGravityField *field);
62
65
66private:
67 // What the field last acted on: the whole scene through this filter, or
68 // the bodies inside its shapes.
69 bool m_applied = false;
70 bool m_sceneWide = false;
71 QFilterData m_filterData;
72};
73
75
76#endif // PHYSXGRAVITYFIELD_H
static QAbstractPhysXNode * backendOf(const QAbstractPhysicsNode *node)
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
QList< QPointer< QAbstractPhysicsNode > > wakesOnRemoval
std::optional< SceneGravity > applyGravity(QList< QFilterData > &staleFilters)
QPhysXGravityField(QGravityField *frontEnd)
DebugDrawBodyType getDebugDrawBodyType() override
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
bool useTriggerFlag() override
std::optional< QFilterData > staleFilterOnRemoval
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
static void fieldDestroyed(QGravityField *field)
void apply(const QPhysicsGravity &gravity, QPhysicsGravity::Target target, QAbstractPhysicsNode *node, QAbstractPhysXNode *backend, bool wake)
Q_ALWAYS_INLINE bool fuzzyEquals(const physx::PxTransform &a, const physx::PxTransform &b)
PxTransformT< float > PxTransform
DebugDrawBodyType
static bool operator!=(const QFilterData &a, const QFilterData &b)
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE