From bc8cb043e93161d3433d24fdceb0b9755721d201 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 2 Aug 2024 16:25:36 +0200 Subject: [PATCH 1/3] Fix issues with observable --- openVulkanoCpp/Base/Observable.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openVulkanoCpp/Base/Observable.hpp b/openVulkanoCpp/Base/Observable.hpp index 2569e8d..d364afc 100644 --- a/openVulkanoCpp/Base/Observable.hpp +++ b/openVulkanoCpp/Base/Observable.hpp @@ -32,14 +32,14 @@ namespace OpenVulkano {} Observable(T&& initValue, const std::string& observableName) - : object(std::forward(initValue)), OnChange(observableName) + : object(initValue), OnChange(observableName) {} template>> auto& operator = (const T& val) { object = val; Notify(); return *this; } template>> - auto& operator = (T&& val) { object = std::forward(val); Notify(); return *this; } + auto& operator = (T&& val) { object = val; Notify(); return *this; } template>> operator T() const { return object; } @@ -54,7 +54,9 @@ namespace OpenVulkano bool operator >=(const T& other) const { return object >= other; } bool operator !() const { return !object; } - operator bool() const { return object.operator bool(); } + template>> + operator bool() const { return static_cast(object); } + auto& operator ++() { ++object; Notify(); return *this; } auto& operator --() { --object; Notify(); return *this; } auto& operator ++(int) { object++; Notify(); return *this; } From 057a64710c433fd92d8fad7941666fdaa61931bf Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 2 Aug 2024 16:26:14 +0200 Subject: [PATCH 2/3] automatically convert enum classes in named events to ints --- openVulkanoCpp/Base/Event.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Base/Event.hpp b/openVulkanoCpp/Base/Event.hpp index 5224a70..a547e88 100644 --- a/openVulkanoCpp/Base/Event.hpp +++ b/openVulkanoCpp/Base/Event.hpp @@ -227,12 +227,30 @@ namespace OpenVulkano {} void Notify(Arguments... args) const override + { + NotifyImpl(std::forward(args)...); + } + + void NotifyImpl(Arguments... args) const { if (INamedEventProcessor::HasProcessor()) { std::vector attributes; attributes.reserve(sizeof...(Arguments)); - (attributes.emplace_back(args), ...); + if constexpr (!std::conjunction_v>...>) + { + (attributes.emplace_back(args), ...); + } + else + { + auto fill = [&](auto&& arg) { + if constexpr (std::is_enum_v>) + attributes.emplace_back(static_cast(arg)); + else + attributes.emplace_back(std::forward(arg)); + }; + (fill(std::forward(args)), ...); + } INamedEventProcessor::NotifyAll(m_name, attributes); } } From ad036ad2b6a6bad87691f73e335c059ccd6c6d66 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 2 Aug 2024 16:57:47 +0200 Subject: [PATCH 3/3] Add getters to camera --- openVulkanoCpp/Scene/Camera.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openVulkanoCpp/Scene/Camera.hpp b/openVulkanoCpp/Scene/Camera.hpp index fa127f8..08dfac3 100644 --- a/openVulkanoCpp/Scene/Camera.hpp +++ b/openVulkanoCpp/Scene/Camera.hpp @@ -148,6 +148,10 @@ namespace OpenVulkano::Scene [[nodiscard]] virtual bool IsPerspective() const { return false; } [[nodiscard]] virtual bool IsOrtho() const { return false; } + + float GetWidth() const { return m_width; } + float GetHeight() const { return m_height; } + Math::Vector2f GetSize() const { return { m_width, m_height }; } }; class PerspectiveCamera : public Camera