From d6e99a696aa582b81018078b68f6600c8030d643 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 7 Nov 2023 02:51:42 +0000 Subject: WIP typedefing all the things - headers --- gfx/gl/bufferedLocation.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'gfx/gl/bufferedLocation.h') diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h index 8096489..39d3139 100644 --- a/gfx/gl/bufferedLocation.h +++ b/gfx/gl/bufferedLocation.h @@ -8,7 +8,7 @@ class BufferedLocation { public: - BufferedLocation(glm::vec3 = {}, glm::vec3 = {}); + BufferedLocation(Position3D = {}, Rotation3D = {}); BufferedLocation(const Location &); virtual ~BufferedLocation() = default; @@ -16,13 +16,13 @@ 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]] Position3D position() const; + [[nodiscard]] Rotation3D rotation() const; + void setPosition(Position3D, bool update = true); + void setRotation(Rotation3D, bool update = true); + void setLocation(Position3D, Rotation3D); - glm::mat4 getTransform() const; + [[nodiscard]] glm::mat4 getTransform() const; private: virtual void updateBuffer() = 0; -- cgit v1.2.3 From ba4bca84808bebfc81be7df2cb536d1f73451bc6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 11 Nov 2023 17:35:07 +0000 Subject: Add BufferedLocation method for getting the rotation only transform --- gfx/gl/bufferedLocation.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gfx/gl/bufferedLocation.h') diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h index 39d3139..8302b3c 100644 --- a/gfx/gl/bufferedLocation.h +++ b/gfx/gl/bufferedLocation.h @@ -23,6 +23,7 @@ public: void setLocation(Position3D, Rotation3D); [[nodiscard]] glm::mat4 getTransform() const; + [[nodiscard]] glm::mat4 getRotationTransform() const; private: virtual void updateBuffer() = 0; -- cgit v1.2.3 From 5e25d79beef19c39537b0f15982a175fec45bb3e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 11 Nov 2023 17:37:57 +0000 Subject: Refactor BufferedLocationT to use a callback Simplifies customisation in the face of multiple fields --- gfx/gl/bufferedLocation.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'gfx/gl/bufferedLocation.h') diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h index 8302b3c..a5cd23e 100644 --- a/gfx/gl/bufferedLocation.h +++ b/gfx/gl/bufferedLocation.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include class BufferedLocation { public: @@ -26,16 +26,16 @@ public: [[nodiscard]] glm::mat4 getRotationTransform() const; private: - virtual void updateBuffer() = 0; + virtual void updateBuffer() const = 0; Location loc; }; -template class BufferedLocationT : public BufferedLocation { +class BufferedLocationUpdater : public BufferedLocation { public: template - BufferedLocationT(Target &&... target, LocationArgs &&... t) : - BufferedLocation {std::forward(t)...}, target {std::forward(target)...} + BufferedLocationUpdater(std::function onUpdate, LocationArgs &&... t) : + BufferedLocation {std::forward(t)...}, onUpdate {std::move(onUpdate)} { updateBuffer(); } @@ -43,11 +43,7 @@ public: using BufferedLocation::operator=; private: - void - updateBuffer() override - { - std::apply(std::invoke, target) = getTransform(); - } + void updateBuffer() const override; - std::tuple target; + std::function onUpdate; }; -- cgit v1.2.3 From 3200eb41d60595813dca751fe15193ba0b44dddf Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Nov 2023 14:32:56 +0000 Subject: Remove getTransform --- gfx/gl/bufferedLocation.h | 1 - 1 file changed, 1 deletion(-) (limited to 'gfx/gl/bufferedLocation.h') diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h index a5cd23e..30967e3 100644 --- a/gfx/gl/bufferedLocation.h +++ b/gfx/gl/bufferedLocation.h @@ -22,7 +22,6 @@ public: void setRotation(Rotation3D, bool update = true); void setLocation(Position3D, Rotation3D); - [[nodiscard]] glm::mat4 getTransform() const; [[nodiscard]] glm::mat4 getRotationTransform() const; private: -- cgit v1.2.3 From 0aa665c3648d788755b00c9e431c872d57fddbb8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Nov 2023 16:28:39 +0000 Subject: Model positions as integers Introduces test failure in arcs due to rounding, but I don't want to create a complicated fix as link positions are still floats and hopefully that'll go away... somehow --- gfx/gl/bufferedLocation.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gfx/gl/bufferedLocation.h') diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h index 30967e3..87b957f 100644 --- a/gfx/gl/bufferedLocation.h +++ b/gfx/gl/bufferedLocation.h @@ -8,7 +8,7 @@ class BufferedLocation { public: - BufferedLocation(Position3D = {}, Rotation3D = {}); + BufferedLocation(GlobalPosition3D = {}, Rotation3D = {}); BufferedLocation(const Location &); virtual ~BufferedLocation() = default; @@ -16,11 +16,11 @@ public: operator const Location &() const; - [[nodiscard]] Position3D position() const; + [[nodiscard]] GlobalPosition3D position() const; [[nodiscard]] Rotation3D rotation() const; - void setPosition(Position3D, bool update = true); + void setPosition(GlobalPosition3D, bool update = true); void setRotation(Rotation3D, bool update = true); - void setLocation(Position3D, Rotation3D); + void setLocation(GlobalPosition3D, Rotation3D); [[nodiscard]] glm::mat4 getRotationTransform() const; -- cgit v1.2.3