-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP_State.hpp
67 lines (53 loc) · 1.72 KB
/
P_State.hpp
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
#ifndef P_STATE_HPP
#define P_STATE_HPP
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include "Force.hpp"
#include "Util.hpp"
#include <iosfwd>
class P_State {
private:
Forces forces;
public:
// just here so that serialize can do it's thing
P_State();
P_State(float m, float inertia, v3 pos, Id id);
Id id;
// primary
v3 position;
v3 momentum;
fq orient;
v3 ang_momentum;
// secondary
v3 velocity;
v3 ang_velocity;
// removed const from these because networking deserialisation lib
// using the assignment operator...
const float mass;
const float inverse_mass;
const float inertia;
const float inverse_inertia;
void set_momentum(const v3& mom);
void apply_force(const Force& force);
void clear_forces();
void recalc();
const Forces& net_forces() const;
v3 facing() const;
m4 modelMatrix(const v3& scale) const;
m4 viewMatrix(const v3& scale) const;
friend std::ostream& operator<<(std::ostream& stream, const P_State& state);
/*
// please note that when serialized the mass/inertia are not encoded
// intended use is to set the object's state according to the serialised
// object's state, not replace the object with the serialised one
template<class Archive>
void serialize(Archive& archive) {
archive(position, momentum, orient, ang_momentum, id);
}
*/
};
#endif