Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qphysicsworld.cpp File Reference

(913a84160dc19725a8f68e9440f1359d63ece31a)

#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 "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 <QtQuick3D/private/qquick3dobject_p.h>
#include <QtQuick3D/private/qquick3dnode_p.h>
#include <QtQuick3D/private/qquick3dmodel_p.h>
#include <QtQuick3D/private/qquick3ddefaultmaterial_p.h>
#include <QtQuick3DUtils/private/qssgutils_p.h>
#include <QtEnvironmentVariables>
#include "qphysicsworld.moc"
+ Include dependency graph for qphysicsworld.cpp:

Go to the source code of this file.

Classes

class  SimulationWorker
 
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 QWorldManager worldManager = QWorldManager {}
 

Macro Definition Documentation

◆ PHYSX_ENABLE_PVD

#define PHYSX_ENABLE_PVD   0

Definition at line 32 of file qphysicsworld.cpp.

Function Documentation

◆ collectPhysicsNodes()

static void collectPhysicsNodes ( QQuick3DObject * node,
QList< QAbstractPhysicsNode * > & nodes )
static

Definition at line 890 of file qphysicsworld.cpp.

References child, and collectPhysicsNodes().

Referenced by collectPhysicsNodes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_LOGGING_CATEGORY()

QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY ( lcQuick3dPhysics ,
"qt.quick3d.physics"  )

\qmltype PhysicsWorld \inqmlmodule QtQuick3D.Physics

Since
6.4

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. This will reduce the risk of bodies going through other bodies at high velocities (also known as tunnelling). The default value is false.

Warning
Using trigger bodies with CCD enabled is not supported and can result in missing or false trigger reports.

\qmlproperty float 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 float 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 float 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.

See also
forceDebugDraw, scene

\qmlproperty float PhysicsWorld::minimumTimestep This property defines the minimum simulation timestep in milliseconds. The default value is 16.667 which corresponds to 60 frames per second.

Range: {[0, maximumTimestep]}

\qmlproperty float PhysicsWorld::maximumTimestep This property defines the maximum simulation timestep in milliseconds. The default value is 33.333 which corresponds to 30 frames per second.

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.

Note
Using the same scene node for several PhysicsWorld is unsupported.

\qmlsignal PhysicsWorld::frameDone(float timestep)

Since
6.5

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

Since
6.7

This property defines the number of threads used for the physical simulation. This is how the range of values are interpreted:

\table \header

  • Value
  • Range
  • Description \row
  • Negative
  • {[-inf, -1]}
  • Automatic thread count. The application will try to query the number of threads from the system. \row
  • Zero
  • {{0}}
  • No threading, simulation will run sequentially. \row
  • Positive
  • {[1, inf]}
  • Specific thread count. \endtable

The default value is {-1}, meaning automatic thread count.

Note
Once the scene has started running it is not possible to change the number of threads.

\qmlproperty bool PhysicsWorld::reportKinematicKinematicCollisions

Since
6.7

This property controls if collisions between pairs of {kinematic} dynamic rigid bodies will trigger a contact report.

The default value is {false}.

Note
Once the scene has started running it is not possible to change this setting.
See also
PhysicsWorld::reportStaticKinematicCollisions
DynamicRigidBody
PhysicsNode::bodyContact

\qmlproperty bool PhysicsWorld::reportStaticKinematicCollisions

Since
6.7

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}.

Note
Once the scene has started running it is not possible to change this setting.
See also
PhysicsWorld::reportKinematicKinematicCollisions
StaticRigidBody
DynamicRigidBody
PhysicsNode::bodyContact

Variable Documentation

◆ worldManager