diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-26 13:51:33 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-26 14:14:13 +0000 |
commit | 7fba471728f2216d7e3b7900297fc3b3531e286c (patch) | |
tree | 5caef3b2efc23aefccb215ec9005cd8e7d2e91b8 /gfx/gl/bufferedLocation.h | |
parent | Fix todo for handling a terrain walk from outside the mesh (diff) | |
parent | Model positions as integers (diff) | |
download | ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.bz2 ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.xz ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.zip |
Merge branch 'ints' into terrain
Conflicts fix, compiles, some test failures remain.
Trees not added, possibility of OM invalid handle assertion failures,
normals broken due to integer overflow in Newell's method.
Diffstat (limited to 'gfx/gl/bufferedLocation.h')
-rw-r--r-- | gfx/gl/bufferedLocation.h | 32 |
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; }; |