Skip to content

Commit

Permalink
Defaults the default constructors to make those types trivial / they …
Browse files Browse the repository at this point in the history
…get passed correctly by interop layer in arm64

dotnet/runtime#106471
  • Loading branch information
azeno committed Aug 16, 2024
1 parent 6a20942 commit 2e580c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ IM_MSVC_RUNTIME_CHECKS_OFF
struct ImVec2
{
float x, y;
constexpr ImVec2() : x(0.0f), y(0.0f) { }
ImVec2() = default;
constexpr ImVec2(float _x, float _y) : x(_x), y(_y) { }
float& operator[] (size_t idx) { IM_ASSERT(idx == 0 || idx == 1); return ((float*)(void*)(char*)this)[idx]; } // We very rarely use this [] operator, so the assert overhead is fine.
float operator[] (size_t idx) const { IM_ASSERT(idx == 0 || idx == 1); return ((const float*)(const void*)(const char*)this)[idx]; }
Expand All @@ -277,7 +277,7 @@ struct ImVec2
struct ImVec4
{
float x, y, z, w;
constexpr ImVec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { }
ImVec4() = default;
constexpr ImVec4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) { }
#ifdef IM_VEC4_CLASS_EXTRA
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
Expand Down Expand Up @@ -2645,7 +2645,7 @@ struct ImColor
{
ImVec4 Value;

constexpr ImColor() { }
ImColor() = default;
constexpr ImColor(float r, float g, float b, float a = 1.0f) : Value(r, g, b, a) { }
constexpr ImColor(const ImVec4& col) : Value(col) {}
constexpr ImColor(int r, int g, int b, int a = 255) : Value((float)r * (1.0f / 255.0f), (float)g * (1.0f / 255.0f), (float)b * (1.0f / 255.0f), (float)a* (1.0f / 255.0f)) {}
Expand Down

0 comments on commit 2e580c8

Please sign in to comment.