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
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
14
16
17QPhysXStaticBody::QPhysXStaticBody(QStaticRigidBody *frontEnd) : QPhysXRigidBody(frontEnd) { }
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{
47 const physx::PxTransform trf = QPhysicsUtils::toPhysXTransform(frontendNode->scenePosition(),
48 frontendNode->sceneRotation());
49 actor = s_physx.physics->createRigidStatic(trf);
50}
51
physx::PxRigidActor * actor
QPhysXStaticBody(QStaticRigidBody *frontEnd)
void createActor(QPhysXWorld *physX) override
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
DebugDrawBodyType getDebugDrawBodyType() override
DebugDrawBodyType
#define QT_BEGIN_NAMESPACE
#define QT_END_NAMESPACE
static StaticPhysXObjects & getReference()
physx::PxPhysics * physics