8#include "PxRigidDynamic.h"
9#include "PxRigidActor.h"
19#define PHYSX_RELEASE(x) \
30 if (qobject_cast<const QPlaneShape *>(node) !=
nullptr) {
35 }
else if (
auto *hf = qobject_cast<const QHeightFieldShape *>(node)) {
53 physX->scene->removeActor(*
actor);
67 physX->scene->addActor(*
actor);
72 QHash<QQuick3DNode *, QMatrix4x4> & )
76 const float staticFriction = qtMaterial->staticFriction();
77 const float dynamicFriction = qtMaterial->dynamicFriction();
78 const float restitution = qtMaterial->restitution();
79 if (
material->getStaticFriction() != staticFriction)
80 material->setStaticFriction(staticFriction);
81 if (
material->getDynamicFriction() != dynamicFriction)
82 material->setDynamicFriction(dynamicFriction);
83 if (
material->getRestitution() != restitution)
84 material->setRestitution(restitution);
98 const auto &physXShapes =
shapes;
100 const int len = collisionShapes.size();
101 if (physXShapes.size() !=
len) {
105 for (
int i = 0;
i <
len;
i++) {
107 auto poseOld = physXShapes[
i]->getLocalPose();
131 actor = s_physx.physics->createRigidDynamic(trf);
141 return actor->getGlobalPose();
147 for (
auto *shape :
shapes) {
148 body->detachShape(*shape);
158 auto *geom = collisionShape->getPhysXGeometry();
163 auto physXShape = s_physx.physics->createShape(*geom, *
material);
166 physXShape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,
false);
167 physXShape->setFlag(physx::PxShapeFlag::eTRIGGER_SHAPE,
true);
171 physx::PxFilterData filterData;
174 physXShape->setSimulationFilterData(filterData);
177 shapes.push_back(physXShape);
179 body->attachShape(*physXShape);
193 for (
auto &physXShape :
shapes) {
194 physx::PxFilterData filterData;
197 physXShape->setSimulationFilterData(filterData);
QAbstractPhysicsNode * frontendNode
bool filtersDirty() const
QVector< physx::PxShape * > shapes
virtual void cleanup(QPhysXWorld *)
physx::PxMaterial * material
void setShapesDirty(bool dirty)
void setFiltersDirty(bool dirty)
virtual void createMaterial(QPhysXWorld *physX)
virtual bool useTriggerFlag()
const QVector< QAbstractCollisionShape * > & getCollisionShapesList() const
void markDirtyShapes() override
void buildShapes(QPhysXWorld *physX)
void rebuildDirtyShapes(QPhysicsWorld *world, QPhysXWorld *physX) override
void init(QPhysicsWorld *world, QPhysXWorld *physX) override
bool debugGeometryCapability() override
QPhysXActorBody(QAbstractPhysicsNode *frontEnd)
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
The QQuaternion class represents a quaternion consisting of a vector and scalar.
QQuaternion sceneRotation
The QVector3D class represents a vector or vertex in 3D space.
Q_ALWAYS_INLINE physx::PxVec3 toPhysXType(const QVector3D &qvec)
Q_ALWAYS_INLINE bool fuzzyEquals(const physx::PxTransform &a, const physx::PxTransform &b)
const QQuaternion kMinus90YawRotation
Q_ALWAYS_INLINE physx::PxTransform toPhysXTransform(const QVector3D &position, const QQuaternion &rotation)
Combined button and popup list for selecting options.
GLenum GLenum GLenum GLenum GLenum scale
static QT_BEGIN_NAMESPACE physx::PxTransform getPhysXLocalTransform(const QQuick3DNode *node)
static StaticPhysXObjects & getReference()