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
qstaticphysxobjects_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 STATICPHYSXOBJECTS_H
6#define STATICPHYSXOBJECTS_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 "qtconfigmacros.h"
20
21#include <QtCore/qhash.h>
22
23#include "extensions/PxDefaultAllocator.h"
24#include "extensions/PxDefaultErrorCallback.h"
25
26namespace physx {
27class PxFoundation;
28class PxPhysics;
29class PxDefaultCpuDispatcher;
30class PxMaterial;
31}
32
34
35// The properties of a physics material. PhysX allows at most 64K materials, so instead of
36// creating one per node, all nodes needing the same properties share a single PxMaterial. This
37// means the materials must be treated as immutable: a node whose properties change is moved to
38// the material with the new properties instead.
40{
41 float staticFriction = 0.f;
42 float dynamicFriction = 0.f;
43 float restitution = 0.f;
44
45 // Properties that no material can have, since friction and restitution are never negative.
46 // Used by the nodes to tell that they have not picked up a material yet.
47 static constexpr PhysicsMaterialProperties none() { return { -1.f, -1.f, -1.f }; }
48
49 friend bool operator==(const PhysicsMaterialProperties &lhs,
50 const PhysicsMaterialProperties &rhs) noexcept
51 {
52 return lhs.staticFriction == rhs.staticFriction
54 && lhs.restitution == rhs.restitution;
55 }
56
57 friend size_t qHash(const PhysicsMaterialProperties &properties, size_t seed = 0) noexcept
58 {
59 return qHashMulti(seed, properties.staticFriction, properties.dynamicFriction,
60 properties.restitution);
61 }
62};
63
65{
66 physx::PxMaterial *material = nullptr;
67 int nodeCount = 0;
68};
69
71{
74 physx::PxFoundation *foundation = nullptr;
75 physx::PxPhysics *physics = nullptr;
76 physx::PxDefaultCpuDispatcher *dispatcher = nullptr;
77
78 // The materials in use, one per distinct set of properties, and how many nodes use each.
79 // They belong to 'physics' and are destroyed together with it.
81
82 unsigned int foundationRefCount = 0;
83 bool foundationCreated = false;
84 bool physicsCreated = false;
85
87};
88
90
91#endif
virtual void updateDefaultDensity(float density)
virtual void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache)=0
QAbstractPhysicsNode * frontendNode
QVector< physx::PxShape * > shapes
virtual void cleanup(QPhysXWorld *)
physx::PxMaterial * material
virtual void rebuildDirtyShapes(QPhysicsWorld *, QPhysXWorld *)
PhysicsMaterialProperties materialProperties
void setShapesDirty(bool dirty)
virtual bool debugGeometryCapability()
virtual physx::PxTransform getGlobalPose()
virtual void init(QPhysicsWorld *world, QPhysXWorld *physX)=0
virtual void markDirtyShapes()
virtual DebugDrawBodyType getDebugDrawBodyType()
virtual QPhysicsMaterial * qtMaterial() const
void setFiltersDirty(bool dirty)
virtual void detachFrontend()
bool cleanupIfRemoved(QPhysXWorld *physX)
virtual bool useTriggerFlag()
void markDirtyShapes() override
void buildShapes(QPhysXWorld *physX)
void rebuildDirtyShapes(QPhysicsWorld *world, QPhysXWorld *physX) override
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
void detachFrontend() override
bool debugGeometryCapability() override
void cleanup(QPhysXWorld *physX) override
physx::PxRigidActor * actor
virtual void createActor(QPhysXWorld *physX)
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
void updateFilters() override
physx::PxTransform getGlobalPose() override
physx::PxD6Motion::Enum toPxEnum(QD6Joint::Motion val)
Definition qd6joint.cpp:286
DebugDrawBodyType
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
friend bool operator==(const PhysicsMaterialProperties &lhs, const PhysicsMaterialProperties &rhs) noexcept
friend size_t qHash(const PhysicsMaterialProperties &properties, size_t seed=0) noexcept
static constexpr PhysicsMaterialProperties none()
physx::PxMaterial * material
physx::PxDefaultErrorCallback defaultErrorCallback
physx::PxDefaultAllocator defaultAllocatorCallback
static StaticPhysXObjects & getReference()
physx::PxFoundation * foundation
QHash< PhysicsMaterialProperties, SharedPhysicsMaterial > materials
physx::PxDefaultCpuDispatcher * dispatcher
physx::PxPhysics * physics