![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include "qphysicsworld_p.h"#include "physxnode/qabstractphysxnode_p.h"#include "physxnode/qphysxworld_p.h"#include "qabstractphysicsnode_p.h"#include "qdebugdrawhelper_p.h"#include "qphysicsutils_p.h"#include "joints/qjoint_p.h"#include "qstaticphysxobjects_p.h"#include "qboxshape_p.h"#include "qsphereshape_p.h"#include "qconvexmeshshape_p.h"#include "qtrianglemeshshape_p.h"#include "qcharactercontroller_p.h"#include "qcapsuleshape_p.h"#include "qplaneshape_p.h"#include "qheightfieldshape_p.h"#include "PxPhysicsAPI.h"#include "cooking/PxCooking.h"#include <QtQuick/private/qquickframeanimation_p.h>#include <QtQuick3D/private/qquick3dobject_p.h>#include <QtQuick3D/private/qquick3dnode_p.h>#include <QtQuick3D/private/qquick3dmodel_p.h>#include <QtQuick3D/private/qquick3dprincipledmaterial_p.h>#include <QtQuick3DUtils/private/qssgutils_p.h>#include <QtGui/qquaternion.h>#include <QtEnvironmentVariables>#include "qphysicsworld.moc"Go to the source code of this file.
Classes | |
| class | FrameAnimator |
| struct | QWorldManager |
Macros | |
| #define | PHYSX_ENABLE_PVD 0 |
Functions | |
| QT_BEGIN_NAMESPACE | Q_LOGGING_CATEGORY (lcQuick3dPhysics, "qt.quick3d.physics") |
| \qmltype PhysicsWorld \inqmlmodule QtQuick3D.Physics | |
| static void | collectPhysicsNodes (QQuick3DObject *node, QList< QAbstractPhysicsNode * > &nodes) |
Variables | |
| static const QString | qtPhysicsTimingsFile = qEnvironmentVariable("QT_PHYSICS_TIMINGS_FILE") |
| static QWorldManager | worldManager = QWorldManager {} |
| #define PHYSX_ENABLE_PVD 0 |
Definition at line 37 of file qphysicsworld.cpp.
|
static |
Definition at line 1001 of file qphysicsworld.cpp.
| QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY | ( | lcQuick3dPhysics | , |
| "qt.quick3d.physics" | ) |
\qmltype PhysicsWorld \inqmlmodule QtQuick3D.Physics
Controls the physics simulation.
The PhysicsWorld type controls the physics simulation. This node is used to create an instance of the physics world as well as define its properties. There can only be one physics world. All collision nodes in the qml will get added automatically to the physics world.
\qmlproperty vector3d PhysicsWorld::gravity This property defines the gravity vector of the physics world. The default value is (0, -981, 0). Set the value to {Qt.vector3d(0, -9.81, 0)} if your unit of measurement is meters and you are simulating Earth gravity.
\qmlproperty bool PhysicsWorld::running This property starts or stops the physical simulation. The default value is true.
\qmlproperty bool PhysicsWorld::forceDebugDraw This property enables debug drawing of all active shapes in the physics world. The default value is false.
\qmlproperty bool PhysicsWorld::enableCCD
This property enables continuous collision detection globally for every dynamic body in the scene that does not explicitly set its own \l DynamicRigidBody::ccd mode. It reduces the risk of fast-moving bodies passing through geometry at high velocities (also known as tunnelling).
For non-kinematic dynamic bodies, enabling this property uses sweep-based CCD. For kinematic bodies, it automatically uses speculative CCD, as sweep-based CCD is not supported for them.
Continuous collision detection can also be configured per body via \l DynamicRigidBody::ccd, which avoids paying its performance cost for objects that do not need it.
\default false
\qmlproperty real PhysicsWorld::typicalLength This property defines the approximate size of objects in the simulation. This is used to estimate certain length-related tolerances. Objects much smaller or much larger than this size may not behave properly. The default value is 100.
Range: {[0, inf]}
\qmlproperty real PhysicsWorld::typicalSpeed This property defines the typical magnitude of velocities of objects in simulation. This is used to estimate whether a contact should be treated as bouncing or resting based on its impact velocity, and a kinetic energy threshold below which the simulation may put objects to sleep.
For normal physical environments, a good choice is the approximate speed of an object falling under gravity for one second. The default value is 1000.
Range: {[0, inf]}
\qmlproperty real PhysicsWorld::defaultDensity This property defines the default density of dynamic objects, measured in kilograms per cubic unit. This is equal to the weight of a cube with side 1.
The default value is 0.001, corresponding to 1 g/cm³: the density of water. If your unit of measurement is meters, a good value would be 1000. Note that only positive values are allowed.
Range: {(0, inf]}
\qmlproperty Node PhysicsWorld::viewport This property defines the viewport where debug components will be drawn if \l{forceDebugDraw} is enabled. If unset the \l{scene} node will be used.
\qmlproperty real PhysicsWorld::minimumTimestep This property defines the minimum simulation timestep in milliseconds. The default value is {1}.
Range: {[0, maximumTimestep]}
\qmlproperty real PhysicsWorld::maximumTimestep This property defines the maximum simulation timestep in milliseconds. The default value is {33.333}.
Range: {[0, inf]}
\qmlproperty Node PhysicsWorld::scene
This property defines the top-most Node that contains all the nodes of the physical simulation. All physics objects that are an ancestor of this node will be seen as part of this PhysicsWorld.
\qmlsignal PhysicsWorld::frameDone(float timestep)
This signal is emitted when the physical simulation is done simulating a frame. The timestep parameter is how long in milliseconds the timestep was in the simulation.
\qmlproperty int PhysicsWorld::numThreads
This property defines the number of threads used for the physical simulation. This is how the range of values are interpreted:
\table \header
{[-inf, -1]} {{0}} {[1, inf]} The default value is {-1}, meaning automatic thread count.
\qmlproperty bool PhysicsWorld::reportKinematicKinematicCollisions
This property controls if collisions between pairs of {kinematic} dynamic rigid bodies will trigger a contact report.
The default value is {false}.
\qmlproperty bool PhysicsWorld::reportStaticKinematicCollisions
This property controls if collisions between a static rigid body and a {kinematic} dynamic rigid body will trigger a contact report.
The default value is {false}.
\qmlproperty QueryStructure PhysicsWorld::staticQueryStructure
The spatial pruning structure type used to accelerate scene queries (raycasts, sweeps, overlaps - used in CharacterController and a {kinematic} dynamic rigid body) against static actors in the physics scene. It has no effect on rigid-body contact/collision detection during simulation.
The following values are available:
\value PhysicsWorld.StaticTree Uses a pre-baked static AABB tree. Offers maximum scene query performance with zero per-frame management overhead. Best for fully static, immutable scenes. Inserting or removing objects at runtime causes heavy scene rebuilds and frame spikes. \value PhysicsWorld.DynamicTree Uses a dynamic self-balancing AABB tree. Allows fast, local runtime insertion (logarithmic time) and removal of static objects without freezing the frame. Ideal for seamless open-world streaming where static chunks are loaded dynamically.
\default PhysicsWorld.DynamicTree
\qmlproperty QueryStructure PhysicsWorld::dynamicQueryStructure
The spatial pruning structure type used to accelerate scene queries (raycasts, sweeps, overlaps - used in CharacterController and a {kinematic} dynamic rigid body) against dynamic actors in the physics scene. It has no effect on rigid-body contact/collision detection during simulation.
The following values are available:
\value PhysicsWorld.NoStructure Disables the scene query acceleration structure for dynamic actors. Eliminates CPU overhead for tree maintenance when objects move, spawn, or are destroyed. Scene queries will fall back to a linear search. Ideal when scene queries are not needed for dynamic objects. \value PhysicsWorld.StaticTree Uses a static AABB tree. Offers faster scene queries for dynamic actors, but updating the tree when objects move or spawn is very expensive. Best when dynamic actors rarely move or spend most of their time sleeping. \value PhysicsWorld.DynamicTree Uses a dynamic self-balancing AABB tree. Allows fast, local runtime insertion (logarithmic time), movement, and removal of dynamic objects without freezing the frame. Ideal for active scenes with frequently moving or spawning dynamic actors.
\default PhysicsWorld.DynamicTree
Controls the physics simulation.
The PhysicsWorld type controls the physics simulation. This node is used to create an instance of the physics world as well as define its properties. There can only be one physics world. All collision nodes in the qml will get added automatically to the physics world.
\qmlproperty vector3d PhysicsWorld::gravity This property defines the gravity vector of the physics world. The default value is (0, -981, 0). Set the value to {Qt.vector3d(0, -9.81, 0)} if your unit of measurement is meters and you are simulating Earth gravity.
\qmlproperty bool PhysicsWorld::running This property starts or stops the physical simulation. The default value is true.
\qmlproperty bool PhysicsWorld::forceDebugDraw This property enables debug drawing of all active shapes in the physics world. The default value is false.
\qmlproperty bool PhysicsWorld::enableCCD
This property enables continuous collision detection globally for every dynamic body in the scene that does not explicitly set its own \l DynamicRigidBody::ccd mode. It reduces the risk of fast-moving bodies passing through geometry at high velocities (also known as tunnelling).
For non-kinematic dynamic bodies, enabling this property uses sweep-based CCD. For kinematic bodies, it automatically uses speculative CCD, as sweep-based CCD is not supported for them.
Continuous collision detection can also be configured per body via \l DynamicRigidBody::ccd, which avoids paying its performance cost for objects that do not need it.
\default false
\qmlproperty real PhysicsWorld::typicalLength This property defines the approximate size of objects in the simulation. This is used to estimate certain length-related tolerances. Objects much smaller or much larger than this size may not behave properly. The default value is 100.
Range: {[0, inf]}
\qmlproperty real PhysicsWorld::typicalSpeed This property defines the typical magnitude of velocities of objects in simulation. This is used to estimate whether a contact should be treated as bouncing or resting based on its impact velocity, and a kinetic energy threshold below which the simulation may put objects to sleep.
For normal physical environments, a good choice is the approximate speed of an object falling under gravity for one second. The default value is 1000.
Range: {[0, inf]}
\qmlproperty real PhysicsWorld::defaultDensity This property defines the default density of dynamic objects, measured in kilograms per cubic unit. This is equal to the weight of a cube with side 1.
The default value is 0.001, corresponding to 1 g/cm³: the density of water. If your unit of measurement is meters, a good value would be 1000. Note that only positive values are allowed.
Range: {(0, inf]}
\qmlproperty Node PhysicsWorld::viewport This property defines the viewport where debug components will be drawn if \l{forceDebugDraw} is enabled. If unset the \l{scene} node will be used.
\qmlproperty real PhysicsWorld::minimumTimestep This property defines the minimum simulation timestep in milliseconds. The default value is {1}.
Range: {[0, maximumTimestep]}
\qmlproperty real PhysicsWorld::maximumTimestep This property defines the maximum simulation timestep in milliseconds. The default value is {33.333}.
Range: {[0, inf]}
\qmlproperty Node PhysicsWorld::scene
This property defines the top-most Node that contains all the nodes of the physical simulation. All physics objects that are an ancestor of this node will be seen as part of this PhysicsWorld.
\qmlsignal PhysicsWorld::frameDone(float timestep)
This signal is emitted when the physical simulation is done simulating a frame. The timestep parameter is how long in milliseconds the timestep was in the simulation.
\qmlproperty int PhysicsWorld::numThreads
This property defines the number of threads used for the physical simulation. This is how the range of values are interpreted:
\table \header
{[-inf, -1]} {{0}} {[1, inf]} The default value is {-1}, meaning automatic thread count.
\qmlproperty bool PhysicsWorld::reportKinematicKinematicCollisions
This property controls if collisions between pairs of {kinematic} dynamic rigid bodies will trigger a contact report.
The default value is {false}.
\qmlproperty bool PhysicsWorld::reportStaticKinematicCollisions
This property controls if collisions between a static rigid body and a {kinematic} dynamic rigid body will trigger a contact report.
The default value is {false}.
\qmlproperty QueryStructure PhysicsWorld::staticQueryStructure
The spatial pruning structure type used to accelerate scene queries (raycasts, sweeps, overlaps - used in CharacterController and a {kinematic} dynamic rigid body) against static actors in the physics scene. It has no effect on rigid-body contact/collision detection during simulation.
The following values are available:
\value PhysicsWorld.StaticTree Uses a pre-baked static AABB tree. Offers maximum scene query performance with zero per-frame management overhead. Best for fully static, immutable scenes. Inserting or removing objects at runtime causes heavy scene rebuilds and frame spikes. \value PhysicsWorld.DynamicTree Uses a dynamic self-balancing AABB tree. Allows fast, local runtime insertion (logarithmic time) and removal of static objects without freezing the frame. Ideal for seamless open-world streaming where static chunks are loaded dynamically.
\default PhysicsWorld.DynamicTree
\qmlproperty QueryStructure PhysicsWorld::dynamicQueryStructure
The spatial pruning structure type used to accelerate scene queries (raycasts, sweeps, overlaps - used in CharacterController and a {kinematic} dynamic rigid body) against dynamic actors in the physics scene. It has no effect on rigid-body contact/collision detection during simulation.
The following values are available:
\value PhysicsWorld.NoStructure Disables the scene query acceleration structure for dynamic actors. Eliminates CPU overhead for tree maintenance when objects move, spawn, or are destroyed. Scene queries will fall back to a linear search. Ideal when scene queries are not needed for dynamic objects. \value PhysicsWorld.StaticTree Uses a static AABB tree. Offers faster scene queries for dynamic actors, but updating the tree when objects move or spawn is very expensive. Best when dynamic actors rarely move or spend most of their time sleeping. \value PhysicsWorld.DynamicTree Uses a dynamic self-balancing AABB tree. Allows fast, local runtime insertion (logarithmic time), movement, and removal of dynamic objects without freezing the frame. Ideal for active scenes with frequently moving or spawning dynamic actors.
\default PhysicsWorld.DynamicTree
|
static |
Definition at line 310 of file qphysicsworld.cpp.
|
static |
Definition at line 417 of file qphysicsworld.cpp.