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 if (!poseNew.isSane()) {
33 qWarning() << "StaticRigidBody: position/rotation is not finite, keeping previous pose.";
34 } else if (!QPhysicsUtils::fuzzyEquals(poseNew, poseOld)) {
35 // For performance we only update static objects if they have been moved
36 actor->setGlobalPose(poseNew);
37 }
38
39 const bool disabledPrevious = actor->getActorFlags() & physx::PxActorFlag::eDISABLE_SIMULATION;
40 const bool disabled = !staticBody->simulationEnabled();
41 if (disabled != disabledPrevious) {
42 actor->setActorFlag(physx::PxActorFlag::eDISABLE_SIMULATION, disabled);
43 }
44
45 QPhysXActorBody::sync(deltaTime, transformCache);
46}
47
49{
51 physx::PxTransform trf = QPhysicsUtils::toPhysXTransform(frontendNode->scenePosition(),
52 frontendNode->sceneRotation());
53 if (!trf.isSane()) {
54 qWarning() << "PhysicsNode: position/rotation is not finite, using identity instead.";
55 trf = physx::PxTransform(physx::PxIdentity);
56 }
57 actor = s_physx.physics->createRigidStatic(trf);
58}
59
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()