Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qphysxstaticbody.cpp
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
5
6#include "PxPhysics.h"
7#include "PxRigidActor.h"
8#include "PxRigidStatic.h"
9
10#include "qphysicsutils_p.h"
11#include "qphysicsworld_p.h"
12#include "qstaticrigidbody_p.h"
14
16
18
23
24void QPhysXStaticBody::sync(float deltaTime, QHash<QQuick3DNode *, QMatrix4x4> &transformCache)
25{
26 auto *staticBody = static_cast<QStaticRigidBody *>(frontendNode);
27 const physx::PxTransform poseNew = QPhysicsUtils::toPhysXTransform(staticBody->scenePosition(),
28 staticBody->sceneRotation());
29 const physx::PxTransform poseOld = actor->getGlobalPose();
30
31 // For performance we only update static objects if they have been moved
32 if (!QPhysicsUtils::fuzzyEquals(poseNew, poseOld))
33 actor->setGlobalPose(poseNew);
34
35 const bool disabledPrevious = actor->getActorFlags() & physx::PxActorFlag::eDISABLE_SIMULATION;
36 const bool disabled = !staticBody->simulationEnabled();
37 if (disabled != disabledPrevious) {
38 actor->setActorFlag(physx::PxActorFlag::eDISABLE_SIMULATION, disabled);
39 }
40
41 QPhysXActorBody::sync(deltaTime, transformCache);
42}
43
45{
46 auto &s_physx = StaticPhysXObjects::getReference();
47 const physx::PxTransform trf = QPhysicsUtils::toPhysXTransform(frontendNode->scenePosition(),
49 actor = s_physx.physics->createRigidStatic(trf);
50}
51
QAbstractPhysicsNode * frontendNode
physx::PxRigidActor * actor
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
QPhysXStaticBody(QStaticRigidBody *frontEnd)
void createActor(QPhysXWorld *physX) override
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
DebugDrawBodyType getDebugDrawBodyType() override
QVector3D scenePosition
QQuaternion sceneRotation
Q_ALWAYS_INLINE bool fuzzyEquals(const physx::PxTransform &a, const physx::PxTransform &b)
Q_ALWAYS_INLINE physx::PxTransform toPhysXTransform(const QVector3D &position, const QQuaternion &rotation)
Combined button and popup list for selecting options.
DebugDrawBodyType
#define disabled
static StaticPhysXObjects & getReference()