Stowy Physics Engine 0.1.0
Loading...
Searching...
No Matches
Rigidbody.hpp
Go to the documentation of this file.
1
11#pragma once
12
14
15namespace stw
16{
21{
22 Rigidbody();
23
28 [[nodiscard]] const Vector2& GravityForce() const;
33 void SetGravityForce(const Vector2& gravityForce);
34
39 [[nodiscard]] const Vector2& Force() const;
44 void ApplyForce(const Vector2& addedForce);
49 void SetForce(const Vector2& force);
50
55 [[nodiscard]] const Vector2& Velocity() const;
60 void SetVelocity(const Vector2& velocity);
61
68 [[nodiscard]] float Mass() const;
73 [[nodiscard]] float InvMass() const;
78 void SetMass(float mass);
79
84 [[nodiscard]] bool TakesGravity() const;
89 void SetTakesGravity(bool takesGravity);
90
95 [[nodiscard]] float StaticFriction() const;
100 void SetStaticFriction(float staticFriction);
101
106 [[nodiscard]] float DynamicFriction() const;
111 void SetDynamicFriction(float dynamicFriction);
112
117 [[nodiscard]] float Restitution() const;
122 void SetRestitution(float restitution);
123
124private:
125 Vector2 _gravityForce;
126 Vector2 _force;
127 Vector2 _velocity;
128
129 float _invMass{};
130 bool _takesGravity{};
131
132 float _staticFriction{};
133 float _dynamicFriction{};
134 float _restitution{};
135};
136}
Contains the CollisionBody struct.
A body that can receive collisions.
Definition CollisionBody.hpp:26
Definition BroadPhaseGrid.hpp:18
A Rigidbody that has dynamics.
Definition Rigidbody.hpp:21
bool TakesGravity() const
Gets a boolean indicating whether this body takes gravity.
Definition Rigidbody.cpp:73
float Mass() const
Computes the mass of this body. Only the inverted mass is stored, so it's computed as 1 / InvMass();.
Definition Rigidbody.cpp:47
float Restitution() const
Gets the restitution of this body. Can be seen as the "Bounciness".
Definition Rigidbody.cpp:107
void SetStaticFriction(float staticFriction)
Sets the static friction of this body.
Definition Rigidbody.cpp:92
float StaticFriction() const
Gets the static friction of this body.
Definition Rigidbody.cpp:87
void SetForce(const Vector2 &force)
Sets the force of this body.
Definition Rigidbody.cpp:32
void SetTakesGravity(bool takesGravity)
Sets a boolean indicating whether this body takes gravity.
Definition Rigidbody.cpp:78
void SetGravityForce(const Vector2 &gravityForce)
Sets the gravity force.
Definition Rigidbody.cpp:17
float InvMass() const
Returns 1 / Mass of this body.
Definition Rigidbody.cpp:52
const Vector2 & Force() const
Gets the force on this body.
Definition Rigidbody.cpp:22
float DynamicFriction() const
Gets the dynamic friction of this body.
Definition Rigidbody.cpp:97
const Vector2 & Velocity() const
Gets the velocity of this body.
Definition Rigidbody.cpp:37
Rigidbody()
Definition Rigidbody.cpp:5
const Vector2 & GravityForce() const
Gets the force of the gravity on this body.
Definition Rigidbody.cpp:12
void SetMass(float mass)
Sets the mass of this body.
Definition Rigidbody.cpp:57
void SetRestitution(float restitution)
Sets the restitution of this body. Can be seen as the "Bounciness".
Definition Rigidbody.cpp:112
void ApplyForce(const Vector2 &addedForce)
Adds force to this body.
Definition Rigidbody.cpp:27
void SetVelocity(const Vector2 &velocity)
Sets the velocity of this body.
Definition Rigidbody.cpp:42
void SetDynamicFriction(float dynamicFriction)
Sets the dynamic friction of this body.
Definition Rigidbody.cpp:102
A struct representing a 2D Vector.
Definition Vector2.hpp:21