CheeseEngine
A 2D Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
phys2d::RigidBodyComponent Struct Reference

#include <types.hpp>

Public Member Functions

 RigidBodyComponent ()=default
 default RigidBodyComponent constructor
 
 RigidBodyComponent (phys2d::BodyType bt)
 RigidBodyComponent c-tor that uses only BodyType parameter, other fields are set by default.
 
 RigidBodyComponent (BodyType bt, const glm::vec2 &linearVelocity, const glm::vec2 &force, float gravityScale, float angularVelocity, float torque, float mass, float inertia, float linearDamping, float angularDamping, float restitution, float friction)
 RigidBody c-tor, requires all fields to be customly set.
 

Public Attributes

BodyType bodyType = BodyType::Dynamic
 bodyType: Static, Kinematic or Dynamic
 
glm::vec2 linearVelocity {0.0f, 0.0f}
 velocity along some axis
 
glm::vec2 force {0.0f, 0.0f}
 force: two-dimensional vector
 
float gravityScale = rb_defaultGravityScale
 gravity scale, 1 by default
 
float angularVelocity = 0.0f
 angular velocity, in radians clockwise
 
float torque = 0.0f
 torque, in radians clockwise
 
float invMass
 inverted mass coefficient, used for calculating linear acceleration
 
float invInertia = rb_defaultInvInertia
 
float linearDamping = rb_defaultDamping
 linear damping of the object, from 0 to 1
 
float angularDamping = rb_defaultDamping
 angular damping of the object, from 0 to 1
 
float restitution = rb_defaultRestitution
 restitution of the object, 0.5 by default
 
float friction = rb_defaultFriction
 friction of the object, 0.2 by default
 

Constructor & Destructor Documentation

◆ RigidBodyComponent() [1/3]

phys2d::RigidBodyComponent::RigidBodyComponent ( )
default

default RigidBodyComponent constructor

◆ RigidBodyComponent() [2/3]

phys2d::RigidBodyComponent::RigidBodyComponent ( phys2d::BodyType  bt)

RigidBodyComponent c-tor that uses only BodyType parameter, other fields are set by default.

Parameters
btBodyType value, Static, Kinematic or Dynamic

◆ RigidBodyComponent() [3/3]

phys2d::RigidBodyComponent::RigidBodyComponent ( BodyType  bt,
const glm::vec2 &  linearVelocity,
const glm::vec2 &  force,
float  gravityScale,
float  angularVelocity,
float  torque,
float  mass,
float  inertia,
float  linearDamping,
float  angularDamping,
float  restitution,
float  friction 
)

RigidBody c-tor, requires all fields to be customly set.

Parameters
btBodyType of the object: Static/Kinematic/Dynamic
linearVelocityvelocity along some axis
forceforce: two-dimensional vector
gravityScalegravity scale, 1 by default
angularVelocityangular velocity, in radians clockwise
torquetorque, in radians, clockwise
massmass of the object
inertiainertia of the object, in radians, clockwise
linearDampingdamping, coefficient from 0 to 1
angularDampingangularDamping, coefficient from 0 to 1
restitiutionphysical restitution, 0.5 by default
frictionphysical friction, 0.2 by default

Member Data Documentation

◆ angularDamping

float phys2d::RigidBodyComponent::angularDamping = rb_defaultDamping

angular damping of the object, from 0 to 1

◆ angularVelocity

float phys2d::RigidBodyComponent::angularVelocity = 0.0f

angular velocity, in radians clockwise

◆ bodyType

BodyType phys2d::RigidBodyComponent::bodyType = BodyType::Dynamic

bodyType: Static, Kinematic or Dynamic

◆ force

glm::vec2 phys2d::RigidBodyComponent::force {0.0f, 0.0f}

force: two-dimensional vector

◆ friction

float phys2d::RigidBodyComponent::friction = rb_defaultFriction

friction of the object, 0.2 by default

◆ gravityScale

float phys2d::RigidBodyComponent::gravityScale = rb_defaultGravityScale

gravity scale, 1 by default

◆ invInertia

float phys2d::RigidBodyComponent::invInertia = rb_defaultInvInertia

inverted inertia, used for calculating angular acceleration, in radians clockwise

◆ invMass

float phys2d::RigidBodyComponent::invMass
Initial value:
=
constexpr float rb_defaultInvMass
Definition types.hpp:21

inverted mass coefficient, used for calculating linear acceleration

◆ linearDamping

float phys2d::RigidBodyComponent::linearDamping = rb_defaultDamping

linear damping of the object, from 0 to 1

◆ linearVelocity

glm::vec2 phys2d::RigidBodyComponent::linearVelocity {0.0f, 0.0f}

velocity along some axis

◆ restitution

float phys2d::RigidBodyComponent::restitution = rb_defaultRestitution

restitution of the object, 0.5 by default

◆ torque

float phys2d::RigidBodyComponent::torque = 0.0f

torque, in radians clockwise


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