#pragma once #include "location.h" #include #include #include #include class BufferedLocation { public: BufferedLocation(Position3D = {}, Rotation3D = {}); BufferedLocation(const Location &); virtual ~BufferedLocation() = default; BufferedLocation & operator=(const Location &); operator const Location &() const; [[nodiscard]] Position3D position() const; [[nodiscard]] Rotation3D rotation() const; void setPosition(Position3D, bool update = true); void setRotation(Rotation3D, bool update = true); void setLocation(Position3D, Rotation3D); [[nodiscard]] glm::mat4 getTransform() const; [[nodiscard]] glm::mat4 getRotationTransform() const; private: virtual void updateBuffer() = 0; Location loc; }; template class BufferedLocationT : public BufferedLocation { public: template BufferedLocationT(Target &&... target, LocationArgs &&... t) : BufferedLocation {std::forward(t)...}, target {std::forward(target)...} { updateBuffer(); } using BufferedLocation::operator=; private: void updateBuffer() override { std::apply(std::invoke, target) = getTransform(); } std::tuple target; };