class IRigidbodyImplementation

Low-level interface for a rigidbody used by the Rigidbody component.

Should be implemented by the physics plugin to provide rigidbody functionality.

Public

Methods

~IRigidbodyImplementation

virtual ~IRigidbodyImplementation() = default

Move

virtual void Move(const Vector3 &position) = 0

Moves the rigidbody to a specific position.

This method will ensure physically correct movement, meaning the body will collide with other objects along the way.

Rotate

virtual void Rotate(const Quaternion &rotation) = 0

Rotates the rigidbody.

This method will ensure physically correct rotation, meaning the body will collide with other objects along the way.

SetMass

virtual void SetMass(float mass) = 0

Determines the mass of the object and all of its collider shapes.

Only relevant if RigidbodyFlag::AutoMass or RigidbodyFlag::AutoTensors is turned off. Value of zero means the object is immovable (but can be rotated).

SetIsKinematic

virtual void SetIsKinematic(bool kinematic) = 0

Determines if the body is kinematic.

Kinematic body will not move in response to external forces (for example gravity, or another object pushing it), essentially behaving like collider. Unlike a collider though, you can still move the object and have other dynamic objects respond correctly (meaning it will push other objects).

IsSleeping

virtual bool IsSleeping() const = 0

Checks if the body is sleeping.

Objects that aren't moved/rotated for a while are put to sleep to reduce load on the physics system.

Sleep

virtual void Sleep() = 0

Forces the object to sleep.

Useful if you know the object will not move in any significant way for a while.

WakeUp

virtual void WakeUp() = 0

Wakes an object up.

Useful if you modified properties of this object, and potentially surrounding objects which might result in the object being moved by physics (although the physics system will automatically wake the object up for majority of such cases).

SetSleepThreshold

virtual void SetSleepThreshold(float threshold) = 0

Determines a threshold of force and torque under which the object will be considered to be put to sleep.

SetUseGravity

virtual void SetUseGravity(bool gravity) = 0

Determines whether or not the rigidbody will have the global gravity force applied to it.

SetVelocity

virtual void SetVelocity(const Vector3 &velocity) = 0

Determines the linear velocity of the body.

GetVelocity

virtual Vector3 GetVelocity() const = 0

SetAngularVelocity

virtual void SetAngularVelocity(const Vector3 &velocity) = 0

Determines the angular velocity of the body.

GetAngularVelocity

virtual Vector3 GetAngularVelocity() const = 0

SetDrag

virtual void SetDrag(float drag) = 0

Determines the linear drag of the body.

Higher drag values means the object resists linear movement more.

SetAngularDrag

virtual void SetAngularDrag(float drag) = 0

Determines the angular drag of the body.

Higher drag values means the object resists angular movement more.

SetInertiaTensor

virtual void SetInertiaTensor(const Vector3 &tensor) = 0

Determines the inertia tensor in local mass space.

Inertia tensor determines how difficult is to rotate the object. Values of zero in the inertia tensor mean the object will be unable to rotate around a specific axis. Only relevant if RigidbodyFlag::AutoTensors is turned off.

GetInertiaTensor

virtual Vector3 GetInertiaTensor() const = 0

SetMaxAngularVelocity

virtual void SetMaxAngularVelocity(float velocity) = 0

Determines the maximum angular velocity of the rigidbody.

Velocity will be clamped to this value.

SetFlags

virtual void SetFlags(RigidbodyFlags flags) = 0

Flags that control the behaviour of the rigidbody.

AddForce

virtual void AddForce(const Vector3 &force, ForceMode mode = ForceMode::Force) = 0

Applies a force to the center of the mass of the rigidbody.

This will produce linear momentum.

force
Force to apply.
mode
Determines what is the type of .

AddTorque

virtual void AddTorque(const Vector3 &torque, ForceMode mode = ForceMode::Force) = 0

Applies a torque to the rigidbody.

This will produce angular momentum.

torque
Torque to apply.
mode
Determines what is the type of .

AddForceAtPoint

virtual void AddForceAtPoint(const Vector3 &force, const Vector3 &position, PointForceMode mode = PointForceMode::Force) = 0

Applies a force to a specific point on the rigidbody.

This will in most cases produce both linear and angular momentum.

force
Force to apply.
position
World position to apply the force at.
mode
Determines what is the type of .

GetVelocityAtPoint

virtual Vector3 GetVelocityAtPoint(const Vector3 &point) const = 0

Returns the total (linear + angular) velocity at a specific point.

point
Point in world space.

Returns: Total velocity of the point.

UpdateMassDistribution

virtual void UpdateMassDistribution(bool autoMassEnabled) = 0

Recalculates rigidbody's mass, inertia tensors and center of mass depending on the currently set child colliders.

This should be called whenever relevant child collider properties change (like mass or shape).

If automatic tensor calculation is turned off then this will do nothing. If automatic mass calculation is turned off then this will use the mass set directly on the body using SetMass().

SetTransform

virtual void SetTransform(const Vector3 &position, const Quaternion &rotation) = 0

Sets the transform of the low-level physics rigidbody object.

Unlike Move() and Rotate() this will not transform the body in a physically correct manner, but will instead "teleport" it immediately to the specified position and rotation.

GetTransform

virtual void GetTransform(Vector3 &outPosition, Quaternion &outRotation) = 0

Returns the transform that is currently assigned to the low-level physics rigidbody object.

This may be the transform you explicitly set via SetTransform(), or a value that has been calculated by physics simulation for kinematic rigidbodies.

SetCenterOfMass

virtual void SetCenterOfMass(const Vector3 &position, const Quaternion &rotation) = 0

Sets the rigidbody's center of mass transform.

Only relevant if RigibodyFlag::AutoTensors is turned off.

position
Position of the center of mass.
rotation
Rotation that determines orientation of the inertia tensor (rotation of the center of mass frame).

GetCenterOfMass

virtual void GetCenterOfMass(Vector3 &outPosition, Quaternion &outRotation) = 0

Gets the rigidbody's center of mass transform.

outPosition
Position of the center of mass.
outRotation
Rotation that determines orientation of the inertia tensor (rotation of the center of mass frame).

SetSolverIterationCounts

virtual void SetSolverIterationCounts(u32 positionCount, u32 velocityCount) = 0

Determines the number of iterations to use when solving for position and velocity.

Higher values can improve precision and numerical stability of the simulation.

AddToScene

virtual void AddToScene(PhysicsScene &scene) = 0

Adds the rigidbody to the physics scene.

RemoveFromScene

virtual void RemoveFromScene() = 0

Removes the rigidbody from the currently assigned physics scene.

AttachShape

virtual void AttachShape(const SPtr<ColliderShape> &shape) = 0

Assigns a new child shape to the rigidbody.

DetachShape

virtual void DetachShape(const SPtr<ColliderShape> &shape) = 0

Removes a shape that was previously attached to the rigidbody.