-
Notifications
You must be signed in to change notification settings - Fork 0
/
RigidBody.h
70 lines (60 loc) · 1.26 KB
/
RigidBody.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <vector>
#include "Common/MathTypes.h"
#include "PhysicalShapes/PhysicalShape.h"
struct PhysicalProps
{
real mass;
real moment;
};
struct InversePhysicalProps
{
real massInverse;
real momentInverse;
};
struct Positional
{
vec2 position;
real angle;
vec2 centerOfMass;
};
struct Dynamical
{
vec2 linearVelocity;
real angularVelocity;
};
struct OverlapCorrectors
{
vec2 linearCorrection;
real angularCorrection;
};
struct Forces
{
vec2 linearForce;
real angularForce; ///< AKA Torque
};
// TODO lib that will create this facade for us. This is just for convenience.
struct RigidBody
{
PhysicalProps physicalProps;
InversePhysicalProps inversePhysicalProps;
Positional positional;
Dynamical dynamics;
OverlapCorrectors overlapCorrectors;
Forces forces;
Transform transform;
std::vector<PhysicalShape*> shapeList;
RigidBody(real mass, real moment)
: positional{},
dynamics{},
overlapCorrectors{},
forces{},
transform{{},{}}
{
shapeList = std::vector<PhysicalShape*>{};
physicalProps = { mass, moment };
// TODO these shall be updated when the ones above are
inversePhysicalProps.massInverse = mass == 0.f ? INFINITY : 1.f / mass;
inversePhysicalProps.momentInverse = moment == 0.f ? INFINITY : 1.f / moment;
}
};