diff --git a/include/Nazara/Math/Cube.hpp b/include/Nazara/Math/Cube.hpp index d35ab2dac..f13406af0 100644 --- a/include/Nazara/Math/Cube.hpp +++ b/include/Nazara/Math/Cube.hpp @@ -19,9 +19,11 @@ class NzCube { public: NzCube() = default; + NzCube(T Width, T Height, T Depth); NzCube(T X, T Y, T Z, T Width, T Height, T Depth); NzCube(const T cube[6]); NzCube(const NzRect& rect); + NzCube(const NzVector3& size); NzCube(const NzVector3& vec1, const NzVector3& vec2); template explicit NzCube(const NzCube& cube); NzCube(const NzCube& cube) = default; @@ -51,10 +53,12 @@ class NzCube NzCube& MakeZero(); + NzCube& Set(T Width, T Height, T Depth); NzCube& Set(T X, T Y, T Z, T Width, T Height, T Depth); NzCube& Set(const T cube[6]); NzCube& Set(const NzCube& cube); NzCube& Set(const NzRect& rect); + NzCube& Set(const NzVector3& size); NzCube& Set(const NzVector3& vec1, const NzVector3& vec2); template NzCube& Set(const NzCube& cube); @@ -66,8 +70,10 @@ class NzCube T operator[](unsigned int i) const; NzCube operator*(T scalar) const; + NzCube operator*(const NzVector3& vec) const; NzCube& operator*=(T scalar); + NzCube& operator*=(const NzVector3& vec); bool operator==(const NzCube& cube) const; bool operator!=(const NzCube& cube) const; diff --git a/include/Nazara/Math/Cube.inl b/include/Nazara/Math/Cube.inl index 08d78db65..41f21a732 100644 --- a/include/Nazara/Math/Cube.inl +++ b/include/Nazara/Math/Cube.inl @@ -10,6 +10,12 @@ #define F(a) static_cast(a) +template +NzCube::NzCube(T Width, T Height, T Depth) +{ + Set(Width, Height, Depth); +} + template NzCube::NzCube(T X, T Y, T Z, T Width, T Height, T Depth) { @@ -22,6 +28,12 @@ NzCube::NzCube(const NzRect& rect) Set(rect); } +template +NzCube::NzCube(const NzVector3& size) +{ + Set(size); +} + template NzCube::NzCube(const NzVector3& vec1, const NzVector3& vec2) { @@ -258,6 +270,19 @@ NzCube& NzCube::MakeZero() return *this; } +template +NzCube& NzCube::Set(T Width, T Height, T Depth) +{ + x = F(0.0); + y = F(0.0); + z = F(0.0); + width = Width; + height = Height; + depth = Depth; + + return *this; +} + template NzCube& NzCube::Set(T X, T Y, T Z, T Width, T Height, T Depth) { @@ -305,6 +330,12 @@ NzCube& NzCube::Set(const NzRect& rect) return *this; } +template +NzCube& NzCube::Set(const NzVector3& size) +{ + return Set(size.x, size.y, size.z); +} + template NzCube& NzCube::Set(const NzVector3& vec1, const NzVector3& vec2) { @@ -393,6 +424,12 @@ NzCube NzCube::operator*(T scalar) const return NzCube(x, y, z, width*scalar, height*scalar, depth*scalar); } +template +NzCube NzCube::operator*(const NzVector3& vec) const +{ + return NzCube(x, y, z, width*vec.x, height*vec.y, depth*vec.z); +} + template NzCube& NzCube::operator*=(T scalar) { @@ -401,6 +438,14 @@ NzCube& NzCube::operator*=(T scalar) depth *= scalar; } +template +NzCube& NzCube::operator*=(const NzVector3& vec) +{ + width *= vec.x; + height *= vec.y; + depth *= vec.z; +} + template bool NzCube::operator==(const NzCube& cube) const { diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 9bb201286..3a9f0b64b 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -15,8 +15,10 @@ class NzRect { public: NzRect() = default; + NzRect(T Width, T Height); NzRect(T X, T Y, T Width, T Height); NzRect(const T rect[4]); + NzRect(const NzVector2& size); NzRect(const NzVector2& vec1, const NzVector2& vec2); template explicit NzRect(const NzRect& rect); NzRect(const NzRect& rect) = default; @@ -42,9 +44,11 @@ class NzRect NzRect& MakeZero(); + NzRect& Set(T Width, T Height); NzRect& Set(T X, T Y, T Width, T Height); NzRect& Set(const T rect[4]); NzRect& Set(const NzRect& rect); + NzRect& Set(const NzVector2& size); NzRect& Set(const NzVector2& vec1, const NzVector2& vec2); template NzRect& Set(const NzRect& rect); @@ -54,8 +58,10 @@ class NzRect T operator[](unsigned int i) const; NzRect operator*(T scalar) const; + NzRect operator*(const NzVector2& vec) const; NzRect& operator*=(T scalar); + NzRect& operator*=(const NzVector2& vec); bool operator==(const NzRect& rect) const; bool operator!=(const NzRect& rect) const; diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 746436d93..df80185b2 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -10,6 +10,12 @@ #define F(a) static_cast(a) +template +NzRect::NzRect(T Width, T Height) +{ + Set(Width, Height); +} + template NzRect::NzRect(T X, T Y, T Width, T Height) { @@ -22,6 +28,12 @@ NzRect::NzRect(const T vec[4]) Set(vec); } +template +NzRect::NzRect(const NzVector2& size) +{ + Set(size); +} + template NzRect::NzRect(const NzVector2& vec1, const NzVector2& vec2) { @@ -178,6 +190,17 @@ NzRect& NzRect::MakeZero() return *this; } +template +NzRect& NzRect::Set(T Width, T Height) +{ + x = F(0.0); + y = F(0.0); + width = Width; + height = Height; + + return *this; +} + template NzRect& NzRect::Set(T X, T Y, T Width, T Height) { @@ -208,6 +231,12 @@ NzRect& NzRect::Set(const NzRect& rect) return *this; } +template +NzRect& NzRect::Set(const NzVector2& size) +{ + return Set(size.x, size.y); +} + template NzRect& NzRect::Set(const NzVector2& vec1, const NzVector2& vec2) { @@ -279,6 +308,12 @@ NzRect NzRect::operator*(T scalar) const return NzRect(x, y, width*scalar, height*scalar); } +template +NzRect NzRect::operator*(const NzVector2& vec) const +{ + return NzRect(x, y, width*vec.x, height*vec.y); +} + template NzRect& NzRect::operator*=(T scalar) { @@ -286,6 +321,13 @@ NzRect& NzRect::operator*=(T scalar) height *= scalar; } +template +NzRect& NzRect::operator*=(const NzVector2& vec) +{ + width *= vec.x; + height *= vec.y; +} + template bool NzRect::operator==(const NzRect& rect) const {