This commit is contained in:
2025-03-17 04:07:21 +03:00
parent 6dd72d2448
commit 8fc107ec0f
2 changed files with 11 additions and 31 deletions

View File

@@ -7,7 +7,7 @@
#include <tuple>
#ifdef OMATH_IMGUI_INTEGRATION
class ImVec2;
#include <imgui.h>
#endif
@@ -159,17 +159,6 @@ namespace omath
return *this;
}
template<class type>
[[nodiscard]] constexpr const type& As() const
{
return *reinterpret_cast<const type*>(this);
}
template<class type>
[[nodiscard]] constexpr type& As()
{
return *reinterpret_cast<type*>(this);
}
[[nodiscard]] constexpr Vector2 operator-() const
{
return {-x, -y};
@@ -210,15 +199,9 @@ namespace omath
#ifdef OMATH_IMGUI_INTEGRATION
[[nodiscard]]
const ImVec2& ToImVec2() const
ImVec2 ToImVec2() const
{
return *reinterpret_cast<const ImVec2*>(this);
}
[[nodiscard]]
ImVec2& ToImVec2()
{
return *reinterpret_cast<ImVec2*>(this);
return {static_cast<float>(this->x), static_cast<float>(this->y)};
}
#endif
};

View File

@@ -6,9 +6,6 @@
#include <omath/Vector3.hpp>
#include <algorithm>
#ifdef OMATH_IMGUI_INTEGRATION
class ImVec4;
#endif
namespace omath
{
@@ -161,15 +158,15 @@ namespace omath
#ifdef OMATH_IMGUI_INTEGRATION
[[nodiscard]]
constexpr ImVec4& ToImVec4() const
ImVec4 ToImVec4() const
{
return *reinterpret_cast<const ImVec4*>(this);
}
[[nodiscard]]
constexpr ImVec2& ToImVec2()
{
return *reinterpret_cast<ImVec4*>(this);
return
{
static_cast<float>(this->x),
static_cast<float>(this->y),
static_cast<float>(this->z),
static_cast<float>(w),
};
}
#endif
};