Photon Quantum 3.0.0

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Quantum.PhysicsBody3D Struct Reference

Adds physics motion to an entity with a PhysicsCollider3D driven by the built-in physics systems. You can customize how the movement of the physics body will works by changing the Mass, GravityScale or Drag. A Kinematic body will not have linear and angular velocities integrated, but those values are still perceived and taken into account when resolving the collision with other dynamic bodies. More...

Inheritance diagram for Quantum.PhysicsBody3D:
Quantum.IComponent

Public Types

enum  ConfigFlags : byte
 The flags to set up how the physics body will behave in the physics systems. More...
 

Public Member Functions

void AddAngularImpulse (FPVector3 amount)
 Accumulates a given amount of angular impulse, to be integrated into angular velocity on the next Physics Update. The amount of delta angular velocity produced by the angular impulse is inversely proportional to the body inertia on each axis. More...
 
void AddForce (FPVector3 amount, FPVector3? relativePoint=null)
 Increases the Force value with the amount vector. The force is integrated into delta velocity on the next Physics Update. The amount of delta-velocity produced by the accumulated force is directly proportional do the delta-time and inversely proportional do the Mass of the body. If the impulse is applied at a relativePoint that is different than zero, it will also generate Torque. More...
 
void AddForceAtPosition (FPVector3 force, FPVector3 position, Transform3D *transform)
 Applies the given force to the body at a given position in world space. More...
 
void AddForceAtPosition (FPVector3 force, FPVector3 position, Transform3D transform)
 
void AddLinearImpulse (FPVector3 amount, FPVector3? relativePoint=null)
 Applies the given amount of linear impulse to the body. The amount of delta-velocity generated by the impulse is inversely proportional to the mass of the body. If the impulse is applied in a relativePoint that is different than zero, it will also generate a delta angular velocity. More...
 
void AddLinearImpulseAtPosition (FPVector3 impulse, FPVector3 position, Transform3D *transform)
 Applies the given linear impulse to the body at a given position in world space. More...
 
void AddLinearImpulseAtPosition (FPVector3 impulse, FPVector3 position, Transform3D transform)
 
void AddTorque (FPVector3 amount)
 Accumulates a given amount of torque, to be integrated into angular velocity on the next Physics Update. The amount of delta angular velocity produced by the angular impulse is directly proportional to the Update delta-time and inversely proportional to the body inertia on each axis. More...
 
void ClearForce ()
 Clears all the accumulated forces in this body. More...
 
void ClearTorque ()
 Clears all the accumulated torques in this body. More...
 
FPVector3 GetInertiaTensor ()
 Returns the inertia tensor based on the stored inverse inertia tensor values. More...
 
FPVector3 GetPointVelocity (FPVector3 point, Transform3D *bodyTransform)
 Computes the velocity of the physics body at a given point defined in world space. More...
 
FPVector3 GetRelativePointVelocity (FPVector3 point, Transform3D *bodyTransform)
 Computes the velocity of the physics body at a given point defined on its local space. More...
 
void InitBody (FP bodyMass, FP drag, FP angularDrag, ConfigFlags bodyConfig, RotationFreezeFlags rotationFlags, FPVector3? centerOfMass=null, NullableFP gravityScale=default)
 Initializes a PhysicsBody3D component with custom settings. More...
 
void ResetCenterOfMass (FrameBase f, EntityRef entity)
 Resets the CenterOfMass of physics body component to the the shape centroid of a PhysicsCollider3D component attached to the entity . More...
 
void ResetInertia (FrameBase frame, EntityRef entity)
 Resets the inertia on this physics body component based on its mass and the shape of a PhysicsCollider3D component on the entity . More...
 
void SetInertiaTensor (FPVector3 inertiaTensor)
 Sets the inertia tensor value. The greater the value of inertia on a given axis, the more torque will be required to achieve the same delta angular velocity on that axis. This value is automatically recomputed when the value of mass is set. More...
 
void Sleep ()
 Puts an enabled physics body into a sleeping state. More...
 
void WakeUp ()
 Wakes up a sleeping physics body and resets the accumulated time within sleeping thresholds. More...
 

Static Public Member Functions

static PhysicsBody3D CreateDynamic (FP mass, FP drag, FP angularDrag, Boolean allowSleeping, Boolean awakenByKinematics=false, RotationFreezeFlags flags=default, FPVector3? centerOfMass=null, NullableFP gravityScale=default)
 Creates a dynamic PhysicsBody3D. More...
 
static PhysicsBody3D CreateDynamic (FP mass, FP drag=default, FP angularDrag=default, ConfigFlags bodyConfig=ConfigFlags.Default, RotationFreezeFlags flags=default, FPVector3? centerOfMass=null, NullableFP gravityScale=default)
 
static PhysicsBody3D CreateKinematic ()
 Creates a kinematic PhysicsBody3D. The mass, drag and angular drag are not considered in kinematic interactions and have 0 as value. More...
 
static void Serialize (void *ptr, FrameSerializer serializer)
 Serializes a PhysicsBody3D into a FrameSerializer. More...
 

Public Attributes

FPVector3 AngularVelocity
 The rate of change of physics rotation in radians per second for each axis. More...
 
RotationFreezeFlags RotationFreeze
 The RotationFreezeFlags that blocks the rotation in the specified axes. More...
 
FPVector3 Velocity
 The rate of change of physics body position in units per second. More...
 

Static Public Attributes

const int SIZE = FirstVector3 + FPVector3.SIZE * 4
 The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. More...
 

Properties

Boolean? AllowSleeping [get, set]
 
FP AngularDrag [get, set]
 
FPVector3 CenterOfMass [get, set]
 
FP Drag [get, set]
 
Boolean? Enabled [get, set]
 
FPVector3 Force [get]
 The accumulated forces by the AddForce method that will be integrated into delta velocity on the next Physics Update. This value is reset after the integration. More...
 
FP GravityScale [get, set]
 
Boolean? IsAwakenedByKinematics [get, set]
 
Boolean? IsKinematic [get, set]
 
Boolean IsSleeping [get]
 
FP?? Mass [get, set]
 
FPMassInverse [get, set]
 
FPVector3 Torque [get]
 The accumulated torques by the AddTorque method that will be integrated into delta angular velocity on the next Physics Update. This value is reset after the integration. More...
 
Boolean? UseContinuousCollisionDetection [get, set]
 

Detailed Description

Adds physics motion to an entity with a PhysicsCollider3D driven by the built-in physics systems. You can customize how the movement of the physics body will works by changing the Mass, GravityScale or Drag. A Kinematic body will not have linear and angular velocities integrated, but those values are still perceived and taken into account when resolving the collision with other dynamic bodies.

Member Function Documentation

◆ GetInertiaTensor()

FPVector3 Quantum.PhysicsBody3D.GetInertiaTensor ( )
inline

Returns the inertia tensor based on the stored inverse inertia tensor values.

◆ SetInertiaTensor()

void Quantum.PhysicsBody3D.SetInertiaTensor ( FPVector3  inertiaTensor)
inline

Sets the inertia tensor value. The greater the value of inertia on a given axis, the more torque will be required to achieve the same delta angular velocity on that axis. This value is automatically recomputed when the value of mass is set.

◆ CreateKinematic()

static PhysicsBody3D Quantum.PhysicsBody3D.CreateKinematic ( )
inlinestatic

Creates a kinematic PhysicsBody3D. The mass, drag and angular drag are not considered in kinematic interactions and have 0 as value.

Returns
A PhysicsBody3D component.

◆ ResetInertia()

void Quantum.PhysicsBody3D.ResetInertia ( FrameBase  frame,
EntityRef  entity 
)
inline

Resets the inertia on this physics body component based on its mass and the shape of a PhysicsCollider3D component on the entity .

This is called automatically when a PhysicsBody3D component is added to an entity, unless the body ConfigFlags.ResetInertiaOnAdded flag is not set. The body's center of mass affects the computation of the inertia, so consider calling ResetCenterOfMass before resetting the inertia, specially if the collider shape has changed. More info on the online docs here.

Parameters
frameCurrent frame instance in use.
entityThe entity from which the collider shape will be retrieved, necessary for computing the inertia.

◆ ResetCenterOfMass()

void Quantum.PhysicsBody3D.ResetCenterOfMass ( FrameBase  f,
EntityRef  entity 
)
inline

Resets the CenterOfMass of physics body component to the the shape centroid of a PhysicsCollider3D component attached to the entity .

This is called automatically when a PhysicsBody3D component is added to an entity, unless the body ConfigFlags.ResetCenterOfMassOnAdded flag is not set. When changing the collider shape in runtime, consider resetting the center of mass and inertia of the attached physics body, in this order. More info on the online docs here.

Parameters
fCurrent frame instance in use.
entityThe entity from which the collider component and shape will be retrieved.

◆ AddLinearImpulse()

void Quantum.PhysicsBody3D.AddLinearImpulse ( FPVector3  amount,
FPVector3 relativePoint = null 
)
inline

Applies the given amount of linear impulse to the body. The amount of delta-velocity generated by the impulse is inversely proportional to the mass of the body. If the impulse is applied in a relativePoint that is different than zero, it will also generate a delta angular velocity.

Parameters
amountThe impulse vector to be applied.
relativePointA vector in world space that represents the distance from the center of mass to the point where the impulse is being applied.
See also
AddLinearImpulseAtPosition(Photon.Deterministic.FPVector3,Photon.Deterministic.FPVector3,Quantum.Transform3D)

◆ AddLinearImpulseAtPosition()

void Quantum.PhysicsBody3D.AddLinearImpulseAtPosition ( FPVector3  impulse,
FPVector3  position,
Transform3D transform 
)
inline

Applies the given linear impulse to the body at a given position in world space.

Parameters
impulseThe impulse vector to be applied.
positionThe point in world space where the impulse is being applied. This position should be withing the collider shape in order to prevent unrealistic behavior.
transformThe current transform of the entity that owns this physics body.

◆ AddAngularImpulse()

void Quantum.PhysicsBody3D.AddAngularImpulse ( FPVector3  amount)
inline

Accumulates a given amount of angular impulse, to be integrated into angular velocity on the next Physics Update. The amount of delta angular velocity produced by the angular impulse is inversely proportional to the body inertia on each axis.

Parameters
amountThe angular impulse to be accumulated.

◆ ClearForce()

void Quantum.PhysicsBody3D.ClearForce ( )
inline

Clears all the accumulated forces in this body.

◆ AddForce()

void Quantum.PhysicsBody3D.AddForce ( FPVector3  amount,
FPVector3 relativePoint = null 
)
inline

Increases the Force value with the amount vector. The force is integrated into delta velocity on the next Physics Update. The amount of delta-velocity produced by the accumulated force is directly proportional do the delta-time and inversely proportional do the Mass of the body. If the impulse is applied at a relativePoint that is different than zero, it will also generate Torque.

Parameters
amountThe force vector in world coordinates.
relativePointA vector in world space that represents the distance from the center of mass to the point where the impulse is being applied.
See also
AddTorque

◆ AddForceAtPosition()

void Quantum.PhysicsBody3D.AddForceAtPosition ( FPVector3  force,
FPVector3  position,
Transform3D transform 
)
inline

Applies the given force to the body at a given position in world space.

Parameters
forceThe force vector to be applied.
positionThe point in world space where the impulse is being applied. This position should be withing the collider shape in order to prevent unrealistic behavior.
transformThe current transform of the entity that owns this physics body.

◆ ClearTorque()

void Quantum.PhysicsBody3D.ClearTorque ( )
inline

Clears all the accumulated torques in this body.

◆ AddTorque()

void Quantum.PhysicsBody3D.AddTorque ( FPVector3  amount)
inline

Accumulates a given amount of torque, to be integrated into angular velocity on the next Physics Update. The amount of delta angular velocity produced by the angular impulse is directly proportional to the Update delta-time and inversely proportional to the body inertia on each axis.

Parameters
amountThe torque to be accumulated.

◆ GetPointVelocity()

FPVector3 Quantum.PhysicsBody3D.GetPointVelocity ( FPVector3  point,
Transform3D bodyTransform 
)
inline

Computes the velocity of the physics body at a given point defined in world space.

Parameters
pointThe point where the velocity will be computed at, in world space.
bodyTransformThe transform component of the entity to which this physics body belongs.
Returns
A 3D vector representing the computed velocity, also in world space.

◆ GetRelativePointVelocity()

FPVector3 Quantum.PhysicsBody3D.GetRelativePointVelocity ( FPVector3  point,
Transform3D bodyTransform 
)
inline

Computes the velocity of the physics body at a given point defined on its local space.

Parameters
pointThe point where the velocity will be computed at, in local space.
bodyTransformThe transform component of the entity to which this physics body belongs.
Returns
A 3D vector representing the computed velocity, in world space.

◆ WakeUp()

void Quantum.PhysicsBody3D.WakeUp ( )
inline

Wakes up a sleeping physics body and resets the accumulated time within sleeping thresholds.

◆ Sleep()

void Quantum.PhysicsBody3D.Sleep ( )
inline

Puts an enabled physics body into a sleeping state.

If set during a physics collision callback, the body might be awakened by the solver if the collision is not ignored.

◆ Serialize()

static void Quantum.PhysicsBody3D.Serialize ( void *  ptr,
FrameSerializer  serializer 
)
inlinestatic

Serializes a PhysicsBody3D into a FrameSerializer.

Parameters
ptrThe pointer to the PhysicsBody3D.
serializerThe FrameSerializer instance into which the struct will be serialized.

Member Data Documentation

◆ SIZE

const int Quantum.PhysicsBody3D.SIZE = FirstVector3 + FPVector3.SIZE * 4
static

The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.

◆ RotationFreeze

RotationFreezeFlags Quantum.PhysicsBody3D.RotationFreeze

The RotationFreezeFlags that blocks the rotation in the specified axes.

◆ Velocity

FPVector3 Quantum.PhysicsBody3D.Velocity

The rate of change of physics body position in units per second.

◆ AngularVelocity

FPVector3 Quantum.PhysicsBody3D.AngularVelocity

The rate of change of physics rotation in radians per second for each axis.

Property Documentation

◆ Force

FPVector3 Quantum.PhysicsBody3D.Force
get

The accumulated forces by the AddForce method that will be integrated into delta velocity on the next Physics Update. This value is reset after the integration.

◆ Torque

FPVector3 Quantum.PhysicsBody3D.Torque
get

The accumulated torques by the AddTorque method that will be integrated into delta angular velocity on the next Physics Update. This value is reset after the integration.