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// Qt-Security score:significant reason:default
4
6
7#include "PxPhysics.h"
8#include "PxRigidActor.h"
9#include "PxRigidStatic.h"
10
15
17
18QPhysXStaticBody::QPhysXStaticBody(QStaticRigidBody *frontEnd) : QPhysXRigidBody(frontEnd) { }
19
24
25void QPhysXStaticBody::sync(float deltaTime, QHash<QQuick3DNode *, QMatrix4x4> &transformCache)
26{
27 auto *staticBody = static_cast<QStaticRigidBody *>(frontendNode);
28 const physx::PxTransform poseNew = QPhysicsUtils::toPhysXTransform(staticBody->scenePosition(),
29 staticBody->sceneRotation());
30 const physx::PxTransform poseOld = actor->getGlobalPose();
31
32 // For performance we only update static objects if they have been moved
33 if (!QPhysicsUtils::fuzzyEquals(poseNew, poseOld))
34 actor->setGlobalPose(poseNew);
35
36 const bool disabledPrevious = actor->getActorFlags() & physx::PxActorFlag::eDISABLE_SIMULATION;
37 const bool disabled = !staticBody->simulationEnabled();
38 if (disabled != disabledPrevious) {
39 actor->setActorFlag(physx::PxActorFlag::eDISABLE_SIMULATION, disabled);
40 }
41
42 QPhysXActorBody::sync(deltaTime, transformCache);
43}
44
46{
48 const physx::PxTransform trf = QPhysicsUtils::toPhysXTransform(frontendNode->scenePosition(),
49 frontendNode->sceneRotation());
50 actor = s_physx.physics->createRigidStatic(trf);
51}
52
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()