From 2eb51f9a8386e6d733b42d51e99150e3985b4b7a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 21 May 2022 20:04:12 +0200 Subject: [PATCH] Reformat code in Math libary --- Source/Engine/Core/Math/AABB.h | 5 -- Source/Engine/Core/Math/BoundingBox.h | 12 +-- Source/Engine/Core/Math/BoundingFrustum.h | 6 -- Source/Engine/Core/Math/BoundingSphere.h | 10 +-- Source/Engine/Core/Math/CollisionsHelper.h | 1 - Source/Engine/Core/Math/Color.h | 11 +-- Source/Engine/Core/Math/Color32.h | 8 -- Source/Engine/Core/Math/Double2.h | 89 +++++-------------- Source/Engine/Core/Math/Double3.h | 8 +- Source/Engine/Core/Math/Double4.h | 86 +++--------------- Source/Engine/Core/Math/Int2.h | 17 ++-- Source/Engine/Core/Math/Int3.h | 20 ++--- Source/Engine/Core/Math/Int4.h | 21 ++--- Source/Engine/Core/Math/Matrix.h | 12 +-- Source/Engine/Core/Math/Matrix3x3.h | 11 --- Source/Engine/Core/Math/OrientedBoundingBox.h | 9 -- Source/Engine/Core/Math/Plane.h | 12 +-- Source/Engine/Core/Math/Quaternion.h | 10 +-- Source/Engine/Core/Math/Ray.h | 9 +- Source/Engine/Core/Math/Rectangle.h | 13 +-- Source/Engine/Core/Math/Transform.h | 13 +-- Source/Engine/Core/Math/Triangle.h | 4 - Source/Engine/Core/Math/Vector2.h | 87 +++++------------- Source/Engine/Core/Math/Vector3.h | 9 +- Source/Engine/Core/Math/Vector4.h | 88 +++--------------- Source/Engine/Core/Math/Viewport.h | 6 -- 26 files changed, 103 insertions(+), 474 deletions(-) diff --git a/Source/Engine/Core/Math/AABB.h b/Source/Engine/Core/Math/AABB.h index fbc498189..1c96e12b5 100644 --- a/Source/Engine/Core/Math/AABB.h +++ b/Source/Engine/Core/Math/AABB.h @@ -11,7 +11,6 @@ struct FLAXENGINE_API AABB { public: - int32 MinX; int32 MaxX; @@ -22,7 +21,6 @@ public: int32 MaxZ; public: - AABB() { MinX = MAX_int32; @@ -49,7 +47,6 @@ public: } public: - int32 Width() const { return MaxX - MinX; @@ -86,7 +83,6 @@ public: } public: - void Clear() { MinX = MAX_int32; @@ -184,7 +180,6 @@ public: } public: - bool IsOutside(const AABB& other) const { return MaxX - other.MinX < 0 || MinX - other.MaxX > 0 || diff --git a/Source/Engine/Core/Math/BoundingBox.h b/Source/Engine/Core/Math/BoundingBox.h index 575f484fa..7e65f0d58 100644 --- a/Source/Engine/Core/Math/BoundingBox.h +++ b/Source/Engine/Core/Math/BoundingBox.h @@ -11,9 +11,8 @@ /// API_STRUCT() struct FLAXENGINE_API BoundingBox { -DECLARE_SCRIPTING_TYPE_MINIMAL(BoundingBox); + DECLARE_SCRIPTING_TYPE_MINIMAL(BoundingBox); public: - /// /// A which represents an empty space. /// @@ -25,7 +24,6 @@ public: static const BoundingBox Zero; public: - /// /// The minimum point of the box. /// @@ -37,7 +35,6 @@ public: API_FIELD() Vector3 Maximum; public: - /// /// Empty constructor. /// @@ -67,11 +64,9 @@ public: } public: - String ToString() const; public: - /// /// Gets the eight corners of the bounding box. /// @@ -152,7 +147,6 @@ public: } public: - static bool NearEqual(const BoundingBox& a, const BoundingBox& b) { return Vector3::NearEqual(a.Minimum, b.Minimum) && Vector3::NearEqual(a.Maximum, b.Maximum); @@ -164,7 +158,6 @@ public: } public: - /// /// Merges the box with a point. /// @@ -193,7 +186,6 @@ public: BoundingBox MakeOffsetted(const Vector3& offset) const; public: - FORCE_INLINE bool operator==(const BoundingBox& other) const { return Minimum == other.Minimum && Maximum == other.Maximum; @@ -212,7 +204,6 @@ public: } public: - /// /// Constructs a Bounding Box that fully contains the given pair of points. /// @@ -300,7 +291,6 @@ public: static void Transform(const BoundingBox& box, const Matrix& matrix, BoundingBox& result); public: - /// /// Determines if there is an intersection between the current object and a Ray. /// diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index a1dcd9b51..ae30b5daa 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -13,7 +13,6 @@ API_STRUCT(InBuild) struct FLAXENGINE_API BoundingFrustum { private: - Matrix _matrix; Plane _pNear; Plane _pFar; @@ -23,7 +22,6 @@ private: Plane _pBottom; public: - /// /// Empty constructor. /// @@ -41,11 +39,9 @@ public: } public: - String ToString() const; public: - /// /// Gets the matrix that describes this bounding frustum. /// @@ -194,7 +190,6 @@ public: float GetHeightAtDepth(float depth) const; public: - FORCE_INLINE bool operator==(const BoundingFrustum& other) const { return _matrix == other._matrix; @@ -206,7 +201,6 @@ public: } public: - /// /// Checks whether a point lays inside, intersects or lays outside the frustum. /// diff --git a/Source/Engine/Core/Math/BoundingSphere.h b/Source/Engine/Core/Math/BoundingSphere.h index 2282584fd..38acd93ad 100644 --- a/Source/Engine/Core/Math/BoundingSphere.h +++ b/Source/Engine/Core/Math/BoundingSphere.h @@ -12,16 +12,14 @@ /// API_STRUCT() struct FLAXENGINE_API BoundingSphere { -DECLARE_SCRIPTING_TYPE_MINIMAL(BoundingSphere); + DECLARE_SCRIPTING_TYPE_MINIMAL(BoundingSphere); public: - /// /// An empty bounding sphere (Center = 0 and Radius = 0). /// static const BoundingSphere Empty; public: - /// /// The center of the sphere in three dimensional space. /// @@ -33,7 +31,6 @@ public: API_FIELD() float Radius; public: - /// /// Empty constructor. /// @@ -53,11 +50,9 @@ public: } public: - String ToString() const; public: - FORCE_INLINE bool operator==(const BoundingSphere& other) const { return Center == other.Center && Radius == other.Radius; @@ -69,7 +64,6 @@ public: } public: - static bool NearEqual(const BoundingSphere& a, const BoundingSphere& b) { return Vector3::NearEqual(a.Center, b.Center) && Math::NearEqual(a.Radius, b.Radius); @@ -81,7 +75,6 @@ public: } public: - /// /// Determines if there is an intersection between the current object and a Ray. /// @@ -175,7 +168,6 @@ public: ContainmentType Contains(const BoundingSphere& sphere) const; public: - /// /// Gets the box which contains whole sphere. /// diff --git a/Source/Engine/Core/Math/CollisionsHelper.h b/Source/Engine/Core/Math/CollisionsHelper.h index ef1791ec1..44c2373e7 100644 --- a/Source/Engine/Core/Math/CollisionsHelper.h +++ b/Source/Engine/Core/Math/CollisionsHelper.h @@ -60,7 +60,6 @@ enum class PlaneIntersectionType class FLAXENGINE_API CollisionsHelper { public: - /// /// Determines the closest point between a point and a line. /// diff --git a/Source/Engine/Core/Math/Color.h b/Source/Engine/Core/Math/Color.h index 8a8ea5f54..937fba0e9 100644 --- a/Source/Engine/Core/Math/Color.h +++ b/Source/Engine/Core/Math/Color.h @@ -16,9 +16,8 @@ struct Color32; /// API_STRUCT() struct FLAXENGINE_API Color { -DECLARE_SCRIPTING_TYPE_MINIMAL(Color); + DECLARE_SCRIPTING_TYPE_MINIMAL(Color); public: - union { struct @@ -51,7 +50,6 @@ public: }; public: - /// /// Empty constructor. /// @@ -119,7 +117,6 @@ public: explicit Color(const Color32& color); public: - /// /// Initializes from values in range [0;255]. /// @@ -177,12 +174,10 @@ public: static Color Random(); public: - String ToString() const; String ToHexString() const; public: - bool operator==(const Color& other) const { return R == other.R && G == other.G && B == other.B && A == other.A; @@ -270,12 +265,10 @@ public: bool HasOpacity() const; public: - static bool NearEqual(const Color& a, const Color& b); static bool NearEqual(const Color& a, const Color& b, float epsilon); public: - // Get color as vector structure. Vector3 ToVector3() const; @@ -343,7 +336,6 @@ public: } public: - uint32 GetHashCode() const; static uint32 GetHashCode(const Color& v) @@ -352,7 +344,6 @@ public: } public: - static Color Transparent; static Color AliceBlue; static Color AntiqueWhite; diff --git a/Source/Engine/Core/Math/Color32.h b/Source/Engine/Core/Math/Color32.h index 4912d5a2f..09ccfe426 100644 --- a/Source/Engine/Core/Math/Color32.h +++ b/Source/Engine/Core/Math/Color32.h @@ -16,7 +16,6 @@ struct Color; API_STRUCT(InBuild) struct FLAXENGINE_API Color32 { public: - union { struct @@ -49,13 +48,11 @@ public: }; public: - static Color32 Transparent; static Color32 Black; static Color32 White; public: - /// /// Empty constructor. /// @@ -82,12 +79,10 @@ public: explicit Color32(const Vector4& c); public: - String ToString() const; String ToHexString() const; public: - bool operator==(const Color32& other) const { return R == other.R && G == other.G && B == other.B && A == other.A; @@ -158,7 +153,6 @@ public: } public: - uint32 GetAsABGR() const { return (R << 24) + (G << 16) + (B << 8) + A; @@ -185,7 +179,6 @@ public: } public: - uint32 GetHashCode() const; static uint32 GetHashCode(const Color32& v) @@ -194,7 +187,6 @@ public: } public: - /// /// Initializes from packed RGB value of the color and separate alpha channel value. /// diff --git a/Source/Engine/Core/Math/Double2.h b/Source/Engine/Core/Math/Double2.h index 2de5bd736..3e57e332c 100644 --- a/Source/Engine/Core/Math/Double2.h +++ b/Source/Engine/Core/Math/Double2.h @@ -23,9 +23,8 @@ struct Matrix; /// API_STRUCT() struct FLAXENGINE_API Double2 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Double2); + DECLARE_SCRIPTING_TYPE_MINIMAL(Double2); public: - union { struct @@ -46,7 +45,6 @@ public: }; public: - // Vector with all components equal 0 static const Double2 Zero; @@ -66,7 +64,6 @@ public: static const Double2 Maximum; public: - /// /// Empty constructor. /// @@ -100,49 +97,21 @@ public: , Y(xy[1]) { } - - // Init - // @param v Int2 to use X and Y components + explicit Double2(const Int2& xy); - - // Init - // @param v Int3 to use X and Y components explicit Double2(const Int3& xyz); - - // Init - // @param v Int4 to use X and Y components explicit Double2(const Int4& xyzw); - - // Init - // @param v Vector2 to use X and Y components Double2(const Vector2& xy); - - // Init - // @param v Vector3 to use X and Y components explicit Double2(const Vector3& xyz); - - // Init - // @param v Vector4 to use X and Y components explicit Double2(const Vector4& xyzw); - - // Init - // @param v Double3 to use X and Y components explicit Double2(const Double3& xyz); - - // Init - // @param v Double4 to use X and Y components explicit Double2(const Double4& xyzw); - - // Init - // @param color Color value explicit Double2(const Color& color); public: - String ToString() const; public: - // Arithmetic operators with Double2 Double2 operator+(const Double2& b) const { @@ -272,7 +241,6 @@ public: } public: - static bool NearEqual(const Double2& a, const Double2& b) { return Math::NearEqual(a.X, b.X) && Math::NearEqual(a.Y, b.Y); @@ -284,7 +252,6 @@ public: } public: - static double Dot(const Double2& a, const Double2& b) { return a.X * b.X + a.Y * b.Y; @@ -396,137 +363,125 @@ public: } public: - - // Gets a value indicting whether this instance is normalized + // Gets a value indicting whether this instance is normalized. bool IsNormalized() const { return Math::IsOne(X * X + Y * Y); } - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsZero() const { return Math::IsZero(X) && Math::IsZero(Y); } - // Gets a value indicting whether any vector component is zero + // Gets a value indicting whether any vector component is zero. bool IsAnyZero() const { return Math::IsZero(X) || Math::IsZero(Y); } - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsOne() const { return Math::IsOne(X) && Math::IsOne(Y); } - // Calculates length of the vector - // @returns Length of the vector + // Calculates length of the vector. double Length() const { return Math::Sqrt(X * X + Y * Y); } - // Calculates the squared length of the vector - // @returns The squared length of the vector + // Calculates the squared length of the vector. double LengthSquared() const { return X * X + Y * Y; } - // Calculates inverted length of the vector (1 / Length()) + // Calculates inverted length of the vector (1 / length). double InvLength() const { return 1. / Length(); } - // Calculates a vector with values being absolute values of that vector + // Calculates a vector with values being absolute values of that vector. Double2 GetAbsolute() const { return Double2(Math::Abs(X), Math::Abs(Y)); } - // Calculates a vector with values being opposite to values of that vector + // Calculates a vector with values being opposite to values of that vector. Double2 GetNegative() const { return Double2(-X, -Y); } /// - /// Returns average arithmetic of all the components + /// Returns the average arithmetic of all the components. /// - /// Average arithmetic of all the components double AverageArithmetic() const { return (X + Y) * 0.5; } /// - /// Gets sum of all vector components values + /// Gets the sum of all vector components values. /// - /// Sum of X,Y and Z double SumValues() const { return X + Y; } /// - /// Gets multiplication result of all vector components values + /// Gets the multiplication result of all vector components values. /// - /// X * Y double MulValues() const { return X * Y; } /// - /// Returns minimum value of all the components + /// Returns the minimum value of all the components. /// - /// Minimum value double MinValue() const { return Math::Min(X, Y); } /// - /// Returns maximum value of all the components + /// Returns the maximum value of all the components. /// - /// Maximum value double MaxValue() const { return Math::Max(X, Y); } /// - /// Returns true if vector has one or more components is not a number (NaN) + /// Returns true if vector has one or more components is not a number (NaN). /// - /// True if one or more components is not a number (NaN) bool IsNaN() const { return isnan(X) || isnan(Y); } /// - /// Returns true if vector has one or more components equal to +/- infinity + /// Returns true if vector has one or more components equal to +/- infinity. /// - /// True if one or more components equal to +/- infinity bool IsInfinity() const { return isinf(X) || isinf(Y); } /// - /// Returns true if vector has one or more components equal to +/- infinity or NaN + /// Returns true if vector has one or more components equal to +/- infinity or NaN. /// - /// True if one or more components equal to +/- infinity or NaN bool IsNanOrInfinity() const { return IsInfinity() || IsNaN(); } public: - // Performs a linear interpolation between two vectors // @param start Start vector // @param end End vector @@ -616,7 +571,6 @@ public: } public: - /// /// Calculates the area of the triangle. /// @@ -625,15 +579,14 @@ public: /// The third triangle vertex. /// The triangle area. static double TriangleArea(const Double2& v0, const Double2& v1, const Double2& v2); - - /// + + /// /// Calculates the angle (in radians) between from and to. This is always the smallest value. /// /// The first vector. /// The second vector. /// The angle (in radians). static double Angle(const Double2& from, const Double2& to); - }; inline Double2 operator+(double a, const Double2& b) diff --git a/Source/Engine/Core/Math/Double3.h b/Source/Engine/Core/Math/Double3.h index 5adaaf225..c545cf78e 100644 --- a/Source/Engine/Core/Math/Double3.h +++ b/Source/Engine/Core/Math/Double3.h @@ -215,7 +215,7 @@ public: } /// - /// Returns average arithmetic of all the components. + /// Returns the average arithmetic of all the components. /// double AverageArithmetic() const { @@ -223,7 +223,7 @@ public: } /// - /// Gets sum of all vector components values. + /// Gets the sum of all vector components values. /// double SumValues() const { @@ -231,7 +231,7 @@ public: } /// - /// Returns minimum value of all the components. + /// Returns the minimum value of all the components. /// double MinValue() const { @@ -239,7 +239,7 @@ public: } /// - /// Returns maximum value of all the components. + /// Returns the maximum value of all the components. /// double MaxValue() const { diff --git a/Source/Engine/Core/Math/Double4.h b/Source/Engine/Core/Math/Double4.h index f2b86a433..aeb43ca10 100644 --- a/Source/Engine/Core/Math/Double4.h +++ b/Source/Engine/Core/Math/Double4.h @@ -25,9 +25,8 @@ struct Int4; /// API_STRUCT() struct FLAXENGINE_API Double4 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Double4); + DECLARE_SCRIPTING_TYPE_MINIMAL(Double4); public: - union { struct @@ -60,7 +59,6 @@ public: }; public: - // Vector with all components equal 0 static const Double4 Zero; @@ -86,7 +84,6 @@ public: static const Double4 Maximum; public: - /// /// Empty constructor. /// @@ -121,167 +118,113 @@ public: { } - // Init - // @param xy X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Double4(const Vector2& xy, double z, double w); - - // Init - // @param xy X and Y values in the vector - // @param zw Z and W values in the vector explicit Double4(const Vector2& xy, const Vector2& zw); - - // Init - // @param xyz X, Y and Z values in the vector - // @param w W component value explicit Double4(const Vector3& xyz, double w); - - // Init - // @param xyzw Vector4 value Double4(const Vector4& xyzw); - - // Init - // @param xy X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Double4(const Int2& xy, double z, double w); - - // Init - // @param xyz X, Y and Z values in the vector - // @param w W component value explicit Double4(const Int3& xyz, double w); - - // Init - // @param xyzw Int4 value explicit Double4(const Int4& xyzw); - - // Init - // @param xy X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Double4(const Double2& xy, double z, double w); - - // Init - // @param xyz X, Y and Z values in the vector - // @param w W component value explicit Double4(const Double3& xyz, double w); - - // Init - // @param color Color value explicit Double4(const Color& color); - - // Init - // @param rect Rectangle value explicit Double4(const Rectangle& rect); public: - String ToString() const; public: - - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsZero() const { return Math::IsZero(X) && Math::IsZero(Y) && Math::IsZero(Z) && Math::IsZero(W); } - // Gets a value indicting whether any vector component is zero + // Gets a value indicting whether any vector component is zero. bool IsAnyZero() const { return Math::IsZero(X) || Math::IsZero(Y) || Math::IsZero(Z) || Math::IsZero(W); } - // Gets a value indicting whether this vector is one + // Gets a value indicting whether this vector is one. bool IsOne() const { return Math::IsOne(X) && Math::IsOne(Y) && Math::IsOne(Z) && Math::IsOne(W); } /// - /// Calculates a vector with values being absolute values of that vector + /// Calculates a vector with values being absolute values of that vector. /// - /// Absolute vector Double4 GetAbsolute() const { return Double4(Math::Abs(X), Math::Abs(Y), Math::Abs(Z), Math::Abs(W)); } /// - /// Calculates a vector with values being opposite to values of that vector + /// Calculates a vector with values being opposite to values of that vector. /// - /// Negative vector Double4 GetNegative() const { return Double4(-X, -Y, -Z, -W); } /// - /// Returns average arithmetic of all the components + /// Returns the average arithmetic of all the components. /// - /// Average arithmetic of all the components double AverageArithmetic() const { return (X + Y + Z + W) * 0.25; } /// - /// Gets sum of all vector components values + /// Gets the sum of all vector components values. /// - /// Sum of X, Y, Z and W double SumValues() const { return X + Y + Z + W; } /// - /// Returns minimum value of all the components + /// Returns the minimum value of all the components. /// - /// Minimum value double MinValue() const { return Math::Min(X, Y, Z, W); } /// - /// Returns maximum value of all the components + /// Returns the maximum value of all the components. /// - /// Maximum value double MaxValue() const { return Math::Max(X, Y, Z, W); } /// - /// Returns true if vector has one or more components is not a number (NaN) + /// Returns true if vector has one or more components is not a number (NaN). /// - /// True if one or more components is not a number (NaN) bool IsNaN() const { return isnan(X) || isnan(Y) || isnan(Z) || isnan(W); } /// - /// Returns true if vector has one or more components equal to +/- infinity + /// Returns true if vector has one or more components equal to +/- infinity. /// - /// True if one or more components equal to +/- infinity bool IsInfinity() const { return isinf(X) || isinf(Y) || isinf(Z) || isinf(W); } /// - /// Returns true if vector has one or more components equal to +/- infinity or NaN + /// Returns true if vector has one or more components equal to +/- infinity or NaN. /// - /// True if one or more components equal to +/- infinity or NaN bool IsNanOrInfinity() const { return IsInfinity() || IsNaN(); } public: - // Arithmetic operators with Double4 inline Double4 operator+(const Double4& b) const { @@ -406,7 +349,6 @@ public: } public: - static bool NearEqual(const Double4& a, const Double4& b) { return Math::NearEqual(a.X, b.X) && Math::NearEqual(a.Y, b.Y) && Math::NearEqual(a.Z, b.Z) && Math::NearEqual(a.W, b.W); @@ -418,7 +360,6 @@ public: } public: - static void Add(const Double4& a, const Double4& b, Double4& result) { result.X = a.X + b.X; @@ -475,7 +416,6 @@ public: static Double4 Ceil(const Double4& v); public: - // Restricts a value to be within a specified range // @param value The value to clamp // @param min The minimum value, diff --git a/Source/Engine/Core/Math/Int2.h b/Source/Engine/Core/Math/Int2.h index d01756848..836d4a38c 100644 --- a/Source/Engine/Core/Math/Int2.h +++ b/Source/Engine/Core/Math/Int2.h @@ -11,9 +11,8 @@ /// API_STRUCT() struct FLAXENGINE_API Int2 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Int2); + DECLARE_SCRIPTING_TYPE_MINIMAL(Int2); public: - union { struct @@ -34,7 +33,6 @@ public: }; public: - // Vector with all components equal 0 static const Int2 Zero; @@ -48,7 +46,6 @@ public: static const Int2 Maximum; public: - /// /// Empty constructor. /// @@ -80,7 +77,7 @@ public: // Init // @param xyzw Int4 to use X and Y components Int2(const Int4& xyzw); - + // Init // @param xy Vector2 to use X and Y components explicit Int2(const Vector2& xy); @@ -92,13 +89,11 @@ public: // Init // @param xyzw Vector4 to use X and Y components explicit Int2(const Vector4& xyzw); - -public: +public: String ToString() const; public: - // Arithmetic operators with Int2 Int2 operator+(const Int2& b) const @@ -233,7 +228,6 @@ public: } public: - static void Add(const Int2& a, const Int2& b, Int2& result) { result.X = a.X + b.X; @@ -306,7 +300,7 @@ public: { return X == 1 && Y == 1; } - + /// /// Calculates a vector with values being opposite to values of that vector /// @@ -315,7 +309,7 @@ public: { return Int2(-X, -Y); } - + /// /// Returns average arithmetic of all the components /// @@ -352,7 +346,6 @@ public: return Math::Max(X, Y); } - // Returns a vector containing the smallest components of the specified vectors // @param a The first source vector // @param b The second source vector diff --git a/Source/Engine/Core/Math/Int3.h b/Source/Engine/Core/Math/Int3.h index 2a350ea84..989d4aeca 100644 --- a/Source/Engine/Core/Math/Int3.h +++ b/Source/Engine/Core/Math/Int3.h @@ -6,15 +6,13 @@ #include "Engine/Core/Formatting.h" #include "Engine/Core/Templates.h" - /// /// Three-components vector (32 bit integer type). /// API_STRUCT() struct FLAXENGINE_API Int3 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Int3); + DECLARE_SCRIPTING_TYPE_MINIMAL(Int3); public: - union { struct @@ -40,7 +38,6 @@ public: }; public: - // Vector with all components equal 0 static const Int3 Zero; @@ -54,7 +51,6 @@ public: static const Int3 Maximum; public: - /// /// Empty constructor. /// @@ -95,7 +91,7 @@ public: // @param v Vector2 to use X and Y components // @param z Z component value explicit Int3(const Vector2& xy, int32 z); - + // Init // @param v Vector3 to use X, Y and Z components explicit Int3(const Vector3& xyz); @@ -103,13 +99,11 @@ public: // Init // @param v Vector4 to use X and Y components explicit Int3(const Vector4& xyzw); - -public: +public: String ToString() const; public: - // Arithmetic operators with Int2 Int3 operator+(const Int3& b) const @@ -244,7 +238,6 @@ public: } public: - static void Add(const Int3& a, const Int3& b, Int3& result) { result.X = a.X + b.X; @@ -294,7 +287,6 @@ public: } public: - /// /// Gets a value indicting whether this vector is zero. /// @@ -321,7 +313,7 @@ public: { return X == 1 && Y == 1 && Z == 1; } - + /// /// Calculates a vector with values being opposite to values of that vector /// @@ -330,7 +322,7 @@ public: { return Int3(-X, -Y, -Z); } - + /// /// Returns average arithmetic of all the components /// @@ -366,7 +358,7 @@ public: { return Math::Max(X, Y, Z); } - + // Returns a vector containing the largest components of the specified vectors // @param a The first source vector // @param b The second source vector diff --git a/Source/Engine/Core/Math/Int4.h b/Source/Engine/Core/Math/Int4.h index 296fb1da0..0896cc05a 100644 --- a/Source/Engine/Core/Math/Int4.h +++ b/Source/Engine/Core/Math/Int4.h @@ -11,9 +11,8 @@ /// API_STRUCT() struct FLAXENGINE_API Int4 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Int4); + DECLARE_SCRIPTING_TYPE_MINIMAL(Int4); public: - union { struct @@ -44,7 +43,6 @@ public: }; public: - // Vector with all components equal 0 static const Int4 Zero; @@ -56,9 +54,8 @@ public: // A maximum Int4 static const Int4 Maximum; - -public: +public: /// /// Empty constructor. /// @@ -110,17 +107,15 @@ public: // @param v Vector3 to use X , Y and Z components // @param w W component value explicit Int4(const Vector3& xyz, int32 w); - + // Init // @param v Vector to use X, Y, Z and W components explicit Int4(const Vector4& xyzw); public: - String ToString() const; public: - // Arithmetic operators with Int2 Int4 operator+(const Int4& b) const @@ -255,7 +250,6 @@ public: } public: - static void Add(const Int4& a, const Int4& b, Int4& result) { result.X = a.X + b.X; @@ -305,9 +299,8 @@ public: { return Int4(a.X / b, a.Y / b, a.Z / b, a.Y / b); } - -public: +public: /// /// Gets a value indicting whether this vector is zero. /// @@ -334,7 +327,7 @@ public: { return X == 1 && Y == 1 && Z == 1 && W == 1; } - + /// /// Calculates a vector with values being opposite to values of that vector /// @@ -343,7 +336,7 @@ public: { return Int4(-X, -Y, -Z, -W); } - + /// /// Returns average arithmetic of all the components /// @@ -379,7 +372,7 @@ public: { return Math::Max(X, Y, Z, W); } - + // Returns a vector containing the largest components of the specified vectors // @param a The first source vector // @param b The second source vector diff --git a/Source/Engine/Core/Math/Matrix.h b/Source/Engine/Core/Math/Matrix.h index feb7c8160..14731b369 100644 --- a/Source/Engine/Core/Math/Matrix.h +++ b/Source/Engine/Core/Math/Matrix.h @@ -13,9 +13,8 @@ struct Transform; /// API_STRUCT() struct FLAXENGINE_API Matrix { -DECLARE_SCRIPTING_TYPE_MINIMAL(Matrix); + DECLARE_SCRIPTING_TYPE_MINIMAL(Matrix); public: - union { struct @@ -74,7 +73,6 @@ public: }; public: - /// A matrix with all of its components set to zero. static const Matrix Zero; @@ -82,7 +80,6 @@ public: static const Matrix Identity; public: - /// /// Empty constructor. /// @@ -153,11 +150,9 @@ public: explicit Matrix(const Matrix3x3& matrix); public: - String ToString() const; public: - // Gets the up Vector3 of the matrix; that is M21, M22, and M23. Vector3 GetUp() const { @@ -430,7 +425,6 @@ public: float RotDeterminant() const; public: - // Inverts the matrix. void Invert() { @@ -449,7 +443,6 @@ public: void NormalizeScale(); public: - /// /// Decomposes a rotation matrix with the specified yaw, pitch, roll. /// @@ -492,7 +485,6 @@ public: void Decompose(Vector3& scale, Matrix& rotation, Vector3& translation) const; public: - Matrix operator*(const float scale) const { Matrix result; @@ -553,7 +545,6 @@ public: } public: - // Calculates the sum of two matrices. // @param left The first matrix to add. // @param right The second matrix to add. @@ -1141,7 +1132,6 @@ public: static void CreateFromAxisAngle(const Vector3& axis, float angle, Matrix& result); public: - static Vector4 TransformPosition(const Matrix& m, const Vector3& v); static Vector4 TransformPosition(const Matrix& m, const Vector4& v); }; diff --git a/Source/Engine/Core/Math/Matrix3x3.h b/Source/Engine/Core/Math/Matrix3x3.h index f005abc3a..082601b8a 100644 --- a/Source/Engine/Core/Math/Matrix3x3.h +++ b/Source/Engine/Core/Math/Matrix3x3.h @@ -12,7 +12,6 @@ API_STRUCT(InBuild) struct FLAXENGINE_API Matrix3x3 { public: - union { struct @@ -50,7 +49,6 @@ public: }; public: - /// /// A matrix with all of its components set to zero. /// @@ -62,7 +60,6 @@ public: static const Matrix3x3 Identity; public: - /// /// Empty constructor. /// @@ -120,11 +117,9 @@ public: explicit Matrix3x3(const Matrix& matrix); public: - String ToString() const; public: - // Gets the first row in the matrix; that is M11, M12 and M13. Vector3 GetRow1() const { @@ -244,7 +239,6 @@ public: } public: - /// /// Inverts the Matrix3x3. /// @@ -267,7 +261,6 @@ public: void NormalizeScale(); public: - /// /// Calculates the inverse of the specified Matrix3x3. /// @@ -307,7 +300,6 @@ public: } public: - /// /// Determines the sum of two matrices. /// @@ -435,7 +427,6 @@ public: } public: - /// /// Creates 2D translation matrix. /// @@ -491,7 +482,6 @@ public: } public: - /// /// Creates a rotation matrix from a quaternion /// @@ -512,7 +502,6 @@ public: static void RotationQuaternion(const Quaternion& rotation, Matrix3x3& result); public: - /// /// Tests for equality between two objects. /// diff --git a/Source/Engine/Core/Math/OrientedBoundingBox.h b/Source/Engine/Core/Math/OrientedBoundingBox.h index a1e8236ab..e55920404 100644 --- a/Source/Engine/Core/Math/OrientedBoundingBox.h +++ b/Source/Engine/Core/Math/OrientedBoundingBox.h @@ -11,7 +11,6 @@ API_STRUCT(InBuild) struct FLAXENGINE_API OrientedBoundingBox { public: - // Half lengths of the box along each axis. Vector3 Extents; @@ -19,7 +18,6 @@ public: Matrix Transformation; public: - /// /// Empty constructor. /// @@ -58,11 +56,9 @@ public: OrientedBoundingBox(Vector3 points[], int32 pointCount); public: - String ToString() const; public: - // Gets the eight corners of the bounding box. void GetCorners(Vector3 corners[8]) const; @@ -98,7 +94,6 @@ public: void GetBoundingBox(BoundingBox& result) const; public: - // Transforms this box using a transformation matrix. // @param mat The transformation matrix. void Transform(const Matrix& matrix); @@ -127,7 +122,6 @@ public: } public: - FORCE_INLINE bool operator==(const OrientedBoundingBox& other) const { return Extents == other.Extents && Transformation == other.Transformation; @@ -146,7 +140,6 @@ public: } private: - static void GetRows(const Matrix& mat, Vector3 rows[3]) { rows[0] = Vector3(mat.M11, mat.M12, mat.M13); @@ -155,7 +148,6 @@ private: } public: - /// /// Creates the centered box (axis aligned). /// @@ -183,7 +175,6 @@ public: } public: - // Determines whether a OBB contains a point. // @param point The point to test. // @returns The type of containment the two objects have. diff --git a/Source/Engine/Core/Math/Plane.h b/Source/Engine/Core/Math/Plane.h index 280d431c5..dc34ac6f8 100644 --- a/Source/Engine/Core/Math/Plane.h +++ b/Source/Engine/Core/Math/Plane.h @@ -10,14 +10,12 @@ /// API_STRUCT() struct FLAXENGINE_API Plane { -DECLARE_SCRIPTING_TYPE_MINIMAL(Plane); + DECLARE_SCRIPTING_TYPE_MINIMAL(Plane); public: - static const float DistanceEpsilon; static const float NormalEpsilon; public: - /// /// The normal vector of the plane. /// @@ -29,7 +27,6 @@ public: API_FIELD() float D; public: - /// /// Empty constructor. /// @@ -91,11 +88,9 @@ public: Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3); public: - String ToString() const; public: - /// /// Changes the coefficients of the normal vector of the plane to make it of unit length. /// @@ -128,7 +123,6 @@ public: void Shadow(const Vector4& light, Matrix& result) const; public: - // Scales a plane by the given value // @param scale The amount by which to scale the plane // @param plane The plane to scale @@ -154,7 +148,6 @@ public: } public: - void Translate(const Vector3& translation) { const Vector3 mul = Normal * translation; @@ -176,7 +169,6 @@ public: } public: - static Vector3 Intersection(const Plane& inPlane1, const Plane& inPlane2, const Plane& inPlane3) { // intersection point with 3 planes @@ -214,7 +206,6 @@ public: } public: - // Determines if there is an intersection between the current object and a point // @param point The point to test // @returns Whether the two objects intersected @@ -301,7 +292,6 @@ public: } public: - // Scales the plane by the given scaling factor // @param value The plane to scale // @param scale The amount by which to scale the plane diff --git a/Source/Engine/Core/Math/Quaternion.h b/Source/Engine/Core/Math/Quaternion.h index 77e3a51fe..53ac31e28 100644 --- a/Source/Engine/Core/Math/Quaternion.h +++ b/Source/Engine/Core/Math/Quaternion.h @@ -17,9 +17,8 @@ struct Matrix3x3; /// API_STRUCT() struct FLAXENGINE_API Quaternion { -DECLARE_SCRIPTING_TYPE_MINIMAL(Quaternion); + DECLARE_SCRIPTING_TYPE_MINIMAL(Quaternion); public: - union { struct @@ -52,7 +51,6 @@ public: }; public: - /// /// Quaternion with all components equal 0. /// @@ -69,7 +67,6 @@ public: static Quaternion Identity; public: - /// /// Empty constructor. /// @@ -111,11 +108,9 @@ public: explicit Quaternion(const Vector4& value); public: - String ToString() const; public: - /// /// Gets a value indicating whether this instance is equivalent to the identity quaternion. /// @@ -283,7 +278,6 @@ public: void Multiply(const Quaternion& other); public: - /// /// Adds two quaternions. /// @@ -406,7 +400,6 @@ public: } public: - /// /// Determines whether the specified structures are equal. /// @@ -431,7 +424,6 @@ public: } public: - /// /// Calculates the inverse of the specified quaternion. /// diff --git a/Source/Engine/Core/Math/Ray.h b/Source/Engine/Core/Math/Ray.h index dbf2439a9..13952ed55 100644 --- a/Source/Engine/Core/Math/Ray.h +++ b/Source/Engine/Core/Math/Ray.h @@ -13,9 +13,8 @@ struct Viewport; /// API_STRUCT() struct FLAXENGINE_API Ray { -DECLARE_SCRIPTING_TYPE_MINIMAL(Ray); + DECLARE_SCRIPTING_TYPE_MINIMAL(Ray); public: - /// /// The position in three dimensional space where the ray starts. /// @@ -27,14 +26,12 @@ public: API_FIELD() Vector3 Direction; public: - /// /// Identity ray (at zero origin pointing forwards). /// static Ray Identity; public: - /// /// Empty constructor. /// @@ -54,11 +51,9 @@ public: } public: - String ToString() const; public: - FORCE_INLINE bool operator==(const Ray& other) const { return Position == other.Position && Direction == other.Direction; @@ -80,7 +75,6 @@ public: } public: - /// /// Gets a point at distance long ray. /// @@ -260,7 +254,6 @@ public: } public: - /// /// Calculates a world space ray from 2d screen coordinates. /// diff --git a/Source/Engine/Core/Math/Rectangle.h b/Source/Engine/Core/Math/Rectangle.h index 08ef0cc8e..a7a6d235e 100644 --- a/Source/Engine/Core/Math/Rectangle.h +++ b/Source/Engine/Core/Math/Rectangle.h @@ -9,7 +9,7 @@ /// API_STRUCT() struct FLAXENGINE_API Rectangle { -DECLARE_SCRIPTING_TYPE_MINIMAL(Rectangle); + DECLARE_SCRIPTING_TYPE_MINIMAL(Rectangle); /// /// The empty rectangle. @@ -17,7 +17,6 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(Rectangle); static Rectangle Empty; public: - /// /// Rectangle location (coordinates of the upper-left corner) /// @@ -29,7 +28,6 @@ public: API_FIELD() Vector2 Size; public: - /// /// Empty constructor. /// @@ -58,11 +56,9 @@ public: } public: - String ToString() const; public: - // Returns width of the rectangle float GetWidth() const { @@ -145,7 +141,6 @@ public: } public: - // Offset rectangle Location point // @param v Offset to add // @returns Result rectangle @@ -208,7 +203,6 @@ public: } public: - static bool NearEqual(const Rectangle& a, const Rectangle& b) { return Vector2::NearEqual(a.Location, b.Location) && Vector2::NearEqual(a.Size, b.Size); @@ -220,7 +214,6 @@ public: } public: - // Checks if rectangle contains given point // @param location Point location to check // @returns True if point is inside rectangle's area @@ -237,7 +230,6 @@ public: bool Intersects(const Rectangle& value) const; public: - // Offset rectangle position // @param x X coordinate offset // @param y Y coordinate offset @@ -253,7 +245,6 @@ public: Rectangle MakeOffsetted(const Vector2& offset) const; public: - // Expand rectangle area in all directions by given amount // @param toExpand Amount of units to expand a rectangle void Expand(float toExpand); @@ -264,7 +255,6 @@ public: Rectangle MakeExpanded(float toExpand) const; public: - // Scale rectangle area in all directions by given amount // @param scale Scale value to expand a rectangle void Scale(float scale); @@ -275,7 +265,6 @@ public: Rectangle MakeScaled(float scale) const; public: - // Calculates a rectangle that contains the union of rectangle and the arbitrary point // @param a The rectangle // @param b The point diff --git a/Source/Engine/Core/Math/Transform.h b/Source/Engine/Core/Math/Transform.h index 807c535d1..bcfd57ea4 100644 --- a/Source/Engine/Core/Math/Transform.h +++ b/Source/Engine/Core/Math/Transform.h @@ -13,7 +13,7 @@ struct Matrix; /// API_STRUCT() struct FLAXENGINE_API Transform { -DECLARE_SCRIPTING_TYPE_MINIMAL(Transform); + DECLARE_SCRIPTING_TYPE_MINIMAL(Transform); /// /// The translation vector of the transform. @@ -31,14 +31,12 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(Transform); API_FIELD(Attributes="EditorOrder(30), Limit(float.MinValue, float.MaxValue, 0.01f)") Vector3 Scale; public: - /// /// An identity transform. /// static Transform Identity; public: - /// /// Empty constructor. /// @@ -83,11 +81,9 @@ public: } public: - String ToString() const; public: - /// /// Checks if transform is an identity transformation /// @@ -116,7 +112,6 @@ public: } public: - /// /// Gets rotation matrix (from Orientation) /// @@ -148,7 +143,6 @@ public: void GetWorld(Matrix& result) const; public: - /// /// Adds translation to this transform. /// @@ -250,7 +244,6 @@ public: void WorldToLocal(const Vector3* points, int32 pointsCount, Vector3* result) const; public: - FORCE_INLINE Transform operator*(const Transform& other) const { return LocalToWorld(other); @@ -292,7 +285,6 @@ public: } public: - FORCE_INLINE Vector3 GetRight() const { return Vector3::Transform(Vector3::Right, Orientation); @@ -312,7 +304,7 @@ public: { return Vector3::Transform(Vector3::Down, Orientation); } - + FORCE_INLINE Vector3 GetForward() const { return Vector3::Transform(Vector3::Forward, Orientation); @@ -324,7 +316,6 @@ public: } public: - static Transform Lerp(const Transform& t1, const Transform& t2, float amount); static void Lerp(const Transform& t1, const Transform& t2, float amount, Transform& result); }; diff --git a/Source/Engine/Core/Math/Triangle.h b/Source/Engine/Core/Math/Triangle.h index a830f7e3e..99b991c1e 100644 --- a/Source/Engine/Core/Math/Triangle.h +++ b/Source/Engine/Core/Math/Triangle.h @@ -11,7 +11,6 @@ struct FLAXENGINE_API Triangle { public: - /// /// The first vertex. /// @@ -28,7 +27,6 @@ public: Vector3 V2; public: - /// /// Empty constructor. /// @@ -50,14 +48,12 @@ public: } public: - Vector3 GetNormal() const { return Vector3::Normalize((V1 - V0) ^ (V2 - V0)); } public: - // Determines if there is an intersection between the current object and a Ray // @param ray The ray to test // @returns Whether the two objects intersected diff --git a/Source/Engine/Core/Math/Vector2.h b/Source/Engine/Core/Math/Vector2.h index 94837533d..0bf004124 100644 --- a/Source/Engine/Core/Math/Vector2.h +++ b/Source/Engine/Core/Math/Vector2.h @@ -22,9 +22,8 @@ struct Matrix; /// API_STRUCT() struct FLAXENGINE_API Vector2 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Vector2); + DECLARE_SCRIPTING_TYPE_MINIMAL(Vector2); public: - union { struct @@ -45,7 +44,6 @@ public: }; public: - // Vector with all components equal 0 static const Vector2 Zero; @@ -65,7 +63,6 @@ public: static const Vector2 Maximum; public: - /// /// Empty constructor. /// @@ -90,48 +87,20 @@ public: { } - // Init - // @param v Int2 to use X and Y components explicit Vector2(const Int2& xy); - - // Init - // @param v Int3 to use X and Y components explicit Vector2(const Int3& xyz); - - // Init - // @param v Int4 to use X and Y components explicit Vector2(const Int4& xyzw); - - // Init - // @param v Vector3 to use X and Y components explicit Vector2(const Vector3& xyz); - - // Init - // @param v Vector4 to use X and Y components explicit Vector2(const Vector4& xyzw); - - // Init - // @param xy Double2 to use X and Y components Vector2(const Double2& xy); - - // Init - // @param xyz Double3 to use X and Y components explicit Vector2(const Double3& xyz); - - // Init - // @param xyzw Double4 to use X and Y components explicit Vector2(const Double4& xyzw); - - // Init - // @param color Color value explicit Vector2(const Color& color); public: - String ToString() const; public: - // Arithmetic operators with Vector2 Vector2 operator+(const Vector2& b) const { @@ -261,7 +230,6 @@ public: } public: - static bool NearEqual(const Vector2& a, const Vector2& b) { return Math::NearEqual(a.X, b.X) && Math::NearEqual(a.Y, b.Y); @@ -273,7 +241,6 @@ public: } public: - static float Dot(const Vector2& a, const Vector2& b) { return a.X * b.X + a.Y * b.Y; @@ -385,137 +352,125 @@ public: } public: - - // Gets a value indicting whether this instance is normalized + // Gets a value indicting whether this instance is normalized. bool IsNormalized() const { return Math::IsOne(X * X + Y * Y); } - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsZero() const { return Math::IsZero(X) && Math::IsZero(Y); } - // Gets a value indicting whether any vector component is zero + // Gets a value indicting whether any vector component is zero. bool IsAnyZero() const { return Math::IsZero(X) || Math::IsZero(Y); } - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsOne() const { return Math::IsOne(X) && Math::IsOne(Y); } - // Calculates length of the vector - // @returns Length of the vector + // Calculates the length of the vector. float Length() const { return Math::Sqrt(X * X + Y * Y); } - // Calculates the squared length of the vector - // @returns The squared length of the vector + // Calculates the squared length of the vector. float LengthSquared() const { return X * X + Y * Y; } - // Calculates inverted length of the vector (1 / Length()) + // Calculates inverted length of the vector (1 / length). float InvLength() const { return 1.0f / Length(); } - // Calculates a vector with values being absolute values of that vector + // Calculates a vector with values being absolute values of that vector. Vector2 GetAbsolute() const { return Vector2(Math::Abs(X), Math::Abs(Y)); } - // Calculates a vector with values being opposite to values of that vector + // Calculates a vector with values being opposite to values of that vector. Vector2 GetNegative() const { return Vector2(-X, -Y); } /// - /// Returns average arithmetic of all the components + /// Returns the average arithmetic of all the components. /// - /// Average arithmetic of all the components float AverageArithmetic() const { return (X + Y) * 0.5f; } /// - /// Gets sum of all vector components values + /// Gets the sum of all vector components values. /// - /// Sum of X,Y and Z float SumValues() const { return X + Y; } /// - /// Gets multiplication result of all vector components values + /// Gets the multiplication result of all vector components values. /// - /// X * Y float MulValues() const { return X * Y; } /// - /// Returns minimum value of all the components + /// Returns the minimum value of all the components. /// - /// Minimum value float MinValue() const { return Math::Min(X, Y); } /// - /// Returns maximum value of all the components + /// Returns the maximum value of all the components. /// - /// Maximum value float MaxValue() const { return Math::Max(X, Y); } /// - /// Returns true if vector has one or more components is not a number (NaN) + /// Returns true if vector has one or more components is not a number (NaN). /// - /// True if one or more components is not a number (NaN) bool IsNaN() const { return isnan(X) || isnan(Y); } /// - /// Returns true if vector has one or more components equal to +/- infinity + /// Returns true if vector has one or more components equal to +/- infinity. /// - /// True if one or more components equal to +/- infinity bool IsInfinity() const { return isinf(X) || isinf(Y); } /// - /// Returns true if vector has one or more components equal to +/- infinity or NaN + /// Returns true if vector has one or more components equal to +/- infinity or NaN. /// - /// True if one or more components equal to +/- infinity or NaN bool IsNanOrInfinity() const { return IsInfinity() || IsNaN(); } public: - // Performs a linear interpolation between two vectors // @param start Start vector // @param end End vector @@ -605,7 +560,6 @@ public: } public: - /// /// Calculates the area of the triangle. /// @@ -614,15 +568,14 @@ public: /// The third triangle vertex. /// The triangle area. static float TriangleArea(const Vector2& v0, const Vector2& v1, const Vector2& v2); - - /// + + /// /// Calculates the angle (in radians) between from and to. This is always the smallest value. /// /// The first vector. /// The second vector. /// The angle (in radians). static float Angle(const Vector2& from, const Vector2& to); - }; inline Vector2 operator+(float a, const Vector2& b) diff --git a/Source/Engine/Core/Math/Vector3.h b/Source/Engine/Core/Math/Vector3.h index 9ab6bf450..82d7b6ea5 100644 --- a/Source/Engine/Core/Math/Vector3.h +++ b/Source/Engine/Core/Math/Vector3.h @@ -132,7 +132,6 @@ public: { } - explicit Vector3(const Vector2& xy, float z); explicit Vector3(const Vector2& xy); explicit Vector3(const Int2& xy, float z); @@ -358,7 +357,7 @@ public: { return Dot(*this, b); } - + Vector3& operator+=(const Vector3& b) { X += b.X; @@ -390,7 +389,7 @@ public: Z /= b.Z; return *this; } - + Vector3 operator+(float b) const { return Vector3(X + b, Y + b, Z + b); @@ -410,7 +409,7 @@ public: { return Vector3(X / b, Y / b, Z / b); } - + Vector3& operator+=(float b) { *this = Add(*this, b); @@ -434,7 +433,7 @@ public: *this = Divide(*this, b); return *this; } - + bool operator==(const Vector3& b) const { return X == b.X && Y == b.Y && Z == b.Z; diff --git a/Source/Engine/Core/Math/Vector4.h b/Source/Engine/Core/Math/Vector4.h index 4521d7d63..7df59e902 100644 --- a/Source/Engine/Core/Math/Vector4.h +++ b/Source/Engine/Core/Math/Vector4.h @@ -24,9 +24,8 @@ struct Int4; /// API_STRUCT() struct FLAXENGINE_API Vector4 { -DECLARE_SCRIPTING_TYPE_MINIMAL(Vector4); + DECLARE_SCRIPTING_TYPE_MINIMAL(Vector4); public: - union { struct @@ -59,7 +58,6 @@ public: }; public: - // Vector with all components equal 0 static const Vector4 Zero; @@ -85,7 +83,6 @@ public: static const Vector4 Maximum; public: - /// /// Empty constructor. /// @@ -120,169 +117,113 @@ public: { } - // Init - // @param xy X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Vector4(const Vector2& xy, float z, float w); - - // Init - // @param xy X and Y values in the vector - // @param zw Z and W values in the vector - // @param z Z component value - // @param w W component value explicit Vector4(const Vector2& xy, const Vector2& zw); - - // Init - // @param xyz X, Y and Z values in the vector - // @param w W component value explicit Vector4(const Vector3& xyz, float w); - - // Init - // @param xy X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Vector4(const Int2& xy, float z, float w); - - // Init - // @param xyz X, Y and Z values in the vector - // @param w W component value explicit Vector4(const Int3& xyz, float w); - - // Init - // @param color Int4 value explicit Vector4(const Int4& xyzw); - - // Init - // @param xy Double2. X and Y values in the vector - // @param z Z component value - // @param w W component value explicit Vector4(const Double2& xy, float z, float w); - - // Init - // @param xyz Double3. X, Y and Z values in the vector - // @param w W component value explicit Vector4(const Double3& xyz, float w); - - // Init - // @param xyzw Double4 value Vector4(const Double4& xyzw); - - // Init - // @param color Color value explicit Vector4(const Color& color); - - // Init - // @param rect Rectangle value explicit Vector4(const Rectangle& rect); public: - String ToString() const; public: - - // Gets a value indicting whether this vector is zero + // Gets a value indicting whether this vector is zero. bool IsZero() const { return Math::IsZero(X) && Math::IsZero(Y) && Math::IsZero(Z) && Math::IsZero(W); } - // Gets a value indicting whether any vector component is zero + // Gets a value indicting whether any vector component is zero. bool IsAnyZero() const { return Math::IsZero(X) || Math::IsZero(Y) || Math::IsZero(Z) || Math::IsZero(W); } - // Gets a value indicting whether this vector is one + // Gets a value indicting whether this vector is one. bool IsOne() const { return Math::IsOne(X) && Math::IsOne(Y) && Math::IsOne(Z) && Math::IsOne(W); } /// - /// Calculates a vector with values being absolute values of that vector + /// Calculates a vector with values being absolute values of that vector. /// - /// Absolute vector Vector4 GetAbsolute() const { return Vector4(Math::Abs(X), Math::Abs(Y), Math::Abs(Z), Math::Abs(W)); } /// - /// Calculates a vector with values being opposite to values of that vector + /// Calculates a vector with values being opposite to values of that vector. /// - /// Negative vector Vector4 GetNegative() const { return Vector4(-X, -Y, -Z, -W); } /// - /// Returns average arithmetic of all the components + /// Returns the average arithmetic of all the components. /// - /// Average arithmetic of all the components float AverageArithmetic() const { return (X + Y + Z + W) * 0.25f; } /// - /// Gets sum of all vector components values + /// Gets the sum of all vector components values. /// - /// Sum of X, Y, Z and W float SumValues() const { return X + Y + Z + W; } /// - /// Returns minimum value of all the components + /// Returns the minimum value of all the components. /// - /// Minimum value float MinValue() const { return Math::Min(X, Y, Z, W); } /// - /// Returns maximum value of all the components + /// Returns the maximum value of all the components. /// - /// Maximum value float MaxValue() const { return Math::Max(X, Y, Z, W); } /// - /// Returns true if vector has one or more components is not a number (NaN) + /// Returns true if vector has one or more components is not a number (NaN). /// - /// True if one or more components is not a number (NaN) bool IsNaN() const { return isnan(X) || isnan(Y) || isnan(Z) || isnan(W); } /// - /// Returns true if vector has one or more components equal to +/- infinity + /// Returns true if vector has one or more components equal to +/- infinity. /// - /// True if one or more components equal to +/- infinity bool IsInfinity() const { return isinf(X) || isinf(Y) || isinf(Z) || isinf(W); } /// - /// Returns true if vector has one or more components equal to +/- infinity or NaN + /// Returns true if vector has one or more components equal to +/- infinity or NaN. /// - /// True if one or more components equal to +/- infinity or NaN bool IsNanOrInfinity() const { return IsInfinity() || IsNaN(); } public: - // Arithmetic operators with Vector4 inline Vector4 operator+(const Vector4& b) const { @@ -407,7 +348,6 @@ public: } public: - static bool NearEqual(const Vector4& a, const Vector4& b) { return Math::NearEqual(a.X, b.X) && Math::NearEqual(a.Y, b.Y) && Math::NearEqual(a.Z, b.Z) && Math::NearEqual(a.W, b.W); @@ -419,7 +359,6 @@ public: } public: - static void Add(const Vector4& a, const Vector4& b, Vector4& result) { result.X = a.X + b.X; @@ -476,7 +415,6 @@ public: static Vector4 Ceil(const Vector4& v); public: - // Restricts a value to be within a specified range // @param value The value to clamp // @param min The minimum value, diff --git a/Source/Engine/Core/Math/Viewport.h b/Source/Engine/Core/Math/Viewport.h index 6a7165b59..62dd3fa5b 100644 --- a/Source/Engine/Core/Math/Viewport.h +++ b/Source/Engine/Core/Math/Viewport.h @@ -13,7 +13,6 @@ struct Rectangle; API_STRUCT(InBuild) struct FLAXENGINE_API Viewport { public: - union { struct @@ -51,7 +50,6 @@ public: float MaxDepth; public: - /// /// Empty constructor. /// @@ -110,11 +108,9 @@ public: Viewport(const Rectangle& bounds); public: - String ToString() const; public: - // Gets the aspect ratio used by the viewport // @returns The aspect ratio float GetAspectRatio() const @@ -135,7 +131,6 @@ public: void SetBounds(const Rectangle& bounds); public: - bool operator==(const Viewport& other) const { return X == other.X && Y == other.Y && Width == other.Width && Height == other.Height && MinDepth == other.MinDepth && MaxDepth == other.MaxDepth; @@ -147,7 +142,6 @@ public: } public: - // Projects a 3D vector from object space into screen space // @param source The vector to project // @param vp A combined WorldViewProjection matrix