From 9d72ed2d5801b1506158082f08bd0b47e58db17f Mon Sep 17 00:00:00 2001 From: fschildt Date: Mon, 29 Sep 2025 13:20:43 +0200 Subject: renderer: major refactor; vectors: now aggregates --- src/basic/math.cpp | 64 +++++++++++++++++++++++++----------------------------- src/basic/math.hpp | 11 ---------- 2 files changed, 30 insertions(+), 45 deletions(-) (limited to 'src/basic') diff --git a/src/basic/math.cpp b/src/basic/math.cpp index 3067255..81fcbbf 100644 --- a/src/basic/math.cpp +++ b/src/basic/math.cpp @@ -1,50 +1,45 @@ #include +/* V2ST */ -V2ST::V2ST(size_t x, size_t y) : x(x), y(y) { -} - -V2ST::V2ST(int32_t x, int32_t y) : x((size_t)x), y((size_t)y) { -} - -bool V2ST::operator==(V2ST &b) { +bool +V2ST::operator==(V2ST& b) +{ bool result = this->x == b.x && this->y == b.y; return result; } -V2F32::V2F32(float x, float y) { - this->x = x; - this->y = y; -} -V2F32 V2F32::operator/(float scalar) { - V2F32 result = {}; +/* V2F32 */ + +V2F32 +V2F32::operator/(float scalar) +{ + V2F32 result {}; result.x = this->x / scalar; result.y = this->y / scalar; return result; } -V2F32 V2F32::operator*(float scalar) { - V2F32 result = {}; +V2F32 +V2F32::operator*(float scalar) +{ + V2F32 result {}; result.x = this->x * scalar; result.y = this->y * scalar; return result; } V2F32 V2F32::operator+(V2F32 other) { - V2F32 result = {}; + V2F32 result {}; result.x = this->x + other.x; result.y = this->y + other.y; return result; } -V3F32::V3F32(float x, float y, float z) { - this->x = x; - this->y = y; - this->z = z; -} +/* V3F32 */ V3F32 V3F32::operator/(float scalar) { V3F32 result = {}; @@ -63,15 +58,12 @@ V3F32 V3F32::operator*(float scalar) { } -V4F32::V4F32(float x, float y, float z, float w) { - this->x = x; - this->y = y; - this->z = z; - this->w = w; -} +/* V4F32 */ -V4F32 V4F32::operator/(float scalar) { - V4F32 result = {}; +V4F32 +V4F32::operator/(float scalar) +{ + V4F32 result {}; result.x = this->x / scalar; result.y = this->y / scalar; result.z = this->z / scalar; @@ -79,8 +71,10 @@ V4F32 V4F32::operator/(float scalar) { return result; } -V4F32 V4F32::operator*(float scalar) { - V4F32 result = {}; +V4F32 +V4F32::operator*(float scalar) +{ + V4F32 result {}; result.x = this->x * scalar; result.y = this->y * scalar; result.z = this->z * scalar; @@ -88,10 +82,12 @@ V4F32 V4F32::operator*(float scalar) { return result; } -V2I32::V2I32(int32_t x, int32_t y) : x(x), y(y) { -} -bool V2I32::operator==(V2I32 other) { +/* V2I32 */ + +bool +V2I32::operator==(V2I32 other) +{ bool result = x == other.x && y == other.y; return result; } diff --git a/src/basic/math.hpp b/src/basic/math.hpp index 40be80a..c5b5940 100644 --- a/src/basic/math.hpp +++ b/src/basic/math.hpp @@ -6,9 +6,6 @@ struct V2ST { size_t x; size_t y; - V2ST() = default; - V2ST(size_t x, size_t y); - V2ST(int32_t x, int32_t y); bool operator==(V2ST &b); bool operator==(const V2ST& other) const { return x == other.x && y == other.y; @@ -19,8 +16,6 @@ struct V2F32 { float x; float y; - V2F32() = default; - V2F32(float x, float y); V2F32 operator/(float scalar); V2F32 operator*(float scalar); V2F32 operator+(V2F32 other); @@ -31,8 +26,6 @@ struct V3F32 { float y; float z; - V3F32() = default; - V3F32(float x, float y, float z); V3F32 operator/(float scalar); V3F32 operator*(float scalar); }; @@ -43,8 +36,6 @@ struct V4F32 { float z; float w; - V4F32() = default; - V4F32 (float x, float y, float z, float w); V4F32 operator/(float scalar); V4F32 operator*(float scalar); }; @@ -53,8 +44,6 @@ struct V2I32 { int32_t x; int32_t y; - V2I32() = default; - V2I32 (int32_t x, int32_t y); bool operator==(V2I32 other); }; -- cgit v1.2.3