-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamics.h
More file actions
71 lines (61 loc) · 1.37 KB
/
dynamics.h
File metadata and controls
71 lines (61 loc) · 1.37 KB
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
71
#pragma once
#include "rigid_body.h"
#include "basic_data_structures.h"
enum constraint_type
{
CONSTRAINT_Distance,
CONSTRAINT_Point,
CONSTRAINT_Contact,
CONSTRAINT_Friction,
CONSTRAINT_Count,
};
struct constraint
{
uint32_t Type;
int32_t IndA;
int32_t IndB;
float L;
vec3 BodyRa;
vec3 BodyRb;
float Penetration;
vec3 n;
vec3 P;
vec3 Tangent;
// For friction
int32_t ContactIndex;
};
const int RIGID_BODY_MAX_COUNT = 20;
const int CONSTRAINT_MAX_COUNT = 200;
struct physics_params
{
vec3 ExternalForce;
vec3 ExternalForceStart;
int32_t PGSIterationCount;
float Beta;
float Mu;
};
struct physics_switches
{
bool SimulateDynamics;
bool PerformDynamicsStep;
bool ApplyExternalForce;
bool ApplyExternalTorque;
bool UseGravity;
bool SimulateFriction;
bool VisualizeV;
bool VisualizeOmega;
bool VisualizeFc;
bool VisualizeFcComponents;
bool VisualizeFriction;
bool VisualizeContactPoints;
bool VisualizeContactManifold;
};
struct physics_world
{
rigid_body RigidBodies[RIGID_BODY_MAX_COUNT]; // Indices correspond to entities
fixed_stack<constraint, CONSTRAINT_MAX_COUNT> Constraints;
int RBCount;
physics_params Params;
physics_switches Switches;
};
void SimulateDynamics(physics_world* World);