blob: 809648978a786b3b7c305671b26990555b63f47f (
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
|
#pragma once
#include "location.h"
#include <functional>
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <tuple>
class BufferedLocation {
public:
BufferedLocation(glm::vec3 = {}, glm::vec3 = {});
BufferedLocation(const Location &);
virtual ~BufferedLocation() = default;
BufferedLocation & operator=(const Location &);
operator const Location &() const;
glm::vec3 position() const;
glm::vec3 rotation() const;
void setPosition(glm::vec3, bool update = true);
void setRotation(glm::vec3, bool update = true);
void setLocation(glm::vec3, glm::vec3);
glm::mat4 getTransform() const;
private:
virtual void updateBuffer() = 0;
Location loc;
};
template<typename... Target> class BufferedLocationT : public BufferedLocation {
public:
template<typename... LocationArgs>
BufferedLocationT(Target &&... target, LocationArgs &&... t) :
BufferedLocation {std::forward<LocationArgs>(t)...}, target {std::forward<Target>(target)...}
{
updateBuffer();
}
using BufferedLocation::operator=;
private:
void
updateBuffer() override
{
std::apply(std::invoke<const Target &...>, target) = getTransform();
}
std::tuple<Target...> target;
};
|