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 "Common/Math.hpp"
4#include "EngineCore/ECS/Entity.hpp"
5#include "EngineCore/Reflection/ComponentReflection.hpp"
6#include "ColliderComponent.hpp"
7
8class btRigidBody;
9
10namespace Grindstone {
11 struct TransformComponent;
12 class WorldContextSet;
13
14 namespace Physics {
15 struct ColliderComponent;
16
17 void SetupRigidBodyComponent(Grindstone::WorldContextSet&, entt::entity);
18
19 struct RigidBodyComponent {
20 RigidBodyComponent() = default;
21 RigidBodyComponent(float mass, ColliderComponent* colliderComponent);
22 RigidBodyComponent Clone(Grindstone::WorldContextSet& cxt, entt::entity newEntityId) const;
23
24 void SetCollisionShape(ColliderComponent* colliderComponent);
25 void SetFriction(float friction);
26 void SetRestitution(float restitution);
27 void SetDamping(float linear, float rotational);
28
29 void ApplyForce(Math::Float3 pos, Math::Float3 force);
30 void ApplyCentralForce(Math::Float3 force);
31 void ApplyImpulse(Math::Float3 pos, Math::Float3 force);
32 void ApplyCentralImpulse(Math::Float3 force);
33
34 float GetMass() const;
35 float GetFriction() const;
36 float GetRestitution() const;
37 float GetDampingLinear() const;
38 float GetDampingRotational() const;
39 private:
40 float mass = 0.0f;
41 float friction = 0.0f;
42 float restitution = 0.0f;
43 float dampingLinear = 0.0f;
44 float dampingRotational = 0.0f;
45 public:
46 Grindstone::UniquePtr<btRigidBody> rigidBody = nullptr;
48
49 REFLECT("RigidBody")
50 };
51
52 void SetupRigidBodyComponentWithCollider(
54 RigidBodyComponent* rigidBodyComponent,
55 TransformComponent* transformComponent,
56 ColliderComponent* colliderComponent
57 );
58 }
59}
Definition TransformComponent.cs:7
Definition UniquePtr.hpp:7
Definition WorldContextSet.hpp:11
Definition FloatVectors.cs:108
Definition ColliderComponent.hpp:14
Definition RigidBodyComponent.hpp:19