NcEngine
nc::RigidBody Class Reference

Component managing physics simulation properties. More...

#include <RigidBody.h>

Public Member Functions

Special Member Functions
 RigidBody (Entity self, const Shape &shape=Shape::MakeBox(), const RigidBodyInfo &info=RigidBodyInfo{})
 
 RigidBody (RigidBody &&other) noexcept
 
RigidBodyoperator= (RigidBody &&other) noexcept
 
 RigidBody (RigidBody &)=delete
 
RigidBodyoperator= (RigidBody &)=delete
 
General Functions
auto GetEntity () const -> Entity
 
auto GetInfo () const -> const RigidBodyInfo &
 
BodyType Functions
Note
BodyType::Static is forced if attached to a static Entity.
auto GetBodyType () const -> BodyType
 
void SetBodyType (BodyType type, bool wake=true)
 
DegreeOfFreedom Functions
Note
Not supported on static bodies.
auto GetDegreesOfFreedom () const -> DegreeOfFreedom::Type
 
void SetDegreesOfFreedom (DegreeOfFreedom::Type dof)
 
Shape Functions
auto GetShape () const -> const Shape &
 
void SetShape (const Shape &shape, const Vector3 &transformScale, bool wake=true)
 
Simulation Properties
auto IsAwake () const -> bool
 
void SetAwakeState (bool wake)
 
auto GetFriction () const -> float
 
void SetFriction (float friction)
 
auto GetRestitution () const -> float
 
void SetRestitution (float restitution)
 
auto GetGravityMultiplier () const -> float
 
void SetGravityMultiplier (float factor)
 
Simulation Properties (Dynamic Only)
Note
Not supported on static bodies.
auto GetMass () const -> float
 
void SetMass (float mass)
 
auto GetLinearDamping () const -> float
 
void SetLinearDamping (float damping)
 
auto GetAngularDamping () const -> float
 
void SetAngularDamping (float damping)
 
RigidBodyFlags Functions
auto IsTrigger () const -> bool
 
void SetTrigger (bool value)
 
auto UseContinuousDetection () const -> bool
 
void UseContinuousDetection (bool value)
 
auto ScalesWithTransform () const -> bool
 
auto IgnoreTransformScaling () const -> bool
 
void IgnoreTransformScaling (bool value)
 
auto DisableSleeping () const -> bool
 
void DisableSleeping (bool value)
 
Velocity Functions
auto GetLinearVelocity () const -> Vector3
 
void SetLinearVelocity (const Vector3 &velocity)
 
void AddLinearVelocity (const Vector3 &velocity)
 
auto GetAngularVelocity () const -> Vector3
 
void SetAngularVelocity (const Vector3 &velocity)
 
void SetVelocities (const Vector3 &linearVelocity, const Vector3 &angularVelocity)
 
void AddVelocities (const Vector3 &linearVelocity, const Vector3 &angularVelocity)
 
Force/Impulse Functions
Note
Requires BodyType::Dynamic
void AddForce (const Vector3 &force)
 
void AddForceAt (const Vector3 &force, const Vector3 &point)
 
void AddTorque (const Vector3 &torque)
 
void AddImpulse (const Vector3 &impulse)
 
void AddImpulseAt (const Vector3 &impulse, const Vector3 &point)
 
void AddAngularImpulse (const Vector3 &impulse)
 
Constraint Functions
auto AddConstraint (const ConstraintInfo &createInfo, const RigidBody &otherBody) -> Constraint &
 Add a Constraint between the RigidBody and another.
 
auto AddConstraint (const ConstraintInfo &createInfo) -> Constraint &
 Add a Constraint between the RigidBody and the world.
 
void RemoveConstraint (ConstraintId constraintId)
 Remove a constraint from the RigidBody.
 
auto GetConstraints () -> std::span< Constraint >
 View all of the constraints attached to the RigidBody.
 
auto GetConstraints () const -> std::span< const Constraint >
 Add a Constraint between the RigidBody and another.
 
Vehicle Functions
Note
A RigidBody may only have one Vehicle. Currently, Vehicles are not serialized with the RigidBody.
auto AddVehicle (VehicleInfo createInfo) -> Vehicle &
 
void RemoveVehicle ()
 
auto GetVehicle () -> Vehicle *
 
auto GetVehicle () const -> const Vehicle *
 
Simulated Body Functions
Note
Prefer using simulated body functions over the Transform equivalents for entities with a RigidBody.

Simulated body functions synchronize updating of properties shared between a Transform and RigidBody. They should only be used when strictly necessary, as directly modifying these properties can cause undesirable behavior in the simulation (e.g. when repositioning one body inside of another).

void SetSimulatedBodyPosition (Transform &transform, const Vector3 &position, bool wake=true)
 Set the position of an object's Transform and RigidBody.
 
void SetSimulatedBodyRotation (Transform &transform, const Quaternion &rotation, bool wake=true)
 Set the rotation of an object's Transform and RigidBody.
 
auto SetSimulatedBodyScale (Transform &transform, const Vector3 &scale, bool wake=true) -> Vector3
 Set the scale of an object's Transform and RigidBody. More...
 

Detailed Description

Component managing physics simulation properties.

Member Function Documentation

◆ SetSimulatedBodyScale()

auto nc::RigidBody::SetSimulatedBodyScale ( Transform transform,
const Vector3 scale,
bool  wake = true 
) -> Vector3

Set the scale of an object's Transform and RigidBody.

The actual applied scale is returned and may differ from the requested value, depending on scaling requirements of the RigidBody Shape. If the body does not have ScaleWithTransform set, only the Transform will be modified.


The documentation for this class was generated from the following file: