diff --git a/include/BoundingBox.hpp b/include/BoundingBox.hpp index 4edafe49..6d8354cb 100644 --- a/include/BoundingBox.hpp +++ b/include/BoundingBox.hpp @@ -13,7 +13,7 @@ class BoundingBox : public ::BoundingBox { /* * Copy a bounding box from another bounding box. */ - BoundingBox(const ::BoundingBox& box) : ::BoundingBox{box.min, box.max} { + constexpr BoundingBox(const ::BoundingBox& box) : ::BoundingBox{box.min, box.max} { // Nothing. } @@ -22,8 +22,8 @@ class BoundingBox : public ::BoundingBox { */ BoundingBox(const ::Mesh& mesh) { set(::GetMeshBoundingBox(mesh)); } - BoundingBox(::Vector3 minMax = ::Vector3{0.0f, 0.0f, 0.0f}) : ::BoundingBox{minMax, minMax} {} - BoundingBox(::Vector3 min, ::Vector3 max) : ::BoundingBox{min, max} {} + constexpr BoundingBox(::Vector3 minMax = ::Vector3{0.0f, 0.0f, 0.0f}) : ::BoundingBox{minMax, minMax} {} + constexpr BoundingBox(::Vector3 min, ::Vector3 max) : ::BoundingBox{min, max} {} GETTERSETTER(::Vector3, Min, min) GETTERSETTER(::Vector3, Max, max) diff --git a/include/Color.hpp b/include/Color.hpp index 8bb52c7e..84a7e5ee 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -13,15 +13,15 @@ namespace raylib { */ class Color : public ::Color { public: - Color(const ::Color& color) : ::Color{color.r, color.g, color.b, color.a} {} + constexpr Color(const ::Color& color) : ::Color{color.r, color.g, color.b, color.a} {} - Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255) + constexpr Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255) : ::Color{red, green, blue, alpha} {}; /** * Black. */ - Color() : ::Color{0, 0, 0, 255} {}; + constexpr Color() : ::Color{0, 0, 0, 255} {}; /** * Returns a Color from HSV values diff --git a/include/Matrix.hpp b/include/Matrix.hpp index 7f82138d..cbcb200c 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -15,12 +15,12 @@ namespace raylib { */ class Matrix : public ::Matrix { public: - Matrix(const ::Matrix& mat) + constexpr Matrix(const ::Matrix& mat) : ::Matrix(mat) { // Nothing. } - Matrix( + constexpr Matrix( float m0 = 0, float m4 = 0, float m8 = 0, @@ -72,14 +72,14 @@ class Matrix : public ::Matrix { return *this; } - bool operator==(const ::Matrix& other) { + constexpr bool operator==(const ::Matrix& other) { return m0 == other.m0 && m1 == other.m1 && m2 == other.m2 && m3 == other.m3 && m4 == other.m4 && m5 == other.m5 && m6 == other.m6 && m7 == other.m7 && m8 == other.m8 && m9 == other.m9 && m10 == other.m10 && m11 == other.m11 && m12 == other.m12 && m13 == other.m13 && m14 == other.m14 && m15 == other.m15; } - bool operator!=(const ::Matrix& other) { return !(*this == other); } + constexpr bool operator!=(const ::Matrix& other) { return !(*this == other); } #ifndef RAYLIB_CPP_NO_MATH /** diff --git a/include/Ray.hpp b/include/Ray.hpp index c9ccb09b..d38267ef 100644 --- a/include/Ray.hpp +++ b/include/Ray.hpp @@ -13,7 +13,7 @@ class Ray : public ::Ray { public: Ray(const ::Ray& ray) { set(ray); } - Ray(::Vector3 position = {0.0f, 0.0f, 0.0f}, ::Vector3 direction = {0.0f, 0.0f, 0.0f}) + constexpr Ray(::Vector3 position = {0.0f, 0.0f, 0.0f}, ::Vector3 direction = {0.0f, 0.0f, 0.0f}) : ::Ray{position, direction} { // Nothing. } diff --git a/include/RayCollision.hpp b/include/RayCollision.hpp index 0dfe4390..5595cdba 100644 --- a/include/RayCollision.hpp +++ b/include/RayCollision.hpp @@ -12,7 +12,7 @@ class RayCollision : public ::RayCollision { public: RayCollision(const ::RayCollision& ray) : ::RayCollision(ray) { } - RayCollision(bool hit, float distance, ::Vector3 point, ::Vector3 normal) + constexpr RayCollision(bool hit, float distance, ::Vector3 point, ::Vector3 normal) : ::RayCollision{hit, distance, point, normal} { // Nothing. } diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 416d2337..e07a45c1 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -11,17 +11,17 @@ namespace raylib { */ class Rectangle : public ::Rectangle { public: - Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {} + constexpr Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {} - Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {} - Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, 0} {} - Rectangle(float x, float y) : ::Rectangle{x, y, 0, 0} {} - Rectangle(float x) : ::Rectangle{x, 0, 0, 0} {} - Rectangle() : ::Rectangle{0, 0, 0, 0} {} + 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} {} - Rectangle(::Vector2 position, ::Vector2 size) : ::Rectangle{position.x, position.y, size.x, size.y} {} - Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {} - Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {} + 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} {} + constexpr Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {} GETTERSETTER(float, X, x) GETTERSETTER(float, Y, y) @@ -33,9 +33,9 @@ class Rectangle : public ::Rectangle { return *this; } - ::Vector4 ToVector4() { return {x, y, width, height}; } + constexpr ::Vector4 ToVector4() const { return {x, y, width, height}; } - explicit operator ::Vector4() const { return {x, y, width, height}; } + constexpr explicit operator ::Vector4() const { return {x, y, width, height}; } /** * Draw a color-filled rectangle diff --git a/include/Vector2.hpp b/include/Vector2.hpp index bcbb8387..97d69563 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -17,11 +17,11 @@ namespace raylib { */ class Vector2 : public ::Vector2 { public: - Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {} + constexpr Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {} - Vector2(float x, float y) : ::Vector2{x, y} {} - Vector2(float x) : ::Vector2{x, 0} {} - Vector2() : ::Vector2{0, 0} {} + constexpr Vector2(float x, float y) : ::Vector2{x, y} {} + constexpr Vector2(float x) : ::Vector2{x, 0} {} + constexpr Vector2() : ::Vector2{0, 0} {} GETTERSETTER(float, X, x) GETTERSETTER(float, Y, y) @@ -37,12 +37,12 @@ class Vector2 : public ::Vector2 { /** * Determine whether or not the vectors are equal. */ - bool operator==(const ::Vector2& other) const { return x == other.x && y == other.y; } + constexpr bool operator==(const ::Vector2& other) const { return x == other.x && y == other.y; } /** * Determines if the vectors are not equal. */ - bool operator!=(const ::Vector2& other) const { return !(*this == other); } + constexpr bool operator!=(const ::Vector2& other) const { return !(*this == other); } [[nodiscard]] std::string ToString() const { return TextFormat("Vector2(%f, %f)", x, y); } diff --git a/include/Vector3.hpp b/include/Vector3.hpp index c4fbb8f3..6399e4c6 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -17,12 +17,12 @@ namespace raylib { */ class Vector3 : public ::Vector3 { public: - Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {} + constexpr Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {} - Vector3(float x, float y, float z) : ::Vector3{x, y, z} {} - Vector3(float x, float y) : ::Vector3{x, y, 0} {} - Vector3(float x) : ::Vector3{x, 0, 0} {} - Vector3() : ::Vector3{0, 0, 0} {} + 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} {} Vector3(::Color color) { set(ColorToHSV(color)); } @@ -35,9 +35,9 @@ class Vector3 : public ::Vector3 { return *this; } - bool operator==(const ::Vector3& other) const { return x == other.x && y == other.y && z == other.z; } + constexpr bool operator==(const ::Vector3& other) const { return x == other.x && y == other.y && z == other.z; } - bool operator!=(const ::Vector3& other) const { return !(*this == other); } + constexpr bool operator!=(const ::Vector3& other) const { return !(*this == other); } [[nodiscard]] std::string ToString() const { return TextFormat("Vector3(%f, %f, %f)", x, y, z); } diff --git a/include/Vector4.hpp b/include/Vector4.hpp index 03cb47f6..3d1afcb2 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -18,14 +18,14 @@ namespace raylib { */ class Vector4 : public ::Vector4 { public: - Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {} + constexpr Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {} - Vector4(float x, float y, float z, float w) : ::Vector4{x, y, z, w} {} - Vector4(float x, float y, float z) : ::Vector4{x, y, z, 0} {} - Vector4(float x, float y) : ::Vector4{x, y, 0, 0} {} - Vector4(float x) : ::Vector4{x, 0, 0, 0} {} - Vector4() : ::Vector4{0, 0, 0, 0} {} - Vector4(::Rectangle rectangle) : ::Vector4{rectangle.x, rectangle.y, rectangle.width, rectangle.height} {} + 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(::Rectangle rectangle) : ::Vector4{rectangle.x, rectangle.y, rectangle.width, rectangle.height} {} Vector4(::Color color) { set(ColorNormalize(color)); } @@ -39,15 +39,15 @@ class Vector4 : public ::Vector4 { return *this; } - bool operator==(const ::Vector4& other) const { + constexpr bool operator==(const ::Vector4& other) const { return x == other.x && y == other.y && z == other.z && w == other.w; } - bool operator!=(const ::Vector4& other) const { return !(*this == other); } + constexpr bool operator!=(const ::Vector4& other) const { return !(*this == other); } - [[nodiscard]] ::Rectangle ToRectangle() const { return {x, y, z, w}; } + [[nodiscard]] constexpr ::Rectangle ToRectangle() const { return {x, y, z, w}; } - operator ::Rectangle() const { return {x, y, z, w}; } + constexpr operator ::Rectangle() const { return {x, y, z, w}; } [[nodiscard]] std::string ToString() const { return TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w); }