Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
RigidBodyComponent.hpp
1#pragma once
2
3#include <bullet/btBulletDynamicsCommon.h>
4
5#include "Common/Math.hpp"
6#include "EngineCore/ECS/Entity.hpp"
7#include "EngineCore/Reflection/ComponentReflection.hpp"
8#include "ColliderComponent.hpp"
9
10class btRigidBody;
11
12namespace Grindstone {
13 struct TransformComponent;
14 class WorldContextSet;
15
16 namespace Physics {
17 struct ColliderComponent;
18
19 struct RigidBodyComponent {
20 RigidBodyComponent() = default;
21 RigidBodyComponent(float mass, ColliderComponent* colliderComponent);
22
23 static void Construct(Grindstone::WorldContextSet&, entt::entity);
24 RigidBodyComponent Clone(Grindstone::WorldContextSet& cxt, entt::entity newEntityId) const;
25
26 void SetCollisionShape(ColliderComponent* colliderComponent);
27 void SetFriction(float friction);
28 void SetRestitution(float restitution);
29 void SetDamping(float linear, float rotational);
30
31 void ApplyForce(Math::Float3 pos, Math::Float3 force);
32 void ApplyCentralForce(Math::Float3 force);
33 void ApplyImpulse(Math::Float3 pos, Math::Float3 force);
34 void ApplyCentralImpulse(Math::Float3 force);
35
36 float GetMass() const;
37 float GetFriction() const;
38 float GetRestitution() const;
39 float GetDampingLinear() const;
40 float GetDampingRotational() const;
41 private:
42 float mass = 0.0f;
43 float friction = 0.0f;
44 float restitution = 0.0f;
45 float dampingLinear = 0.0f;
46 float dampingRotational = 0.0f;
47 public:
48 Grindstone::UniquePtr<btRigidBody> rigidBody = nullptr;
50
51 REFLECT("RigidBody")
52 };
53
54 void SetupRigidBodyComponentWithCollider(
56 RigidBodyComponent* rigidBodyComponent,
57 TransformComponent* transformComponent,
58 ColliderComponent* colliderComponent
59 );
60 }
61}
Definition UniquePtr.hpp:7
Definition WorldContextSet.hpp:11
Definition PhysicsLayer.hpp:6
Definition ArchiveContentFile.hpp:8
Definition FloatVectors.cs:119
Definition ColliderComponent.hpp:14
Definition RigidBodyComponent.hpp:19
Definition TransformComponent.hpp:12