-
Notifications
You must be signed in to change notification settings - Fork 7
/
physics.h
79 lines (53 loc) · 1.5 KB
/
physics.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
71
72
73
74
75
76
77
78
79
// Copyright © 2015, The Network Protocol Company, Inc. All Rights Reserved.
#ifndef PHYSICS_H
#define PHYSICS_H
#include <stdint.h>
#include "const.h"
#include "vectorial/vec3f.h"
#include "vectorial/quat4f.h"
#include <vector> // todo: remove this!
using namespace vectorial;
enum PhysicsShape
{
PHYSICS_SHAPE_CUBE
};
struct PhysicsObjectState
{
PhysicsObjectState()
{
active = true;
position = vec3f(0,0,0);
orientation = quat4f(0,0,0,1);
linear_velocity = vec3f(0,0,0);
angular_velocity = vec3f(0,0,0);
}
bool active;
vec3f position;
quat4f orientation;
vec3f linear_velocity;
vec3f angular_velocity;
};
class PhysicsManager
{
static int * GetInitCount();
public:
PhysicsManager();
~PhysicsManager();
void Initialize();
void Update( uint64_t tick, double t, float dt, bool paused = false );
int AddObject( int entity_index, const PhysicsObjectState & object_state, PhysicsShape shape, float scale );
bool ObjectExists( int index );
float GetObjectMass( int index );
void RemoveObject( int index );
void GetObjectState( int index, PhysicsObjectState & object_state ) const;
void SetObjectState( int index, const PhysicsObjectState & object_state );
bool IsActive( int index ) const;
void ApplyForce( int index, const vec3f & force );
void ApplyTorque( int index, const vec3f & torque );
void AddPlane( const vec3f & normal, float d );
void Reset();
void WalkInteractions( struct EntityManager * entity_manager );
private:
struct PhysicsInternal * internal;
};
#endif