-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActor.cpp
90 lines (74 loc) · 1.83 KB
/
Actor.cpp
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
80
81
82
83
84
85
86
87
88
89
90
#include "Actor.hpp"
int Actor::num_actors = 0;
Actor::Actor(
int g_cub,
const vv3* face_verts,
v3 scale,
v3 startPos,
float mass,
float inertia,
bool selectable,
bool mobile
) :
id(num_actors++),
l_cuboid(face_verts, scale, startPos),
g_cuboid(g_cub),
p_state_(mass, inertia, startPos, id),
changed_state_(false),
invisible_(false),
selectable(selectable),
mobile(mobile)
{
}
void Actor::invis(const bool& b) {
invisible_ = b;
}
const bool Actor::invis() const {
return invisible_;
}
m4 Actor::modelMatrix() const {
return p_state_.modelMatrix(l_cuboid.scale);
}
m4 Actor::viewMatrix() const {
return p_state_.viewMatrix(l_cuboid.scale);
}
const P_State& Actor::p_state() const {
return p_state_;
}
const L_Cuboid& Actor::logical_cuboid() const {
return l_cuboid;
}
int Actor::graphical_cuboid() const {
return g_cuboid;
}
void Actor::set_changed() {
changed_state_ = true;
}
void Actor::set_unchanged() {
changed_state_ = false;
}
void Actor::recalc() {
static const std::string s = "Should only ever recalc an actor's state if it changed "
"- if strange bug here after time, take care that physics sim clamps mom/ang_mom to zero, "
" try removing clamping";
assert((s,changed_state_));
l_cuboid.recalc(p_state_.position,p_state_.orient);
changed_state_ = false;
}
bool Actor::changed_state() const {
return changed_state_;
}
P_State& Actor::state_to_change() {
return p_state_;
}
void Actor::apply_force(const Force& force) {
if (mobile) {
p_state_.apply_force(force);
}
}
/*
* Code for movement, relative locking of camera
* Need to be able to apply forces and pass these through to p_state_
* Changes of p_state_ need to affect l_cub or set a flag
* To recalc l_cub whenever moved
*/