CVector2i: Remove use of union and unnamed struct

Nothing uses the v data array, so we can remove it entirely. This
removes the use of a compiler extension (anonymous struct), and
simplifies the underlying data within the vector.
This commit is contained in:
Lioncash 2019-09-04 02:41:25 -04:00
parent 35127116f8
commit 5f892dda81
1 changed files with 7 additions and 10 deletions

View File

@ -1,23 +1,20 @@
#pragma once #pragma once
#include <cstdint>
#include "zeus/CVector2f.hpp" #include "zeus/CVector2f.hpp"
namespace zeus { namespace zeus {
class CVector2i { class CVector2i {
public: public:
union { int32_t x = 0;
struct { int32_t y = 0;
int x, y;
};
int v[2];
};
constexpr CVector2i() : x(0), y(0) {} constexpr CVector2i() = default;
constexpr CVector2i(int xin, int yin) : x(xin), y(yin) {} constexpr CVector2i(int32_t xin, int32_t yin) : x(xin), y(yin) {}
CVector2i(const CVector2f& vec) : x(int(vec.x())), y(int(vec.y())) {} CVector2i(const CVector2f& vec) : x(int32_t(vec.x())), y(int32_t(vec.y())) {}
CVector2f toVec2f() const { return CVector2f(x, y); } CVector2f toVec2f() const { return CVector2f(x, y); }
@ -33,6 +30,6 @@ public:
bool operator!=(const CVector2i& other) const { return x != other.x || y != other.y; } bool operator!=(const CVector2i& other) const { return x != other.x || y != other.y; }
CVector2i operator*(int val) const { return CVector2i(x * val, y * val); } CVector2i operator*(int32_t val) const { return CVector2i(x * val, y * val); }
}; };
} // namespace zeus } // namespace zeus