Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
5
#
include
"qphysxstaticbody_p.h"
6
7
#
include
"PxPhysics.h"
8
#
include
"PxRigidActor.h"
9
#
include
"PxRigidStatic.h"
10
11
#
include
"qphysicsutils_p.h"
12
#
include
"qphysicsworld_p.h"
13
#
include
"qstaticrigidbody_p.h"
14
#
include
"qstaticphysxobjects_p.h"
15
16
QT_BEGIN_NAMESPACE
17
18
QPhysXStaticBody
::
QPhysXStaticBody
(QStaticRigidBody *frontEnd) :
QPhysXRigidBody
(frontEnd) { }
19
20
DebugDrawBodyType
QPhysXStaticBody
::
getDebugDrawBodyType
()
21
{
22
return
DebugDrawBodyType
::
Static
;
23
}
24
25
void
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
48
void
QPhysXStaticBody
::
createActor
(
QPhysXWorld
*
/*physX*/
)
49
{
50
auto
&s_physx =
StaticPhysXObjects
::
getReference
(
)
;
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
60
QT_END_NAMESPACE
QPhysXRigidBody
Definition
qphysxrigidbody_p.h:29
QPhysXStaticBody
Definition
qphysxstaticbody_p.h:26
QPhysXStaticBody::QPhysXStaticBody
QPhysXStaticBody(QStaticRigidBody *frontEnd)
Definition
qphysxstaticbody.cpp:18
QPhysXStaticBody::createActor
void createActor(QPhysXWorld *physX) override
Definition
qphysxstaticbody.cpp:48
QPhysXStaticBody::sync
void sync(float deltaTime, QHash< QQuick3DNode *, QMatrix4x4 > &transformCache) override
Definition
qphysxstaticbody.cpp:25
QPhysXStaticBody::getDebugDrawBodyType
DebugDrawBodyType getDebugDrawBodyType() override
Definition
qphysxstaticbody.cpp:20
QPhysXWorld
Definition
qphysxworld_p.h:33
physx
Definition
qphysxactorbody_p.h:22
DebugDrawBodyType
DebugDrawBodyType
Definition
qabstractphysxnode_p.h:42
DebugDrawBodyType::Static
@ Static
Definition
qabstractphysxnode_p.h:43
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
Definition
qtconfigmacros.h:161
QT_END_NAMESPACE
#define QT_END_NAMESPACE
Definition
qtconfigmacros.h:162
StaticPhysXObjects
Definition
qstaticphysxobjects_p.h:71
StaticPhysXObjects::getReference
static StaticPhysXObjects & getReference()
Definition
qstaticphysxobjects.cpp:14
qtquick3dphysics
src
quick3dphysics
physxnode
qphysxstaticbody.cpp
Generated on
for Qt by
1.18.0