summaryrefslogtreecommitdiff
path: root/gfx/gl/bufferedLocation.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-01 17:56:26 +0000
commitd5cdbbf38380239524e351cb69aec94090884ca5 (patch)
tree5d7dff2f2775701069806eceb4eaef23b22eba3f /gfx/gl/bufferedLocation.h
parentReformat with new clang-format (diff)
parentRemove more use of legacy types (diff)
downloadilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.bz2
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.tar.xz
ilt-d5cdbbf38380239524e351cb69aec94090884ca5.zip
Merge remote-tracking branch 'origin/terrain'
Diffstat (limited to 'gfx/gl/bufferedLocation.h')
-rw-r--r--gfx/gl/bufferedLocation.h32
1 files changed, 14 insertions, 18 deletions
diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h
index 8096489..87b957f 100644
--- a/gfx/gl/bufferedLocation.h
+++ b/gfx/gl/bufferedLocation.h
@@ -4,11 +4,11 @@
#include <functional>
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
-#include <tuple>
+#include <utility>
class BufferedLocation {
public:
- BufferedLocation(glm::vec3 = {}, glm::vec3 = {});
+ BufferedLocation(GlobalPosition3D = {}, Rotation3D = {});
BufferedLocation(const Location &);
virtual ~BufferedLocation() = default;
@@ -16,25 +16,25 @@ public:
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);
+ [[nodiscard]] GlobalPosition3D position() const;
+ [[nodiscard]] Rotation3D rotation() const;
+ void setPosition(GlobalPosition3D, bool update = true);
+ void setRotation(Rotation3D, bool update = true);
+ void setLocation(GlobalPosition3D, Rotation3D);
- glm::mat4 getTransform() const;
+ [[nodiscard]] glm::mat4 getRotationTransform() const;
private:
- virtual void updateBuffer() = 0;
+ virtual void updateBuffer() const = 0;
Location loc;
};
-template<typename... Target> class BufferedLocationT : public BufferedLocation {
+class BufferedLocationUpdater : public BufferedLocation {
public:
template<typename... LocationArgs>
- BufferedLocationT(Target &&... target, LocationArgs &&... t) :
- BufferedLocation {std::forward<LocationArgs>(t)...}, target {std::forward<Target>(target)...}
+ BufferedLocationUpdater(std::function<void(const BufferedLocation *)> onUpdate, LocationArgs &&... t) :
+ BufferedLocation {std::forward<LocationArgs>(t)...}, onUpdate {std::move(onUpdate)}
{
updateBuffer();
}
@@ -42,11 +42,7 @@ public:
using BufferedLocation::operator=;
private:
- void
- updateBuffer() override
- {
- std::apply(std::invoke<const Target &...>, target) = getTransform();
- }
+ void updateBuffer() const override;
- std::tuple<Target...> target;
+ std::function<void(const BufferedLocation *)> onUpdate;
};