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 PxPvdTransport;
28class PxPvd;
29class PxFoundation;
30class PxDefaultCpuDispatcher;
31class PxCooking;
32class PxMaterial;
33}
34
36
37// The properties of a physics material. PhysX allows at most 64K materials, so instead of
38// creating one per node, all nodes needing the same properties share a single PxMaterial. This
39// means the materials must be treated as immutable: a node whose properties change is moved to
40// the material with the new properties instead.
42{
43 float staticFriction = 0.f;
44 float dynamicFriction = 0.f;
45 float restitution = 0.f;
46
47 // Properties that no material can have, since friction and restitution are never negative.
48 // Used by the nodes to tell that they have not picked up a material yet.
49 static constexpr PhysicsMaterialProperties none() { return { -1.f, -1.f, -1.f }; }
50
51 friend bool operator==(const PhysicsMaterialProperties &lhs,
52 const PhysicsMaterialProperties &rhs) noexcept
53 {
54 return lhs.staticFriction == rhs.staticFriction
56 && lhs.restitution == rhs.restitution;
57 }
58
59 friend size_t qHash(const PhysicsMaterialProperties &properties, size_t seed = 0) noexcept
60 {
61 return qHashMulti(seed, properties.staticFriction, properties.dynamicFriction,
62 properties.restitution);
63 }
64};
65
67{
68 physx::PxMaterial *material = nullptr;
69 int nodeCount = 0;
70};
71
73{
76 physx::PxFoundation *foundation = nullptr;
77 physx::PxPvd *pvd = nullptr;
78 physx::PxPvdTransport *transport = nullptr;
79 physx::PxPhysics *physics = nullptr;
80 physx::PxDefaultCpuDispatcher *dispatcher = nullptr;
81 physx::PxCooking *cooking = nullptr;
82
83 // The materials in use, one per distinct set of properties, and how many nodes use each.
84 // They belong to 'physics' and are destroyed together with it.
86
87 unsigned int foundationRefCount = 0;
88 bool foundationCreated = false;
89 bool physicsCreated = false;
90
92};
93
95
96#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)
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
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
physx::PxCooking * cooking
static StaticPhysXObjects & getReference()
physx::PxFoundation * foundation
QHash< PhysicsMaterialProperties, SharedPhysicsMaterial > materials
physx::PxPvdTransport * transport
physx::PxDefaultCpuDispatcher * dispatcher
physx::PxPhysics * physics