From dbf88cc90afb9731077c0eecb6a9677a9b005170 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Fri, 24 Apr 2026 10:57:45 -0400 Subject: [PATCH] Reduce constructors using default params --- include/Camera2D.hpp | 3 +-- include/Camera3D.hpp | 4 +--- include/Rectangle.hpp | 6 +----- include/Vector2.hpp | 4 +--- include/Vector3.hpp | 5 +---- include/Vector4.hpp | 6 +----- 6 files changed, 6 insertions(+), 22 deletions(-) diff --git a/include/Camera2D.hpp b/include/Camera2D.hpp index e6ca6ce0..50661c69 100644 --- a/include/Camera2D.hpp +++ b/include/Camera2D.hpp @@ -16,8 +16,7 @@ class Camera2D : public ::Camera2D { // Nothing. } - Camera2D() : ::Camera2D() {} - Camera2D(::Vector2 offset, ::Vector2 target, float rotation = 0.0f, float zoom = 1.0f) + Camera2D(::Vector2 offset = {}, ::Vector2 target = {}, float rotation = 0.0f, float zoom = 1.0f) : ::Camera2D{offset, target, rotation, zoom} {} Camera2D& BeginMode() { diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index 42b180c8..39018938 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -24,15 +24,13 @@ class Camera3D : public ::Camera3D { * @param projection Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC */ Camera3D( - ::Vector3 position, + ::Vector3 position = ::Vector3{0.0f, 0.0f, 0.0f}, ::Vector3 target = ::Vector3{0.0f, 0.0f, -1.0f}, ::Vector3 up = ::Vector3{0.0f, 1.0f, 0.0f}, float fovy = 45.0f, int projection = CAMERA_PERSPECTIVE) : ::Camera3D{position, target, up, fovy, projection} {} - Camera3D() {} - GETTERSETTER(::Vector3, Position, position) GETTERSETTER(::Vector3, Target, target) GETTERSETTER(::Vector3, Up, up) diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 1766a039..5056920e 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -13,11 +13,7 @@ class Rectangle : public ::Rectangle { public: constexpr Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {} - constexpr Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {} - constexpr Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, 0} {} - constexpr Rectangle(float x, float y) : ::Rectangle{x, y, 0, 0} {} - constexpr Rectangle(float x) : ::Rectangle{x, 0, 0, 0} {} - constexpr Rectangle() : ::Rectangle{0, 0, 0, 0} {} + constexpr Rectangle(float x = 0, float y = 0, float width = 0, float height = 0) : ::Rectangle{x, y, width, height} {} constexpr Rectangle(::Vector2 position, ::Vector2 size) : ::Rectangle{position.x, position.y, size.x, size.y} {} constexpr Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {} diff --git a/include/Vector2.hpp b/include/Vector2.hpp index 97d69563..1528f228 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -19,9 +19,7 @@ class Vector2 : public ::Vector2 { public: constexpr Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {} - constexpr Vector2(float x, float y) : ::Vector2{x, y} {} - constexpr Vector2(float x) : ::Vector2{x, 0} {} - constexpr Vector2() : ::Vector2{0, 0} {} + constexpr Vector2(float x = 0, float y = 0) : ::Vector2{x, y} {} GETTERSETTER(float, X, x) GETTERSETTER(float, Y, y) diff --git a/include/Vector3.hpp b/include/Vector3.hpp index 6399e4c6..225fc6e9 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -19,10 +19,7 @@ class Vector3 : public ::Vector3 { public: constexpr Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {} - constexpr Vector3(float x, float y, float z) : ::Vector3{x, y, z} {} - constexpr Vector3(float x, float y) : ::Vector3{x, y, 0} {} - constexpr Vector3(float x) : ::Vector3{x, 0, 0} {} - constexpr Vector3() : ::Vector3{0, 0, 0} {} + constexpr Vector3(float x = 0, float y = 0, float z = 0) : ::Vector3{x, y, z} {} Vector3(::Color color) { set(ColorToHSV(color)); } diff --git a/include/Vector4.hpp b/include/Vector4.hpp index 3d1afcb2..39221531 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -20,11 +20,7 @@ class Vector4 : public ::Vector4 { public: constexpr Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {} - constexpr Vector4(float x, float y, float z, float w) : ::Vector4{x, y, z, w} {} - constexpr Vector4(float x, float y, float z) : ::Vector4{x, y, z, 0} {} - constexpr Vector4(float x, float y) : ::Vector4{x, y, 0, 0} {} - constexpr Vector4(float x) : ::Vector4{x, 0, 0, 0} {} - constexpr Vector4() : ::Vector4{0, 0, 0, 0} {} + constexpr Vector4(float x = 0, float y = 0, float z = 0, float w = 0) : ::Vector4{x, y, z, w} {} constexpr Vector4(::Rectangle rectangle) : ::Vector4{rectangle.x, rectangle.y, rectangle.width, rectangle.height} {} Vector4(::Color color) { set(ColorNormalize(color)); }