From 45312e97eaf39d9a4f34f2641ea2c5fa840dbf6c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 4 Oct 2022 13:11:34 -0700 Subject: [PATCH] Match and link CVector2i --- configure.py | 1 + include/Kyoto/Math/CVector2i.hpp | 11 +++++++++-- obj_files.mk | 2 +- src/Kyoto/Math/CVector2i.cpp | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/Kyoto/Math/CVector2i.cpp diff --git a/configure.py b/configure.py index 640bcb9c..30fadda7 100755 --- a/configure.py +++ b/configure.py @@ -33,6 +33,7 @@ COMPLETE_OBJECTS = [ "Kyoto/Graphics/CGX", "Kyoto/Particles/CWarp", "Kyoto/Math/CPlane", + "Kyoto/Math/CVector2i", "Kyoto/Math/CVector3d", "Kyoto/Math/CVector3i", "Kyoto/CRandom16", diff --git a/include/Kyoto/Math/CVector2i.hpp b/include/Kyoto/Math/CVector2i.hpp index ef7196ee..78a88d60 100644 --- a/include/Kyoto/Math/CVector2i.hpp +++ b/include/Kyoto/Math/CVector2i.hpp @@ -7,9 +7,16 @@ class CVector2i { public: CVector2i(int, int); + int GetX() const { return mX; } + int GetY() const { return mY; } private: - int x; - int y; + int mX; + int mY; }; +CVector2i operator+(const CVector2i& lhs, const CVector2i& rhs); +CVector2i operator+(const CVector2i& lhs, const CVector2i& rhs); +bool operator==(const CVector2i& lhs, const CVector2i& rhs); +CVector2i operator*(const CVector2i& lhs, int rhs); +CVector2i operator/(const CVector2i& lhs, int rhs); #endif diff --git a/obj_files.mk b/obj_files.mk index a5986131..dd76bd8a 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -521,7 +521,7 @@ KYOTO_1 :=\ $(BUILD_DIR)/asm/Kyoto/Math/CTransform4f.o\ $(BUILD_DIR)/asm/Kyoto/Math/CUnitVector3f.o\ $(BUILD_DIR)/asm/Kyoto/Math/CVector2f.o\ - $(BUILD_DIR)/asm/Kyoto/Math/CVector2i.o\ + $(BUILD_DIR)/src/Kyoto/Math/CVector2i.o\ $(BUILD_DIR)/src/Kyoto/Math/CVector3d.o\ $(BUILD_DIR)/asm/Kyoto/Math/CVector3f.o\ $(BUILD_DIR)/src/Kyoto/Math/CVector3i.o\ diff --git a/src/Kyoto/Math/CVector2i.cpp b/src/Kyoto/Math/CVector2i.cpp new file mode 100644 index 00000000..12f4a277 --- /dev/null +++ b/src/Kyoto/Math/CVector2i.cpp @@ -0,0 +1,23 @@ +#include "Kyoto/Math/CVector2i.hpp" + +CVector2i::CVector2i(int x, int y) : mX(x), mY(y) {} + +CVector2i operator+(const CVector2i& lhs, const CVector2i& rhs) { + return CVector2i(lhs.GetX() + rhs.GetX(), lhs.GetY() + rhs.GetY()); +} + +CVector2i operator-(const CVector2i& lhs, const CVector2i& rhs) { + return CVector2i(lhs.GetX() - rhs.GetX(), lhs.GetY() - rhs.GetY()); +} + +bool operator==(const CVector2i& lhs, const CVector2i& rhs) { + return lhs.GetX() == rhs.GetX() && lhs.GetY() == rhs.GetY(); +} + +CVector2i operator*(const CVector2i& lhs, int rhs) { + return CVector2i(lhs.GetX() * rhs, lhs.GetY() * rhs); +} + +CVector2i operator/(const CVector2i& lhs, int rhs) { + return CVector2i(lhs.GetX() / rhs, lhs.GetY() / rhs); +}