blob: 4484053a5fb332de263fc0053df5739387570e5a (
plain)
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
|
#include "bufferedLocation.h"
#include "location.hpp"
#include "maths.h"
#include <glm/gtx/transform.hpp>
BufferedLocation::BufferedLocation(InstanceVertices<glm::mat4> & i, glm::vec3 p, glm::vec3 r) :
BufferedLocation {i, Location {p, r}}
{
}
BufferedLocation::BufferedLocation(InstanceVertices<glm::mat4> & i, const Location & l) :
loc {l}, buffer {i.acquire(getTransform())}
{
}
BufferedLocation::operator const Location &() const
{
return loc;
}
BufferedLocation &
BufferedLocation::operator=(const Location & l)
{
loc = l;
updateBuffer();
return *this;
}
glm::vec3
BufferedLocation::position() const
{
return loc.pos;
}
glm::vec3
BufferedLocation::rotation() const
{
return loc.rot;
}
void
BufferedLocation::setPosition(glm::vec3 p, bool update)
{
loc.pos = p;
if (update) {
updateBuffer();
}
}
void
BufferedLocation::setRotation(glm::vec3 r, bool update)
{
loc.rot = r;
if (update) {
updateBuffer();
}
}
void
BufferedLocation::setLocation(glm::vec3 p, glm::vec3 r)
{
loc.pos = p;
loc.rot = r;
updateBuffer();
}
void
BufferedLocation::updateBuffer()
{
buffer = getTransform();
}
glm::mat4
BufferedLocation::getTransform() const
{
return loc.getTransform();
}
|