2018-10-06 20:39:40 -07:00
|
|
|
#pragma once
|
2016-02-13 19:39:47 -08:00
|
|
|
|
2019-09-03 23:41:25 -07:00
|
|
|
#include <cstdint>
|
2019-09-01 00:38:45 -07:00
|
|
|
#include "zeus/CVector2f.hpp"
|
2016-02-13 19:39:47 -08:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
namespace zeus {
|
2016-02-13 19:39:47 -08:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
class CVector2i {
|
2016-02-13 19:39:47 -08:00
|
|
|
public:
|
2019-09-03 23:41:25 -07:00
|
|
|
int32_t x = 0;
|
|
|
|
int32_t y = 0;
|
2018-12-07 17:16:50 -08:00
|
|
|
|
2019-09-03 23:46:26 -07:00
|
|
|
constexpr CVector2i() noexcept = default;
|
2018-12-07 17:16:50 -08:00
|
|
|
|
2019-09-03 23:46:26 -07:00
|
|
|
constexpr CVector2i(int32_t xin, int32_t yin) noexcept : x(xin), y(yin) {}
|
2018-12-07 17:16:50 -08:00
|
|
|
|
2019-09-05 23:24:33 -07:00
|
|
|
CVector2i(const CVector2f& vec) noexcept : x(int32_t(vec.x())), y(int32_t(vec.y())) {}
|
2018-12-07 17:16:50 -08:00
|
|
|
|
2020-02-29 01:33:29 -08:00
|
|
|
[[nodiscard]] constexpr CVector2f toVec2f() const noexcept { return CVector2f(float(x), float(y)); }
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr CVector2i operator+(const CVector2i& val) const noexcept {
|
|
|
|
return CVector2i(x + val.x, y + val.y);
|
|
|
|
}
|
|
|
|
[[nodiscard]] constexpr CVector2i operator-(const CVector2i& val) const noexcept {
|
|
|
|
return CVector2i(x - val.x, y - val.y);
|
|
|
|
}
|
|
|
|
[[nodiscard]] constexpr CVector2i operator*(const CVector2i& val) const noexcept {
|
|
|
|
return CVector2i(x * val.x, y * val.y);
|
|
|
|
}
|
|
|
|
[[nodiscard]] constexpr CVector2i operator/(const CVector2i& val) const noexcept {
|
|
|
|
return CVector2i(x / val.x, y / val.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr bool operator==(const CVector2i& other) const noexcept {
|
|
|
|
return x == other.x && y == other.y;
|
|
|
|
}
|
|
|
|
[[nodiscard]] constexpr bool operator!=(const CVector2i& other) const noexcept { return !operator==(other); }
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr CVector2i operator*(int32_t val) const noexcept { return CVector2i(x * val, y * val); }
|
2016-02-13 19:39:47 -08:00
|
|
|
};
|
2019-09-04 00:05:25 -07:00
|
|
|
static_assert(sizeof(CVector2i) == sizeof(int32_t) * 2);
|
|
|
|
|
2018-12-07 21:23:50 -08:00
|
|
|
} // namespace zeus
|