diff --git a/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp b/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp index 0cb4fc6ad..c4753661b 100644 --- a/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp +++ b/Source/Editor/Scripting/CodeEditors/VisualStudio/VisualStudioConnection.cpp @@ -183,12 +183,6 @@ namespace VisualStudio } }; - // Scans the running processes to find a running Visual Studio instance with the specified version and open solution. - // - // @param[in] clsID Class ID of the specific Visual Studio version we are looking for. - // @param[in] solutionPath Path to the solution the instance needs to have open. - // @return DTE object that may be used to interact with the Visual Studio instance, or null if - // not found. static Result FindRunningInstance(ConnectionHandle connection) { HRESULT result; diff --git a/Source/Engine/Core/Math/BoundingBox.h b/Source/Engine/Core/Math/BoundingBox.h index 4a7202763..3fdfe5734 100644 --- a/Source/Engine/Core/Math/BoundingBox.h +++ b/Source/Engine/Core/Math/BoundingBox.h @@ -304,7 +304,7 @@ public: public: /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between box and a ray. /// /// The ray to test. /// Whether the two objects intersected. @@ -315,7 +315,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between box and a ray. /// /// The ray to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -326,7 +326,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between box and a ray. /// /// The ray to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -338,7 +338,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between box and a ray. /// /// The ray to test. /// When the method completes, contains the point of intersection, or if there was no intersection. @@ -349,7 +349,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Plane. + /// Determines if there is an intersection between box and a plane. /// /// The plane to test. /// Whether the two objects intersected. @@ -359,7 +359,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Bounding Box. + /// Determines if there is an intersection between two boxes. /// /// The box to test. /// Whether the two objects intersected. @@ -369,7 +369,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a Bounding Sphere. + /// Determines if there is an intersection between box and a sphere. /// /// The sphere to test. /// Whether the two objects intersected. @@ -379,7 +379,7 @@ public: } /// - /// Determines whether the current objects contains a point. + /// Determines whether box contains a point. /// /// The point to test. /// The type of containment the two objects have. @@ -389,7 +389,7 @@ public: } /// - /// Determines whether the current objects contains a Bounding Box. + /// Determines whether box contains a Bounding Box. /// /// The box to test. /// The type of containment the two objects have. @@ -399,7 +399,7 @@ public: } /// - /// Determines whether the current objects contains a Bounding Sphere. + /// Determines whether box contains a Bounding Sphere. /// /// The sphere to test. /// The type of containment the two objects have. @@ -409,7 +409,7 @@ public: } /// - /// Determines the distance between a Bounding Box and a point. + /// Determines the distance between box and a point. /// /// The point to test. /// The distance between bounding box and a point. @@ -419,7 +419,7 @@ public: } /// - /// Determines the distance between two Bounding Boxed. + /// Determines the distance between two boxes. /// /// The bounding box to test. /// The distance between bounding boxes. diff --git a/Source/Engine/Core/Math/BoundingSphere.h b/Source/Engine/Core/Math/BoundingSphere.h index 570fb1ae7..1cc3e324a 100644 --- a/Source/Engine/Core/Math/BoundingSphere.h +++ b/Source/Engine/Core/Math/BoundingSphere.h @@ -74,14 +74,14 @@ public: public: /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between sphere and a rat. /// /// The ray to test. /// Whether the two objects intersected. bool Intersects(const Ray& ray) const; /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between sphere and a rat. /// /// The ray to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -89,7 +89,7 @@ public: bool Intersects(const Ray& ray, Real& distance) const; /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between sphere and a rat. /// /// The ray to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -98,7 +98,7 @@ public: bool Intersects(const Ray& ray, Real& distance, Vector3& normal) const; /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between sphere and a rat. /// /// The ray to test. /// When the method completes, contains the point of intersection, or Vector3::Zero if there was no intersection. @@ -106,14 +106,14 @@ public: bool Intersects(const Ray& ray, Vector3& point) const; /// - /// Determines if there is an intersection between the current object and a Plane. + /// Determines if there is an intersection between sphere and a plane. /// /// The plane to test. /// Whether the two objects intersected. PlaneIntersectionType Intersects(const Plane& plane) const; /// - /// Determines if there is an intersection between the current object and a triangle. + /// Determines if there is an intersection between sphere and a triangle. /// /// The first vertex of the triangle to test. /// The second vertex of the triangle to test. @@ -122,28 +122,28 @@ public: bool Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3) const; /// - /// Determines if there is an intersection between the current object and a Bounding Box. + /// Determines if there is an intersection between sphere and a box. /// /// The box to test. /// Whether the two objects intersected. bool Intersects(const BoundingBox& box) const; /// - /// Determines if there is an intersection between the current object and a Bounding Sphere. + /// Determines if there is an intersection between two spheres. /// /// The sphere to test. /// Whether the two objects intersected. bool Intersects(const BoundingSphere& sphere) const; /// - /// Determines whether the current objects contains a point. + /// Determines whether sphere contains a point. /// /// The point to test. /// The type of containment the two objects have. ContainmentType Contains(const Vector3& point) const; /// - /// Determines whether the current objects contains a triangle. + /// Determines whether sphere contains a triangle. /// /// The first vertex of the triangle to test. /// The second vertex of the triangle to test. @@ -152,14 +152,14 @@ public: ContainmentType Contains(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3) const; /// - /// Determines whether the current objects contains a Bounding Box + /// Determines whether sphere contains a box. /// /// The box to test. /// The type of containment the two objects have. ContainmentType Contains(const BoundingBox& box) const; /// - /// Determines whether the current objects contains a Bounding Sphere. + /// Determines whether sphere contains a sphere. /// /// The sphere to test. /// The type of containment the two objects have. diff --git a/Source/Engine/Core/Math/Math.h b/Source/Engine/Core/Math/Math.h index 99792bbbd..2ce9e0d7d 100644 --- a/Source/Engine/Core/Math/Math.h +++ b/Source/Engine/Core/Math/Math.h @@ -290,20 +290,14 @@ namespace Math return dividend / divisor; } - // Check if value is inside the given range - // @param value value to check - // @param min Minimum value - // @param max Maximum value + // Checks if value is inside the given range. template static bool IsInRange(const T value, const T min, const T max) { return value >= min && value <= max; } - // Check if value isn't inside the given range - // @param value value to check - // @param min Minimum value - // @param max Maximum value + // Checks if value isn't inside the given range. template static bool IsNotInRange(const T value, const T min, const T max) { @@ -311,21 +305,19 @@ namespace Math } // Checks whether a number is a power of two. - // @param value Number to check - // @returns True if value is a power of two static bool IsPowerOfTwo(uint32 value) { return (value & value - 1) == 0; } - // Clamp value to be between minimum and maximum values, inclusive + // Clamps value to be between minimum and maximum values, inclusive template static T Clamp(const T value, const T min, const T max) { return value < min ? min : value < max ? value : max; } - // Clamp value to be between 0 and 1 range, inclusive + // Clamps value to be between 0 and 1 range, inclusive template static T Saturate(const T value) { @@ -478,54 +470,43 @@ namespace Math return Saturate((value - a) / (b - a)); } - // Performs smooth (cubic Hermite) interpolation between 0 and 1 - // @param amount Value between 0 and 1 indicating interpolation amount + // Performs smooth (cubic Hermite) interpolation between 0 and 1. static float SmoothStep(float amount) { return amount <= 0 ? 0 : amount >= 1 ? 1 : amount * amount * (3 - 2 * amount); } - // Performs a smooth(er) interpolation between 0 and 1 with 1st and 2nd order derivatives of zero at endpoints - // @param amount Value between 0 and 1 indicating interpolation amount + // Performs a smooth(er) interpolation between 0 and 1 with 1st and 2nd order derivatives of zero at endpoints. static float SmootherStep(float amount) { return amount <= 0 ? 0 : amount >= 1 ? 1 : amount * amount * amount * (amount * (amount * 6 - 15) + 10); } - // Determines whether the specified value is close to zero (0.0) - // @param a The integer value - // @returns True if the specified value is close to zero (0.0). otherwise false + // Determines whether the specified value is close to zero (0.0). inline int32 IsZero(int32 a) { return a == 0; } - // Determines whether the specified value is close to zero (0.0f) - // @param a The floating value - // @returns True if the specified value is close to zero (0.0f). otherwise false + // Determines whether the specified value is close to zero (0.0f). inline bool IsZero(float a) { return Abs(a) < ZeroTolerance; } - // Determines whether the specified value is close to one (1.0) - // @param a The integer value - // @returns True if the specified value is close to one (1.0). otherwise false + // Determines whether the specified value is close to one (1.0). inline bool IsOne(int32 a) { return a == 1; } - // Determines whether the specified value is close to one (1.0f) - // @param a The floating value - // @returns True if the specified value is close to one (1.0f). otherwise false + // Determines whether the specified value is close to one (1.0f). inline bool IsOne(float a) { return IsZero(a - 1.0f); } - // Returns a value indicating the sign of a number - // @returns A number that indicates the sign of value + // Returns a value indicating the sign of a number. inline float Sign(float v) { return v > 0.0f ? 1.0f : v < 0.0f ? -1.0f : 0.0f; diff --git a/Source/Engine/Core/Math/Mathd.h b/Source/Engine/Core/Math/Mathd.h index 1d22ea666..cb273e21b 100644 --- a/Source/Engine/Core/Math/Mathd.h +++ b/Source/Engine/Core/Math/Mathd.h @@ -165,38 +165,31 @@ namespace Math return TruncToInt(ceil(value)); } - // Performs smooth (cubic Hermite) interpolation between 0 and 1 - // @param amount Value between 0 and 1 indicating interpolation amount + // Performs smooth (cubic Hermite) interpolation between 0 and 1. static double SmoothStep(double amount) { return amount <= 0. ? 0. : amount >= 1. ? 1. : amount * amount * (3. - 2. * amount); } - // Performs a smooth(er) interpolation between 0 and 1 with 1st and 2nd order derivatives of zero at endpoints - // @param amount Value between 0 and 1 indicating interpolation amount + // Performs a smooth(er) interpolation between 0 and 1 with 1st and 2nd order derivatives of zero at endpoints. static double SmootherStep(double amount) { return amount <= 0. ? 0. : amount >= 1. ? 1. : amount * amount * amount * (amount * (amount * 6. - 15.) + 10.); } - // Determines whether the specified value is close to zero (0.0) - // @param a The floating value - // @returns True if the specified value is close to zero (0.0). otherwise false + // Determines whether the specified value is close to zero (0.0). inline bool IsZero(double a) { return Abs(a) < ZeroTolerance; } - // Determines whether the specified value is close to one (1.0f) - // @param a The floating value - // @returns True if the specified value is close to one (1.0f). otherwise false + // Determines whether the specified value is close to one (1.0f). inline bool IsOne(double a) { return IsZero(a - 1.); } - // Returns a value indicating the sign of a number - // @returns A number that indicates the sign of value + // Returns a value indicating the sign of a number. inline double Sign(double v) { return v > 0. ? 1. : v < 0. ? -1. : 0.; diff --git a/Source/Engine/Core/Math/Matrix.h b/Source/Engine/Core/Math/Matrix.h index 0ee31df4f..0eddc173b 100644 --- a/Source/Engine/Core/Math/Matrix.h +++ b/Source/Engine/Core/Math/Matrix.h @@ -531,27 +531,15 @@ public: public: // Calculates the sum of two matrices. - // @param left The first matrix to add. - // @param right The second matrix to add. - // @param result When the method completes, contains the sum of the two matrices. static void Add(const Matrix& left, const Matrix& right, Matrix& result); // Calculates the difference between two matrices. - // @param left The first matrix to subtract. - // @param right The second matrix to subtract. - // @param result When the method completes, contains the difference between the two matrices. static void Subtract(const Matrix& left, const Matrix& right, Matrix& result); // Scales a matrix by the given value. - // @param left The matrix to scale. - // @param right The amount by which to scale. - // @param result When the method completes, contains the scaled matrix. static void Multiply(const Matrix& left, float right, Matrix& result); // Calculates the product of two matrices. - // @param left The first matrix to multiply. - // @param right The second matrix to multiply. - // @returns The product of the two matrices. static Matrix Multiply(const Matrix& left, const Matrix& right) { Matrix result; @@ -560,40 +548,21 @@ public: } // Calculates the product of two matrices. - // @param left The first matrix to multiply. - // @param right The second matrix to multiply. - // @param result The product of the two matrices. static void Multiply(const Matrix& left, const Matrix& right, Matrix& result); // Scales a matrix by the given value. - // @param left The matrix to scale. - // @param right The amount by which to scale. - // @param result When the method completes, contains the scaled matrix. static void Divide(const Matrix& left, float right, Matrix& result); // Calculates the quotient of two matrices. - // @param left The first matrix to divide. - // @param right The second matrix to divide. - // @param result When the method completes, contains the quotient of the two matrices. static void Divide(const Matrix& left, const Matrix& right, Matrix& result); // Negates a matrix. - // @param value The matrix to be negated. - // @param result When the method completes, contains the negated matrix. static void Negate(const Matrix& value, Matrix& result); // Performs a linear interpolation between two matrices. - // @param start Start matrix. - // @param end End matrix. - // @param amount Value between 0 and 1 indicating the weight of end. - // @param result When the method completes, contains the linear interpolation of the two matrices. static void Lerp(const Matrix& start, const Matrix& end, float amount, Matrix& result); // Performs a cubic interpolation between two matrices. - // @param start Start matrix. - // @param end End matrix. - // @param amount Value between 0 and 1 indicating the weight of end. - // @param result When the method completes, contains the cubic interpolation of the two matrices. static void SmoothStep(const Matrix& start, const Matrix& end, float amount, Matrix& result) { amount = Math::SmoothStep(amount); @@ -601,13 +570,9 @@ public: } // Calculates the transpose of the specified matrix. - // @param value The matrix whose transpose is to be calculated. - // @returns The transpose of the specified matrix. static Matrix Transpose(const Matrix& value); // Calculates the transpose of the specified matrix. - // @param value The matrix whose transpose is to be calculated. - // @param result When the method completes, contains the transpose of the specified matrix. static void Transpose(const Matrix& value, Matrix& result); /// @@ -630,26 +595,12 @@ public: static void Invert(const Matrix& value, Matrix& result); // Creates a left-handed spherical billboard that rotates around a specified object position. - // @param objectPosition The position of the object around which the billboard will rotate. - // @param cameraPosition The position of the camera. - // @param cameraUpFloat The up vector of the camera. - // @param cameraForwardFloat The forward vector of the camera. - // @param result When the method completes, contains the created billboard matrix. static void Billboard(const Float3& objectPosition, const Float3& cameraPosition, const Float3& cameraUpFloat, const Float3& cameraForwardFloat, Matrix& result); // Creates a left-handed, look-at matrix. - // @param eye The position of the viewer's eye. - // @param target The camera look-at target. - // @param up The camera's up vector. - // @param result When the method completes, contains the created look-at matrix. static void LookAt(const Float3& eye, const Float3& target, const Float3& up, Matrix& result); // Creates a left-handed, orthographic projection matrix. - // @param width Width of the viewing volume. - // @param height Height of the viewing volume. - // @param zNear Minimum z-value of the viewing volume. - // @param zFar Maximum z-value of the viewing volume. - // @param result When the method completes, contains the created projection matrix. static void Ortho(float width, float height, float zNear, float zFar, Matrix& result) { const float halfWidth = width * 0.5f; @@ -658,21 +609,9 @@ public: } // Creates a left-handed, customized orthographic projection matrix. - // @param left Minimum x-value of the viewing volume. - // @param right Maximum x-value of the viewing volume. - // @param bottom Minimum y-value of the viewing volume. - // @param top Maximum y-value of the viewing volume. - // @param zNear Minimum z-value of the viewing volume. - // @param zFar Maximum z-value of the viewing volume. - // @param result When the method completes, contains the created projection matrix. static void OrthoOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, Matrix& result); // Creates a left-handed, perspective projection matrix. - // @param width Width of the viewing volume. - // @param height Height of the viewing volume. - // @param zNear Minimum z-value of the viewing volume. - // @param zFar Maximum z-value of the viewing volume. - // @param result When the method completes, contains the created projection matrix. static void Perspective(float width, float height, float zNear, float zFar, Matrix& result) { const float halfWidth = width * 0.5f; @@ -681,44 +620,24 @@ public: } // Creates a left-handed, perspective projection matrix based on a field of view. - // @param fov Field of view in the y direction, in radians. - // @param aspect Aspect ratio, defined as view space width divided by height. - // @param zNear Minimum z-value of the viewing volume. - // @param zFar Maximum z-value of the viewing volume. - // @param result When the method completes, contains the created projection matrix. static void PerspectiveFov(float fov, float aspect, float zNear, float zFar, Matrix& result); // Creates a left-handed, customized perspective projection matrix. - // @param left Minimum x-value of the viewing volume. - // @param right Maximum x-value of the viewing volume. - // @param bottom Minimum y-value of the viewing volume. - // @param top Maximum y-value of the viewing volume. - // @param zNear Minimum z-value of the viewing volume. - // @param zFar Maximum z-value of the viewing volume. - // @param result When the method completes, contains the created projection matrix. static void PerspectiveOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, Matrix& result); // Creates a matrix that scales along the x-axis, y-axis, and y-axis. - // @param scale Scaling factor for all three axes. - // @param result The created scaling matrix. static Matrix Scaling(const Float3& scale) { return Scaling(scale.X, scale.Y, scale.Z); } // Creates a matrix that scales along the x-axis, y-axis, and y-axis. - // @param scale Scaling factor for all three axes. - // @param result When the method completes, contains the created scaling matrix. static void Scaling(const Float3& scale, Matrix& result) { Scaling(scale.X, scale.Y, scale.Z, result); } // Creates a matrix that scales along the x-axis, y-axis, and y-axis. - // @param x Scaling factor that is applied along the x-axis. - // @param y Scaling factor that is applied along the y-axis. - // @param z Scaling factor that is applied along the z-axis. - // @returns The created scaling matrix. static Matrix Scaling(float x, float y, float z) { Matrix result = Identity; @@ -729,10 +648,6 @@ public: } // Creates a matrix that scales along the x-axis, y-axis, and y-axis. - // @param x Scaling factor that is applied along the x-axis. - // @param y Scaling factor that is applied along the y-axis. - // @param z Scaling factor that is applied along the z-axis. - // @param result When the method completes, contains the created scaling matrix. static void Scaling(float x, float y, float z, Matrix& result) { result = Identity; @@ -742,8 +657,6 @@ public: } // Creates a matrix that uniformly scales along all three axis. - // @param scale The uniform scale that is applied along all axis. - // @returns The created scaling matrix. static Matrix Scaling(float scale) { Matrix result = Identity; @@ -752,17 +665,13 @@ public: } // Creates a matrix that uniformly scales along all three axis. - // @param scale The uniform scale that is applied along all axis. - // @param result When the method completes, contains the created scaling matrix. static void Scaling(float scale, Matrix& result) { result = Identity; result.M11 = result.M22 = result.M33 = scale; } - // Creates a matrix that rotates around the x-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @returns The created rotation matrix. + // Creates a matrix that rotates around the x-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static Matrix RotationX(float angle) { Matrix result; @@ -770,14 +679,10 @@ public: return result; } - // Creates a matrix that rotates around the x-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @param result When the method completes, contains the created rotation matrix. + // Creates a matrix that rotates around the x-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static void RotationX(float angle, Matrix& result); - // Creates a matrix that rotates around the y-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @returns The created rotation matrix. + // Creates a matrix that rotates around the y-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static Matrix RotationY(float angle) { Matrix result; @@ -785,14 +690,10 @@ public: return result; } - // Creates a matrix that rotates around the y-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @param result When the method completes, contains the created rotation matrix. + // Creates a matrix that rotates around the y-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static void RotationY(float angle, Matrix& result); - // Creates a matrix that rotates around the z-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @returns The created rotation matrix. + // Creates a matrix that rotates around the z-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static Matrix RotationZ(float angle) { Matrix result; @@ -800,15 +701,10 @@ public: return result; } - // Creates a matrix that rotates around the z-axis. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @param result When the method completes, contains the created rotation matrix. + // Creates a matrix that rotates around the z-axis. Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static void RotationZ(float angle, Matrix& result); - // Creates a matrix that rotates around an arbitrary axis. - // @param axis The axis around which to rotate. This parameter is assumed to be normalized. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @returns The created rotation matrix + // Creates a matrix that rotates around an arbitrary axis (normalized). Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static Matrix RotationAxis(const Float3& axis, float angle) { Matrix result; @@ -816,10 +712,7 @@ public: return result; } - // Creates a matrix that rotates around an arbitrary axis. - // @param axis The axis around which to rotate. This parameter is assumed to be normalized. - // @param angle Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. - // @param result When the method completes, contains the created rotation matrix. + // Creates a matrix that rotates around an arbitrary axis (normalized). Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. static void RotationAxis(const Float3& axis, float angle, Matrix& result); /// @@ -842,10 +735,6 @@ public: static void RotationQuaternion(const Quaternion& rotation, Matrix& result); // Creates a rotation matrix with a specified yaw, pitch, and roll. - // @param yaw Yaw around the y-axis, in radians. - // @param pitch Pitch around the x-axis, in radians. - // @param roll Roll around the z-axis, in radians. - // @returns The created rotation matrix. static Matrix RotationYawPitchRoll(float yaw, float pitch, float roll) { Matrix result; @@ -854,34 +743,18 @@ public: } // Creates a rotation matrix with a specified yaw, pitch, and roll. - // @param yaw Yaw around the y-axis, in radians. - // @param pitch Pitch around the x-axis, in radians. - // @param roll Roll around the z-axis, in radians. - // @param result When the method completes, contains the created rotation matrix. static void RotationYawPitchRoll(float yaw, float pitch, float roll, Matrix& result); // Creates a translation matrix using the specified offsets. - // @param value The offset for all three coordinate planes. - // @returns The created translation matrix. static Matrix Translation(const Float3& value); // Creates a translation matrix using the specified offsets. - // @param value The offset for all three coordinate planes. - // @param result When the method completes, contains the created translation matrix. static void Translation(const Float3& value, Matrix& result); // Creates a translation matrix using the specified offsets. - // @param x X-coordinate offset. - // @param y Y-coordinate offset. - // @param z Z-coordinate offset. - // @param result When the method completes, contains the created translation matrix. static void Translation(float x, float y, float z, Matrix& result); // Creates a skew/shear matrix by means of a translation vector, a rotation vector, and a rotation angle. - // @param angle The rotation angle. - // @param rotationVec The rotation vector. - // @param transVec The translation vector. - // @param matrix Contains the created skew/shear matrix. static void Skew(float angle, const Float3& rotationVec, const Float3& transVec, Matrix& matrix); /// @@ -894,79 +767,55 @@ public: static void Transformation(const Float3& scaling, const Quaternion& rotation, const Float3& translation, Matrix& result); // Creates a 3D affine transformation matrix. - // @param scaling Scaling factor. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created affine transformation matrix. static void AffineTransformation(float scaling, const Quaternion& rotation, const Float3& translation, Matrix& result); // Creates a 3D affine transformation matrix. - // @param scaling Scaling factor. - // @param rotationCenter The center of the rotation. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created affine transformation matrix. static void AffineTransformation(float scaling, const Float3& rotationCenter, const Quaternion& rotation, const Float3& translation, Matrix& result); // Creates a 2D affine transformation matrix. - // @param scaling Scaling factor. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created affine transformation matrix. static void AffineTransformation2D(float scaling, float rotation, const Float2& translation, Matrix& result); // Creates a 2D affine transformation matrix. - // @param scaling Scaling factor. - // @param rotationCenter The center of the rotation. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created affine transformation matrix. static void AffineTransformation2D(float scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result); // Creates a transformation matrix. - // @param scalingCenter Center point of the scaling operation. - // @param scalingRotation Scaling rotation amount. - // @param scaling Scaling factor. - // @param rotationCenter The center of the rotation. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created transformation matrix. static void Transformation(const Float3& scalingCenter, const Quaternion& scalingRotation, const Float3& scaling, const Float3& rotationCenter, const Quaternion& rotation, const Float3& translation, Matrix& result); // Creates a 2D transformation matrix. - // @param scalingCenter Center point of the scaling operation. - // @param scalingRotation Scaling rotation amount. - // @param scaling Scaling factor. - // @param rotationCenter The center of the rotation. - // @param rotation The rotation of the transformation. - // @param translation The translation factor of the transformation. - // @param result When the method completes, contains the created transformation matrix. static void Transformation2D(const Float2& scalingCenter, float scalingRotation, const Float2& scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result); - // Creates a world matrix with the specified parameters. - // @param position Position of the object. This value is used in translation operations. - // @param forward Forward direction of the object. - // @param up Upward direction of the object; usually [0, 1, 0]. - // @returns Created world matrix of given transformation world. + /// + /// Creates a world matrix with the specified parameters. + /// + /// Position of the object. This value is used in translation operations. + /// Forward direction of the object. + /// Upward direction of the object; usually [0, 1, 0]. + /// Created world matrix of given transformation world. static Matrix CreateWorld(const Float3& position, const Float3& forward, const Float3& up); - // Creates a world matrix with the specified parameters. - // @param position Position of the object. This value is used in translation operations. - // @param forward Forward direction of the object. - // @param up Upward direction of the object; usually [0, 1, 0]. - // @param result Created world matrix of given transformation world. + /// + /// Creates a world matrix with the specified parameters. + /// + /// Position of the object. This value is used in translation operations. + /// Forward direction of the object. + /// Upward direction of the object; usually [0, 1, 0]. + /// Created world matrix of given transformation world. static void CreateWorld(const Float3& position, const Float3& forward, const Float3& up, Matrix& result); - // Creates a new Matrix that rotates around an arbitrary vector. - // @param axis The axis to rotate around. - // @param angle The angle to rotate around the vector. - // @returns Result matrix. + /// + /// Creates a new Matrix that rotates around an arbitrary vector. + /// + /// The axis to rotate around. + /// The angle to rotate around the vector. + /// Result matrix. static Matrix CreateFromAxisAngle(const Float3& axis, float angle); - // Creates a new Matrix that rotates around an arbitrary vector. - // @param axis The axis to rotate around. - // @param angle The angle to rotate around the vector. - // @param result Result matrix. + /// + /// Creates a new Matrix that rotates around an arbitrary vector. + /// + /// + /// The angle to rotate around the vector. + /// Result matrix. static void CreateFromAxisAngle(const Float3& axis, float angle, Matrix& result); public: diff --git a/Source/Engine/Core/Math/OrientedBoundingBox.h b/Source/Engine/Core/Math/OrientedBoundingBox.h index 247e8f07f..5b3edb66c 100644 --- a/Source/Engine/Core/Math/OrientedBoundingBox.h +++ b/Source/Engine/Core/Math/OrientedBoundingBox.h @@ -62,7 +62,6 @@ public: Vector3 GetSize() const; // Returns the square size of the OBB taking into consideration the scaling applied to the transformation matrix. - // @returns The size of the consideration. Vector3 GetSizeSquared() const; // Gets the center of the OBB. @@ -85,13 +84,11 @@ public: public: // Transforms this box using a transformation matrix. - // @param mat The transformation matrix. void Transform(const Matrix& matrix); void Transform(const ::Transform& transform); // Scales the OBB by scaling its Extents without affecting the Transformation matrix. // By keeping Transformation matrix scaling-free, the collision detection methods will be more accurate. - // @param scaling Scale to apply to the box. void Scale(const Vector3& scaling) { Extents *= scaling; @@ -99,14 +96,12 @@ public: // Scales the OBB by scaling its Extents without affecting the Transformation matrix. // By keeping Transformation matrix scaling-free, the collision detection methods will be more accurate. - // @param scaling Scale to apply to the box. void Scale(Real scaling) { Extents *= scaling; } // Translates the OBB to a new position using a translation vector. - // @param translation the translation vector. void Translate(const Vector3& translation) { Transformation.Translation += translation; @@ -165,38 +160,26 @@ public: public: // Determines whether a OBB contains a point. - // @param point The point to test. - // @returns The type of containment the two objects have. ContainmentType Contains(const Vector3& point, Real* distance = nullptr) const; - // Determines whether a OBB contains a BoundingSphere. - // @param sphere The sphere to test. - // @param ignoreScale Optimize the check operation by assuming that OBB has no scaling applied. - // @returns The type of containment the two objects have. + /// + /// Determines whether a OBB contains a sphere. + /// + /// The sphere to test. + /// Optimize the check operation by assuming that OBB has no scaling applied. + /// The type of containment the two objects have. ContainmentType Contains(const BoundingSphere& sphere, bool ignoreScale = false) const; - // Determines whether there is an intersection between a Ray and a OBB. - // @param ray The ray to test. - // @param point When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection. - // @returns Whether the two objects intersected. + // Determines whether there is an intersection between oriented box and a ray. Returns point of the intersection. bool Intersects(const Ray& ray, Vector3& point) const; - // Determines if there is an intersection between the current object and a Ray. - // @param ray The ray to test. - // @param distance When the method completes, contains the distance of the intersection, or 0 if there was no intersection. - // @returns Whether the two objects intersected. + // Determines if there is an intersection between oriented box and a ray. Returns distance to the intersection. bool Intersects(const Ray& ray, Real& distance) const; - // Determines if there is an intersection between the current object and a Ray. - // @param ray The ray to test. - // @param distance When the method completes, contains the distance of the intersection, or 0 if there was no intersection. - // @param normal When the method completes, contains the intersection surface normal vector, or Vector3::Up if there was no intersection. - // @returns Whether the two objects intersected. + // Determines if there is an intersection between oriented box and a ray. Returns distance to the intersection and surface normal. bool Intersects(const Ray& ray, Real& distance, Vector3& normal) const; // Determines whether there is an intersection between a Ray and a OBB. - // @param ray The ray to test. - // @returns Whether the two objects intersected. bool Intersects(const Ray& ray) const { Vector3 point; diff --git a/Source/Engine/Core/Math/Plane.cpp b/Source/Engine/Core/Math/Plane.cpp index 785f6a15e..3d0e6b1d9 100644 --- a/Source/Engine/Core/Math/Plane.cpp +++ b/Source/Engine/Core/Math/Plane.cpp @@ -7,9 +7,6 @@ #include "Quaternion.h" #include "../Types/String.h" -const Real Plane::DistanceEpsilon = 0.0001f; -const Real Plane::NormalEpsilon = 1.0f / 65535.0f; - Plane::Plane(const Vector3& point1, const Vector3& point2, const Vector3& point3) { Vector3 cross; diff --git a/Source/Engine/Core/Math/Plane.h b/Source/Engine/Core/Math/Plane.h index a55f9ffd2..e71f2f2c5 100644 --- a/Source/Engine/Core/Math/Plane.h +++ b/Source/Engine/Core/Math/Plane.h @@ -11,9 +11,9 @@ API_STRUCT() struct FLAXENGINE_API Plane { DECLARE_SCRIPTING_TYPE_MINIMAL(Plane); -public: - static const Real DistanceEpsilon; - static const Real NormalEpsilon; + + static constexpr Real DistanceEpsilon = 0.0001f; + static constexpr Real NormalEpsilon = 1.0f / 65535.0f; public: /// @@ -132,170 +132,102 @@ public: public: static Vector3 Intersection(const Plane& inPlane1, const Plane& inPlane2, const Plane& inPlane3); - // 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 + // Determines if there is an intersection between plane and a point. PlaneIntersectionType Intersects(const Vector3& point) const { return CollisionsHelper::PlaneIntersectsPoint(*this, point); } - // summary> - // 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 + // Determines if there is an intersection between plane and a ray. bool Intersects(const Ray& ray) const { Real distance; return CollisionsHelper::RayIntersectsPlane(ray, *this, distance); } - // summary> - // Determines if there is an intersection between the current object and a Ray. - // /summary> - // @param ray The ray to test - // @param distance When the method completes, contains the distance of the intersection, or 0 if there was no intersection - // @returns Whether the two objects intersected + // Determines if there is an intersection between plane and a ray. Returns distance to the intersection. bool Intersects(const Ray& ray, Real& distance) const { return CollisionsHelper::RayIntersectsPlane(ray, *this, distance); } - // summary> - // Determines if there is an intersection between the current object and a Ray. - // /summary> - // @param ray The ray to test - // @param point When the method completes, contains the point of intersection, or if there was no intersection - // @returns Whether the two objects intersected + // Determines if there is an intersection between plane and a ray. bool Intersects(const Ray& ray, Vector3& point) const { return CollisionsHelper::RayIntersectsPlane(ray, *this, point); } - // Determines if there is an intersection between the current object and a Plane - // @param plane The plane to test - // @returns Whether the two objects intersected + // Determines if there is an intersection between two planes. bool Intersects(const Plane& plane) const { return CollisionsHelper::PlaneIntersectsPlane(*this, plane); } - // Determines if there is an intersection between the current object and a Plane - // @param plane The plane to test - // @param line When the method completes, contains the line of intersection as a Ray, or a zero ray if there was no intersection - // @returns Whether the two objects intersected + // Determines if there is an intersection between two planes. Returns ray that defines a line of intersection. bool Intersects(const Plane& plane, Ray& line) const { return CollisionsHelper::PlaneIntersectsPlane(*this, plane, line); } - // Determines if there is an intersection between the current object and a triangle - // @param vertex1 The first vertex of the triangle to test - // @param vertex2 The second vertex of the triangle to test - // @param vertex3 The third vertex of the triangle to test - // @returns Whether the two objects intersected + // Determines if there is an intersection between plane and a triangle. PlaneIntersectionType Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3) const { return CollisionsHelper::PlaneIntersectsTriangle(*this, vertex1, vertex2, vertex3); } - // Determines if there is an intersection between the current object and a Bounding Box - // @param box The box to test - // @returns Whether the two objects intersected + // Determines if there is an intersection between plane and a box. PlaneIntersectionType Intersects(const BoundingBox& box) const { return CollisionsHelper::PlaneIntersectsBox(*this, box); } - // Determines if there is an intersection between the current object and a Bounding Sphere - // @param sphere The sphere to test - // @returns Whether the two objects intersected + // Determines if there is an intersection between plane and a sphere. PlaneIntersectionType Intersects(const BoundingSphere& sphere) const { return CollisionsHelper::PlaneIntersectsSphere(*this, sphere); } 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 - // @param result When the method completes, contains the scaled plane + // Scales the plane by the given factor. static void Multiply(const Plane& value, Real scale, Plane& result); - // Scales the plane by the given scaling factor - // @param value The plane to scale - // @param scale The amount by which to scale the plane - // @returns The scaled plane + // Scales the plane by the given factor. static Plane Multiply(const Plane& value, Real scale); - // Calculates the dot product of the specified vector and plane - // @param left The source plane - // @param right The source vector - // @param result When the method completes, contains the dot product of the specified plane and vector + // Calculates the dot product of the specified vector and plane. static void Dot(const Plane& left, const Vector4& right, Real& result); - // Calculates the dot product of the specified vector and plane - // @param left The source plane - // @param right The source vector - // @returns The dot product of the specified plane and vector + // Calculates the dot product of the specified vector and plane. static Real Dot(const Plane& left, const Vector4& right); - // Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane - // @param left The source plane - // @param right The source vector - // @param result When the method completes, contains the dot product of a specified vector and the normal of the Plane plus the distance value of the plane + // Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane. static void DotCoordinate(const Plane& left, const Vector3& right, Real& result); - // Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane - // @param left The source plane - // @param right The source vector - // @returns The dot product of a specified vector and the normal of the Plane plus the distance value of the plane + // Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane. static Real DotCoordinate(const Plane& left, const Vector3& right); - // Calculates the dot product of the specified vector and the normal of the plane - // @param left The source plane - // @param right The source vector - // @param result When the method completes, contains the dot product of the specified vector and the normal of the plane + // Calculates the dot product of the specified vector and the normal of the plane. static void DotNormal(const Plane& left, const Vector3& right, Real& result); - // Calculates the dot product of the specified vector and the normal of the plane - // @param left The source plane - // @param right The source vector - // @returns The dot product of the specified vector and the normal of the plane + // Calculates the dot product of the specified vector and the normal of the plane. static Real DotNormal(const Plane& left, const Vector3& right); - // Changes the coefficients of the normal vector of the plane to make it of unit length - // @param plane The source plane - // @param result When the method completes, contains the normalized plane + // Changes the coefficients of the normal vector of the plane to make it of unit length. static void Normalize(const Plane& plane, Plane& result); - // Changes the coefficients of the normal vector of the plane to make it of unit length - // @param plane The source plane - // @returns The normalized plane + // Changes the coefficients of the normal vector of the plane to make it of unit length. static Plane Normalize(const Plane& plane); - // Transforms a normalized plane by a quaternion rotation - // @param plane The normalized source plane - // @param rotation The quaternion rotation - // @param result When the method completes, contains the transformed plane + // Transforms a normalized plane by a quaternion rotation. static void Transform(const Plane& plane, const Quaternion& rotation, Plane& result); - // Transforms a normalized plane by a quaternion rotation - // @param plane The normalized source plane - // @param rotation The quaternion rotation - // @returns The transformed plane + // Transforms a normalized plane by a quaternion rotation. static Plane Transform(const Plane& plane, const Quaternion& rotation); - // Transforms a normalized plane by a matrix - // @param plane The normalized source plane - // @param transformation The transformation matrix - // @param result When the method completes, contains the transformed plane + // Transforms a normalized plane by a matrix. static void Transform(const Plane& plane, const Matrix& transformation, Plane& result); - // Transforms a normalized plane by a matrix - // @param plane The normalized source plane - // @param transformation The transformation matrix - // @returns When the method completes, contains the transformed plane + // Transforms a normalized plane by a matrix. static Plane Transform(const Plane& plane, const Matrix& transformation); }; diff --git a/Source/Engine/Core/Math/Quaternion.cpp b/Source/Engine/Core/Math/Quaternion.cpp index 14fbd6a2e..b785fa08b 100644 --- a/Source/Engine/Core/Math/Quaternion.cpp +++ b/Source/Engine/Core/Math/Quaternion.cpp @@ -100,6 +100,22 @@ Float3 Quaternion::operator*(const Float3& vector) const return Float3::Transform(vector, *this); } +void Quaternion::Add(const Quaternion& left, const Quaternion& right, Quaternion& result) +{ + result.X = left.X + right.X; + result.Y = left.Y + right.Y; + result.Z = left.Z + right.Z; + result.W = left.W + right.W; +} + +void Quaternion::Subtract(const Quaternion& left, const Quaternion& right, Quaternion& result) +{ + result.X = left.X - right.X; + result.Y = left.Y - right.Y; + result.Z = left.Z - right.Z; + result.W = left.W - right.W; +} + void Quaternion::Multiply(const Quaternion& left, const Quaternion& right, Quaternion& result) { const float a = left.Y * right.Z - left.Z * right.Y; @@ -112,6 +128,14 @@ void Quaternion::Multiply(const Quaternion& left, const Quaternion& right, Quate result.W = left.W * right.W - d; } +void Quaternion::Negate(const Quaternion& value, Quaternion& result) +{ + result.X = -value.X; + result.Y = -value.Y; + result.Z = -value.Z; + result.W = -value.W; +} + void Quaternion::Lerp(const Quaternion& start, const Quaternion& end, float amount, Quaternion& result) { const float inverse = 1.0f - amount; diff --git a/Source/Engine/Core/Math/Quaternion.cs b/Source/Engine/Core/Math/Quaternion.cs index b6b9518c3..f33470c60 100644 --- a/Source/Engine/Core/Math/Quaternion.cs +++ b/Source/Engine/Core/Math/Quaternion.cs @@ -580,7 +580,7 @@ namespace FlaxEngine public static float AngleBetween(Quaternion a, Quaternion b) { float num = Dot(a, b); - return num > 0.9999999f ? 0 : Mathf.Acos(Mathf.Min(Mathf.Abs(num), 1f)) * 2f * 57.29578f; + return num > Tolerance ? 0 : Mathf.Acos(Mathf.Min(Mathf.Abs(num), 1f)) * 2f * 57.29578f; } /// @@ -1602,7 +1602,7 @@ namespace FlaxEngine [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(Quaternion left, Quaternion right) { - return Dot(ref left, ref right) > 0.9999999f; + return Dot(ref left, ref right) > Tolerance; } /// @@ -1614,7 +1614,7 @@ namespace FlaxEngine [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Quaternion left, Quaternion right) { - return Dot(ref left, ref right) <= 0.9999999f; + return Dot(ref left, ref right) <= Tolerance; } /// @@ -1714,7 +1714,7 @@ namespace FlaxEngine [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(ref Quaternion other) { - //return Dot(ref this, ref other) > 0.9999999f; + //return Dot(ref this, ref other) > Tolerance; return Mathf.NearEqual(other.X, X) && Mathf.NearEqual(other.Y, Y) && Mathf.NearEqual(other.Z, Z) && Mathf.NearEqual(other.W, W); } diff --git a/Source/Engine/Core/Math/Quaternion.h b/Source/Engine/Core/Math/Quaternion.h index b2b57886f..1dbcda32d 100644 --- a/Source/Engine/Core/Math/Quaternion.h +++ b/Source/Engine/Core/Math/Quaternion.h @@ -15,6 +15,12 @@ struct Matrix3x3; API_STRUCT() struct FLAXENGINE_API Quaternion { DECLARE_SCRIPTING_TYPE_MINIMAL(Quaternion); + + /// + /// Equality tolerance factor used when comparing quaternions via dot operation. + /// + API_FIELD() static constexpr Real Tolerance = 0.9999999f; + public: union { @@ -342,7 +348,7 @@ public: /// true if the specified is equal to this instance; otherwise, false. FORCE_INLINE bool operator==(const Quaternion& other) const { - return Dot(*this, other) > 0.9999999f; + return Dot(*this, other) > Tolerance; } /// @@ -364,7 +370,7 @@ public: /// true if the specified structures are equal; otherwise, false. static bool NearEqual(const Quaternion& a, const Quaternion& b) { - return Dot(a, b) > 0.9999999f; + return Dot(a, b) > Tolerance; } /// @@ -423,37 +429,16 @@ public: static float AngleBetween(const Quaternion& a, const Quaternion& b) { const float dot = Dot(a, b); - return dot > 0.9999999f ? 0 : Math::Acos(Math::Min(Math::Abs(dot), 1.0f)) * 2.0f * 57.29578f; + return dot > Tolerance ? 0 : Math::Acos(Math::Min(Math::Abs(dot), 1.0f)) * 2.0f * 57.29578f; } - // Adds two quaternions - // @param left The first quaternion to add - // @param right The second quaternion to add - // @param result When the method completes, contains the sum of the two quaternions - static void Add(const Quaternion& left, const Quaternion& right, Quaternion& result) - { - result.X = left.X + right.X; - result.Y = left.Y + right.Y; - result.Z = left.Z + right.Z; - result.W = left.W + right.W; - } + // Adds two quaternions. + static void Add(const Quaternion& left, const Quaternion& right, Quaternion& result); - // Subtracts two quaternions - // @param left The first quaternion to subtract - // @param right The second quaternion to subtract - // @param result When the method completes, contains the difference of the two quaternions - static void Subtract(const Quaternion& left, const Quaternion& right, Quaternion& result) - { - result.X = left.X - right.X; - result.Y = left.Y - right.Y; - result.Z = left.Z - right.Z; - result.W = left.W - right.W; - } + // Subtracts two quaternions. + static void Subtract(const Quaternion& left, const Quaternion& right, Quaternion& result); - // Scales a quaternion by the given value - // @param value The quaternion to scale - // @param scale The amount by which to scale the quaternion - // @param result When the method completes, contains the scaled quaternion + // Scales a quaternion by the given value. static void Multiply(const Quaternion& value, float scale, Quaternion& result) { result.X = value.X * scale; @@ -462,35 +447,16 @@ public: result.W = value.W * scale; } - // Multiplies a quaternion by another - // @param left The first quaternion to multiply - // @param right The second quaternion to multiply - // @param result When the method completes, contains the multiplied quaternion + // Multiplies a quaternion by another. static void Multiply(const Quaternion& left, const Quaternion& right, Quaternion& result); - // Reverses the direction of a given quaternion - // @param value The quaternion to negate - // @param result When the method completes, contains a quaternion facing in the opposite direction - static void Negate(const Quaternion& value, Quaternion& result) - { - result.X = -value.X; - result.Y = -value.Y; - result.Z = -value.Z; - result.W = -value.W; - } + // Reverses the direction of a given quaternion. + static void Negate(const Quaternion& value, Quaternion& result); - // Performs a linear interpolation between two quaternions - // @param start Start quaternion - // @param end End quaternion - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the linear interpolation of the two quaternions + // Performs a linear interpolation between two quaternions. static void Lerp(const Quaternion& start, const Quaternion& end, float amount, Quaternion& result); - // Performs a linear interpolation between two quaternion - // @param start Start quaternion - // @param end End quaternion - // @param amount Value between 0 and 1 indicating the weight of end - // @returns The linear interpolation of the two quaternions + // Performs a linear interpolation between two quaternion. static Quaternion Lerp(const Quaternion& start, const Quaternion& end, float amount) { Quaternion result; @@ -498,47 +464,25 @@ public: return result; } - // Creates a quaternion given a rotation and an axis - // @param axis The axis of rotation - // @param angle The angle of rotation (in radians). - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given an angle cosine (radians in range [-1,1]) and an axis of rotation (normalized). static void RotationAxis(const Float3& axis, float angle, Quaternion& result); - // Creates a quaternion given a angle cosine and an axis - // @param axis The axis of rotation - // @param cos The angle cosine, it must be within [-1,1] range (in radians). - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given an angle cosine (radians in range [-1,1]) and an axis of rotation (normalized). static void RotationCosAxis(const Float3& axis, float cos, Quaternion& result); - // Creates a quaternion given a rotation matrix - // @param matrix The rotation matrix - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given a rotation matrix. static void RotationMatrix(const Matrix& matrix, Quaternion& result); - // Creates a quaternion given a rotation matrix - // @param matrix The rotation matrix - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given a rotation matrix. static void RotationMatrix(const Matrix3x3& matrix, Quaternion& result); - // Creates a left-handed, look-at quaternion - // @param eye The position of the viewer's eye - // @param target The camera look-at target - // @param up The camera's up vector - // @param result When the method completes, contains the created look-at quaternion + // Creates a left-handed, look-at quaternion. static void LookAt(const Float3& eye, const Float3& target, const Float3& up, Quaternion& result); - // Creates a left-handed, look-at quaternion - // @param forward The camera's forward direction - // @param up The camera's up vector - // @param result When the method completes, contains the created look-at quaternion + // Creates a left-handed, look-at quaternion. static void RotationLookAt(const Float3& forward, const Float3& up, Quaternion& result); - // Creates a left-handed spherical billboard that rotates around a specified object position - // @param objectPosition The position of the object around which the billboard will rotate - // @param cameraPosition The position of the camera - // @param cameraUpFloat The up vector of the camera - // @param cameraForwardFloat The forward vector of the camera - // @param result When the method completes, contains the created billboard quaternion + // Creates a left-handed spherical billboard that rotates around a specified object position. static void Billboard(const Float3& objectPosition, const Float3& cameraPosition, const Float3& cameraUpFloat, const Float3& cameraForwardFloat, Quaternion& result); /// @@ -613,9 +557,7 @@ public: return result; } - // Creates a quaternion given a rotation matrix - // @param matrix The rotation matrix - // @returns The newly created quaternion + // Creates a quaternion given a rotation matrix. static Quaternion RotationMatrix(const Matrix& matrix) { Quaternion result; @@ -623,30 +565,16 @@ public: return result; } - // Interpolates between two quaternions, using spherical linear interpolation - // @param start Start quaternion - // @param end End quaternion - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the spherical linear interpolation of the two quaternions + // Interpolates between two quaternions, using spherical linear interpolation. static void Slerp(const Quaternion& start, const Quaternion& end, float amount, Quaternion& result); - // Creates a quaternion given a yaw, pitch, and roll value (is using degrees) - // @param x Roll (in degrees) - // @param x Pitch (in degrees) - // @param x Yaw (in degrees) - // @returns Result rotation + // Creates a quaternion given a yaw, pitch, and roll value (in degrees). static Quaternion Euler(float x, float y, float z); - // Creates a quaternion given a yaw, pitch, and roll value (is using degrees) - // @param euler Euler angle rotation with values in order: X:roll, Y:pitch, Z:yaw (in degrees) - // @returns Result rotation + // Creates a quaternion given a yaw, pitch, and roll value in order: X:roll, Y:pitch, Z:yaw (in degrees). static Quaternion Euler(const Float3& euler); - // Creates a quaternion given a yaw, pitch, and roll value (is using radians) - // @param yaw The yaw of rotation (in radians) - // @param pitch The pitch of rotation (in radians) - // @param roll The roll of rotation (in radians) - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given a yaw, pitch, and roll value (in radians). static Quaternion RotationYawPitchRoll(float yaw, float pitch, float roll) { Quaternion result; @@ -654,11 +582,7 @@ public: return result; } - // Creates a quaternion given a yaw, pitch, and roll value (is using radians) - // @param yaw The yaw of rotation (in radians) - // @param pitch The pitch of rotation (in radians) - // @param roll The roll of rotation (in radians) - // @param result When the method completes, contains the newly created quaternion + // Creates a quaternion given a yaw, pitch, and roll value (in radians). static void RotationYawPitchRoll(float yaw, float pitch, float roll, Quaternion& result); /// diff --git a/Source/Engine/Core/Math/Ray.h b/Source/Engine/Core/Math/Ray.h index 7fd2e81fa..7a265b233 100644 --- a/Source/Engine/Core/Math/Ray.h +++ b/Source/Engine/Core/Math/Ray.h @@ -82,7 +82,7 @@ public: Vector3 GetPoint(Real distance) const; /// - /// Determines if there is an intersection between the current object and a point. + /// Determines if there is an intersection between ray and a point. /// /// The point to test. /// Whether the two objects intersected. @@ -92,7 +92,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between two rays. /// /// The ray to test. /// Whether the two objects intersected. @@ -103,7 +103,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The ray to test. /// When the method completes, contains the point of intersection, or if there was no intersection. @@ -115,7 +115,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The plane to test /// Whether the two objects intersected. @@ -126,7 +126,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The plane to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -137,7 +137,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The plane to test. /// When the method completes, contains the point of intersection, or if there was no intersection. @@ -148,7 +148,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a triangle. + /// Determines if there is an intersection between ray and a triangle. /// /// The first vertex of the triangle to test. /// The second vertex of the triangle to test. @@ -161,7 +161,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a triangle. + /// Determines if there is an intersection between ray and a triangle. /// /// The first vertex of the triangle to test. /// The second vertex of the triangle to test. @@ -174,7 +174,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a triangle. + /// Determines if there is an intersection between ray and a triangle. /// /// The first vertex of the triangle to test. /// The second vertex of the triangle to test. @@ -187,7 +187,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The box to test. /// Whether the two objects intersected. @@ -198,7 +198,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The box to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -209,7 +209,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The box to test. /// When the method completes, contains the point of intersection, or if there was no intersection. @@ -220,7 +220,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The sphere to test. /// Whether the two objects intersected. @@ -231,7 +231,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The sphere to test. /// When the method completes, contains the distance of the intersection, or 0 if there was no intersection. @@ -242,7 +242,7 @@ public: } /// - /// Determines if there is an intersection between the current object and a . + /// Determines if there is an intersection between ray and a . /// /// The sphere to test. /// When the method completes, contains the point of intersection, or if there was no intersection. diff --git a/Source/Engine/Core/Math/Rectangle.h b/Source/Engine/Core/Math/Rectangle.h index 03d0f2530..6ac36efbd 100644 --- a/Source/Engine/Core/Math/Rectangle.h +++ b/Source/Engine/Core/Math/Rectangle.h @@ -33,20 +33,24 @@ public: /// Rectangle() = default; - // Init - // @param x Rectangle location X coordinate - // @param y Rectangle location Y coordinate - // @param width Rectangle width - // @param height Rectangle height + /// + /// Initializes a new instance of the struct. + /// + /// The X coordinate of the upper left corner. + /// The Y coordinate of the upper left corner. + /// The width. + /// The height. Rectangle(float x, float y, float width, float height) : Location(x, y) , Size(width, height) { } - // Init - // @param location Rectangle location point - // @param width Rectangle size + /// + /// Initializes a new instance of the struct. + /// + /// The location of the upper left corner. + /// The size. Rectangle(const Float2& location, const Float2& size) : Location(location) , Size(size) @@ -57,123 +61,114 @@ public: String ToString() const; public: - // Returns width of the rectangle + // Gets width of the rectangle. float GetWidth() const { return Size.X; } - // Returns height of the rectangle + // Gets height of the rectangle. float GetHeight() const { return Size.Y; } - // Gets Y coordinate of the top edge of the rectangle + // Gets Y coordinate of the top edge of the rectangle. float GetY() const { return Location.Y; } - // Gets Y coordinate of the top edge of the rectangle + // Gets Y coordinate of the top edge of the rectangle. float GetTop() const { return Location.Y; } - // Gets Y coordinate of the bottom edge of the rectangle + // Gets Y coordinate of the bottom edge of the rectangle. float GetBottom() const { return Location.Y + Size.Y; } - // Gets X coordinate of the left edge of the rectangle + // Gets X coordinate of the left edge of the rectangle. float GetX() const { return Location.X; } - // Gets X coordinate of the left edge of the rectangle + // Gets X coordinate of the left edge of the rectangle. float GetLeft() const { return Location.X; } - // Gets X coordinate of the right edge of the rectangle + // Gets X coordinate of the right edge of the rectangle. float GetRight() const { return Location.X + Size.X; } - // Gets position of the upper left corner of the rectangle + // Gets position of the upper left corner of the rectangle. Float2 GetUpperLeft() const { return Location; } - // Gets position of the upper right corner of the rectangle + // Gets position of the upper right corner of the rectangle. Float2 GetUpperRight() const { return Location + Float2(Size.X, 0); } - // Gets position of the bottom right corner of the rectangle + // Gets position of the bottom right corner of the rectangle. Float2 GetLowerRight() const { return Location + Size; } - // Gets position of the bottom left corner of the rectangle + // Gets position of the bottom left corner of the rectangle. Float2 GetLowerLeft() const { return Location + Float2(0, Size.Y); } - // Gets position of the upper left corner of the rectangle + // Gets position of the upper left corner of the rectangle. Float2 GetTopLeft() const { return Location; } - // Gets position of the upper right corner of the rectangle + // Gets position of the upper right corner of the rectangle. Float2 GetTopRight() const { return Location + Float2(Size.X, 0); } - // Gets position of the bottom right corner of the rectangle + // Gets position of the bottom right corner of the rectangle. Float2 GetBottomRight() const { return Location + Size; } - // Gets position of the bottom left corner of the rectangle + // Gets position of the bottom left corner of the rectangle. Float2 GetBottomLeft() const { return Location + Float2(0, Size.Y); } - /// - /// Gets center position of the rectangle - /// - /// Center point + // Gets center position of the rectangle. Float2 GetCenter() const { return Location + Size * 0.5f; } public: - // Offset rectangle Location point - // @param v Offset to add - // @returns Result rectangle Rectangle operator+(const Float2& v) const { return Rectangle(Location + v, Size); } - // Offset rectangle Location point - // @param v Offset to subtract - // @returns Result rectangle Rectangle operator-(const Float2& v) const { return Rectangle(Location - v, Size); @@ -236,81 +231,51 @@ public: } public: - // Checks if rectangle contains given point - // @param location Point location to check - // @returns True if point is inside rectangle's area + // Checks if rectangle contains given point. bool Contains(const Float2& location) const; - // Determines whether this rectangle entirely contains a specified rectangle - // @param value The rectangle to evaluate - // @returns True if this rectangle entirely contains the specified rectangle, or false if not + // Determines whether this rectangle entirely contains a specified rectangle. bool Contains(const Rectangle& value) const; - // Determines whether a specified rectangle intersects with this rectangle - // @ value The rectangle to evaluate - // @returns True if the specified rectangle intersects with this one, otherwise false + // Determines whether a specified rectangle intersects with this rectangle. bool Intersects(const Rectangle& value) const; public: - // Offset rectangle position - // @param x X coordinate offset - // @param y Y coordinate offset + // Offsets rectangle position. void Offset(float x, float y); - // Offset rectangle position - // @param offset X and Y coordinate offset + // Offsets rectangle position. void Offset(const Float2& offset); - // Make offseted rectangle - // @param offset X and Y coordinate offset - // @returns Offseted rectangle + // Make offseted rectangle. Rectangle MakeOffsetted(const Float2& offset) const; -public: - // Expand rectangle area in all directions by given amount - // @param toExpand Amount of units to expand a rectangle + // Expands rectangle area in all directions by given amount. void Expand(float toExpand); - // Make expanded rectangle area in all directions by given amount - // @param toExpand Amount of units to expand a rectangle - // @returns Expanded rectangle + // Makes expanded rectangle area in all directions by given amount. Rectangle MakeExpanded(float toExpand) const; -public: - // Scale rectangle area in all directions by given amount - // @param scale Scale value to expand a rectangle + // Scale rectangle area in all directions by given amount. void Scale(float scale); - // Make scaled rectangle area in all directions by given amount - // @param scale Scale value to expand a rectangle - // @returns Scaled rectangle + // Makes scaled rectangle area in all directions by given amount. 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 - // @returns Rectangle that contains both rectangle and the point + // Calculates a rectangle that contains the union of rectangle and the arbitrary point. static Rectangle Union(const Rectangle& a, const Float2& b); - // Calculates a rectangle that contains the union of a and b rectangles - // @param a First rectangle - // @param b Second rectangle - // @returns Rectangle that contains both a and b rectangles + // Calculates a rectangle that contains the union of a and b rectangles. static Rectangle Union(const Rectangle& a, const Rectangle& b); - // Calculates a rectangle that contains the shared part of a and b rectangles - // @param a First rectangle - // @param b Second rectangle - // @returns Rectangle that contains shared part of a and b rectangles + // Calculates a rectangle that contains the shared part of a and b rectangles. static Rectangle Shared(const Rectangle& a, const Rectangle& b); - // Create rectangle from two points - // @param p1 First point - // @param p2 Second point - // @returns Rectangle that contains both p1 and p2 + // Creates rectangle from two points. static Rectangle FromPoints(const Float2& p1, const Float2& p2); + // Creates rectangle from list of points. static Rectangle FromPoints(const Float2* points, int32 pointsCount); }; diff --git a/Source/Engine/Core/Math/Triangle.h b/Source/Engine/Core/Math/Triangle.h index cbdabe759..b61e15104 100644 --- a/Source/Engine/Core/Math/Triangle.h +++ b/Source/Engine/Core/Math/Triangle.h @@ -6,7 +6,7 @@ #include "CollisionsHelper.h" /// -/// Represents a three dimensional triangle. +/// Represents a three-dimensional triangle. /// struct FLAXENGINE_API Triangle { @@ -52,38 +52,26 @@ public: } 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 + // Determines if there is an intersection between triangle and a ray. bool Intersects(const Ray& ray) const { Real distance; return CollisionsHelper::RayIntersectsTriangle(ray, V0, V1, V2, distance); } - // Determines if there is an intersection between the current object and a Ray - // @param ray The ray to test - // @param distance When the method completes, contains the distance of the intersection, or 0 if there was no intersection - // @returns Whether the two objects intersected + /// Determines if there is an intersection between triangle and a ray. Returns distance to the intersection. bool Intersects(const Ray& ray, Real& distance) const { return CollisionsHelper::RayIntersectsTriangle(ray, V0, V1, V2, distance); } - // Determines if there is an intersection between the current object and a Ray - // @param ray The ray to test - // @param distance When the method completes, contains the distance of the intersection, or 0 if there was no intersection - // @param normal When the method completes, contains the intersection surface normal vector, or Vector3::Up if there was no intersection - // @returns Whether the two objects intersected + // Determines if there is an intersection between triangle and a ray. Returns distance to the intersection and surface normal vector. bool Intersects(const Ray& ray, Real& distance, Vector3& normal) const { return CollisionsHelper::RayIntersectsTriangle(ray, V0, V1, V2, distance, normal); } - // Determines if there is an intersection between the current object and a Ray - // @param ray The ray to test - // @param point When the method completes, contains the point of intersection, or if there was no intersection - // @returns Whether the two objects intersected + // Determines if there is an intersection between triangle and a ray. Returns point of intersection. bool Intersects(const Ray& ray, Vector3& point) const { return CollisionsHelper::RayIntersectsTriangle(ray, V0, V1, V2, point); diff --git a/Source/Engine/Core/Math/Vector2.h b/Source/Engine/Core/Math/Vector2.h index f36249025..0c91cbaac 100644 --- a/Source/Engine/Core/Math/Vector2.h +++ b/Source/Engine/Core/Math/Vector2.h @@ -499,11 +499,7 @@ public: } public: - // Clamp vector values within given range - // @param v Vector to clamp - // @param min Minimum value - // @param max Maximum value - // @returns Clamped vector + // Restricts a value to be within a specified range (inclusive min/max). static Vector2Base Clamp(const Vector2Base& v, const Vector2Base& min, const Vector2Base& max) { Vector2Base result; @@ -511,20 +507,13 @@ public: return result; } - // Restricts a value to be within a specified range - // @param v The value to clamp - // @param min The minimum value, - // @param max The maximum value - // @param result When the method completes, contains the clamped value + // Restricts a value to be within a specified range (inclusive min/max). static void Clamp(const Vector2Base& v, const Vector2Base& min, const Vector2Base& max, Vector2Base& result) { result = Vector2Base(Math::Clamp(v.X, min.X, max.X), Math::Clamp(v.Y, min.Y, max.Y)); } - // Calculates distance between two points in 2D - // @param a 1st point - // @param b 2nd point - // @returns Distance + // Calculates distance between two points in 2D. static T Distance(const Vector2Base& a, const Vector2Base& b) { const T x = a.X - b.X; @@ -532,10 +521,7 @@ public: return Math::Sqrt(x * x + y * y); } - // Calculates the squared distance between two points in 2D - // @param a 1st point - // @param b 2nd point - // @returns Distance + // Calculates the squared distance between two points in 2D. static T DistanceSquared(const Vector2Base& a, const Vector2Base& b) { const T x = a.X - b.X; @@ -557,24 +543,14 @@ public: return r; } - // Performs a linear interpolation between two vectors - // @param start Start vector - // @param end End vector - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the linear interpolation of the two vectors + // Performs a linear interpolation between two vectors. static void Lerp(const Vector2Base& start, const Vector2Base& end, T amount, Vector2Base& result) { result.X = Math::Lerp(start.X, end.X, amount); result.Y = Math::Lerp(start.Y, end.Y, amount); } - // // Performs a linear interpolation between two vectors. - // - // @param start Start vector, - // @param end End vector, - // @param amount Value between 0 and 1 indicating the weight of @paramref end"/>, - // @returns The linear interpolation of the two vectors static Vector2Base Lerp(const Vector2Base& start, const Vector2Base& end, T amount) { Vector2Base result; diff --git a/Source/Engine/Core/Math/Vector3.h b/Source/Engine/Core/Math/Vector3.h index 2e5d3d478..67f8e7d44 100644 --- a/Source/Engine/Core/Math/Vector3.h +++ b/Source/Engine/Core/Math/Vector3.h @@ -542,11 +542,7 @@ public: } public: - // Restricts a value to be within a specified range - // @param v The value to clamp - // @param min The minimum value, - // @param max The maximum value - // @returns Clamped value + // Restricts a value to be within a specified range (inclusive min/max). static Vector3Base Clamp(const Vector3Base& v, const Vector3Base& min, const Vector3Base& max) { Vector3Base result; @@ -554,11 +550,7 @@ public: return result; } - // Restricts a value to be within a specified range - // @param v The value to clamp - // @param min The minimum value, - // @param max The maximum value - // @param result When the method completes, contains the clamped value + // Restricts a value to be within a specified range (inclusive min/max). static void Clamp(const Vector3Base& v, const Vector3Base& min, const Vector3Base& max, Vector3Base& result) { result = Vector3Base(Math::Clamp(v.X, min.X, max.X), Math::Clamp(v.Y, min.Y, max.Y), Math::Clamp(v.Z, min.Z, max.Z)); @@ -614,10 +606,7 @@ public: } } - // Calculates the distance between two vectors - // @param a The first vector - // @param b The second vector - // @returns The distance between the two vectors + // Calculates the distance between two vectors. static T Distance(const Vector3Base& a, const Vector3Base& b) { const T x = a.X - b.X; @@ -626,10 +615,7 @@ public: return Math::Sqrt(x * x + y * y + z * z); } - // Calculates the squared distance between two vectors - // @param a The first vector - // @param b The second vector - // @returns The squared distance between the two vectors + // Calculates the squared distance between two vectors. static T DistanceSquared(const Vector3Base& a, const Vector3Base& b) { const T x = a.X - b.X; @@ -653,52 +639,38 @@ public: return r; } - // Performs vector normalization (scales vector up to unit length). This is a faster version that does not performs check for length equal 0 (it assumes that input vector is not empty). - // @param inout Input vector to normalize (cannot be zero). - // @returns Output vector that is normalized (has unit length) + // Performs vector normalization (scales vector up to unit length). This is a faster version that does not perform check for length equal 0 (it assumes that input vector is not empty). static Vector3Base NormalizeFast(const Vector3Base& v) { const T inv = 1.0f / v.Length(); return Vector3Base(v.X * inv, v.Y * inv, v.Z * inv); } - // Performs vector normalization (scales vector up to unit length) - // @param inout Input vector to normalize - // @param output Output vector that is normalized (has unit length) + // Performs vector normalization (scales vector up to unit length). static FORCE_INLINE void Normalize(const Vector3Base& input, Vector3Base& result) { result = Normalize(input); } - // dot product with another vector + // Calculates the dot product of two vectors. FORCE_INLINE static T Dot(const Vector3Base& a, const Vector3Base& b) { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; } - // Calculates the cross product of two vectors - // @param a First source vector - // @param b Second source vector - // @param result When the method completes, contains the cross product of the two vectors + // Calculates the cross product of two vectors. static void Cross(const Vector3Base& a, const Vector3Base& b, Vector3Base& result) { result = Vector3Base(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); } - // Calculates the cross product of two vectors - // @param a First source vector - // @param b Second source vector - // @returns Cross product of the two vectors + // Calculates the cross product of two vectors. static Vector3Base Cross(const Vector3Base& a, const Vector3Base& b) { return Vector3Base(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); } - // Performs a linear interpolation between two vectors - // @param start Start vector - // @param end End vector - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the linear interpolation of the two vectors + // Performs a linear interpolation between two vectors. static void Lerp(const Vector3Base& start, const Vector3Base& end, T amount, Vector3Base& result) { result.X = Math::Lerp(start.X, end.X, amount); @@ -706,9 +678,7 @@ public: result.Z = Math::Lerp(start.Z, end.Z, amount); } - // // Performs a linear interpolation between two vectors. - // static Vector3Base Lerp(const Vector3Base& start, const Vector3Base& end, T amount) { Vector3Base result; @@ -716,11 +686,7 @@ public: return result; } - // Performs a cubic interpolation between two vectors - // @param start Start vector - // @param end End vector - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the cubic interpolation of the two vectors + // Performs a cubic interpolation between two vectors. static void SmoothStep(const Vector3Base& start, const Vector3Base& end, T amount, Vector3Base& result) { amount = Math::SmoothStep(amount); @@ -745,78 +711,39 @@ public: } // Performs a Hermite spline interpolation. - // @param value1 First source position vector - // @param tangent1 First source tangent vector - // @param value2 Second source position vector - // @param tangent2 Second source tangent vector - // @param amount Weighting factor, - // @param result When the method completes, contains the result of the Hermite spline interpolation, static FLAXENGINE_API void Hermite(const Vector3Base& value1, const Vector3Base& tangent1, const Vector3Base& value2, const Vector3Base& tangent2, T amount, Vector3Base& result); - // Returns the reflection of a vector off a surface that has the specified normal - // @param vector The source vector - // @param normal Normal of the surface - // @param result When the method completes, contains the reflected vector + // Returns the reflection of a vector off a surface that has the specified normal. static FLAXENGINE_API void Reflect(const Vector3Base& vector, const Vector3Base& normal, Vector3Base& result); - // Transforms a 3D vector by the given Quaternion rotation - // @param vector The vector to rotate - // @param rotation The Quaternion rotation to apply - // @param result When the method completes, contains the transformed Vector3 + // Transforms a 3D vector by the given Quaternion rotation. static FLAXENGINE_API void Transform(const Vector3Base& vector, const Quaternion& rotation, Vector3Base& result); - // Transforms a 3D vector by the given Quaternion rotation - // @param vector The vector to rotate - // @param rotation The Quaternion rotation to apply - // @returns The transformed Vector3 + // Transforms a 3D vector by the given Quaternion rotation. static FLAXENGINE_API Vector3Base Transform(const Vector3Base& vector, const Quaternion& rotation); - // Transforms a 3D vector by the given matrix - // @param vector The source vector - // @param transform The transformation matrix - // @param result When the method completes, contains the transformed Vector3 + // Transforms a 3D vector by the given matrix. static FLAXENGINE_API void Transform(const Vector3Base& vector, const Matrix& transform, Vector3Base& result); - // Transforms a 3D vector by the given matrix - // @param vector The source vector - // @param transform The transformation matrix - // @param result When the method completes, contains the transformed Vector3 + // Transforms a 3D vector by the given matrix. static FLAXENGINE_API void Transform(const Vector3Base& vector, const Matrix3x3& transform, Vector3Base& result); - // Transforms a 3D vector by the given transformation - // @param vector The source vector - // @param transform The transformation - // @param result When the method completes, contains the transformed Vector3 + // Transforms a 3D vector by the given transformation. static FLAXENGINE_API void Transform(const Vector3Base& vector, const ::Transform& transform, Vector3Base& result); - // Transforms a 3D vector by the given matrix - // @param vector The source vector - // @param transform The transformation matrix - // @returns Transformed Vector3 + // Transforms a 3D vector by the given matrix. static FLAXENGINE_API Vector3Base Transform(const Vector3Base& vector, const Matrix& transform); - // Transforms a 3D vector by the given transformation - // @param vector The source vector - // @param transform The transformation - // @returns Transformed Vector3 + // Transforms a 3D vector by the given transformation. static FLAXENGINE_API Vector3Base Transform(const Vector3Base& vector, const ::Transform& transform); - // Transforms a 3D vector by the given matrix - // @param vector The source vector - // @param transform The transformation matrix - // @param result When the method completes, contains the transformed Vector4 + // Transforms a 3D vector by the given matrix. static FLAXENGINE_API void Transform(const Vector3Base& vector, const Matrix& transform, Vector4Base& result); - // Performs a coordinate transformation using the given matrix - // @param coordinate The coordinate vector to transform - // @param transform The transformation matrix - // @param result When the method completes, contains the transformed coordinates + // Performs a coordinate transformation using the given matrix. static FLAXENGINE_API void TransformCoordinate(const Vector3Base& coordinate, const Matrix& transform, Vector3Base& result); - // Performs a normal transformation using the given matrix - // @param normal The normal vector to transform - // @param transform The transformation matrix - // @param result When the method completes, contains the transformed normal + // Performs a normal transformation using the given matrix. static FLAXENGINE_API void TransformNormal(const Vector3Base& normal, const Matrix& transform, Vector3Base& result); /// @@ -838,28 +765,10 @@ public: return vector - Project(vector, planeNormal); } - // Projects a 3D vector from object space into screen space - // @param vector The vector to project - // @param x The X position of the viewport - // @param y The Y position of the viewport - // @param width The width of the viewport - // @param height The height of the viewport - // @param minZ The minimum depth of the viewport - // @param maxZ The maximum depth of the viewport - // @param worldViewProjection The combined world-view-projection matrix - // @param result When the method completes, contains the vector in screen space + // Projects a 3D vector from object space into screen space using the provided viewport and transformation matrix. static FLAXENGINE_API void Project(const Vector3Base& vector, float x, float y, float width, float height, float minZ, float maxZ, const Matrix& worldViewProjection, Vector3Base& result); - // Projects a 3D vector from object space into screen space - // @param vector The vector to project - // @param x The X position of the viewport - // @param y The Y position of the viewport - // @param width The width of the viewport - // @param height The height of the viewport - // @param minZ The minimum depth of the viewport - // @param maxZ The maximum depth of the viewport - // @param worldViewProjection The combined world-view-projection matrix - // @returns The vector in screen space + // Projects a 3D vector from object space into screen space using the provided viewport and transformation matrix. static Vector3Base Project(const Vector3Base& vector, float x, float y, float width, float height, float minZ, float maxZ, const Matrix& worldViewProjection) { Vector3Base result; @@ -867,28 +776,10 @@ public: return result; } - // Projects a 3D vector from screen space into object space - // @param vector The vector to project - // @param x The X position of the viewport - // @param y The Y position of the viewport - // @param width The width of the viewport - // @param height The height of the viewport - // @param minZ The minimum depth of the viewport - // @param maxZ The maximum depth of the viewport - // @param worldViewProjection The combined world-view-projection matrix - // @param result When the method completes, contains the vector in object space + // Projects a 3D vector from screen space into object space using the provided viewport and transformation matrix. static FLAXENGINE_API void Unproject(const Vector3Base& vector, float x, float y, float width, float height, float minZ, float maxZ, const Matrix& worldViewProjection, Vector3Base& result); - // Projects a 3D vector from screen space into object space - // @param vector The vector to project - // @param x The X position of the viewport - // @param y The Y position of the viewport - // @param width The width of the viewport - // @param height The height of the viewport - // @param minZ The minimum depth of the viewport - // @param maxZ The maximum depth of the viewport - // @param worldViewProjection The combined world-view-projection matrix - // @returns The vector in object space + // Projects a 3D vector from screen space into object space using the provided viewport and transformation matrix. static Vector3Base Unproject(const Vector3Base& vector, float x, float y, float width, float height, float minZ, float maxZ, const Matrix& worldViewProjection) { Vector3Base result; diff --git a/Source/Engine/Core/Math/Vector4.h b/Source/Engine/Core/Math/Vector4.h index e938ba1c1..b7dc176c4 100644 --- a/Source/Engine/Core/Math/Vector4.h +++ b/Source/Engine/Core/Math/Vector4.h @@ -455,11 +455,7 @@ public: } public: - // Restricts a value to be within a specified range - // @param v The value to clamp - // @param min The minimum value, - // @param max The maximum value - // @returns Clamped value + // Restricts a value to be within a specified range (inclusive min/max). static Vector4Base Clamp(const Vector4Base& v, const Vector4Base& min, const Vector4Base& max) { Vector4Base result; @@ -467,21 +463,13 @@ public: return result; } - // Restricts a value to be within a specified range - // @param v The value to clamp - // @param min The minimum value, - // @param max The maximum value - // @param result When the method completes, contains the clamped value + // Restricts a value to be within a specified range (inclusive min/max). static void Clamp(const Vector4Base& v, const Vector4Base& min, const Vector4Base& max, Vector4Base& result) { result = Vector4Base(Math::Clamp(v.X, min.X, max.X), Math::Clamp(v.Y, min.Y, max.Y), Math::Clamp(v.Z, min.Z, max.Z), Math::Clamp(v.W, min.W, max.W)); } - // Performs a linear interpolation between two vectors - // @param start Start vector - // @param end End vector - // @param amount Value between 0 and 1 indicating the weight of end - // @param result When the method completes, contains the linear interpolation of the two vectors + // Performs a linear interpolation between two vectors. static void Lerp(const Vector4Base& start, const Vector4Base& end, T amount, Vector4Base& result) { result.X = Math::Lerp(start.X, end.X, amount); @@ -490,13 +478,7 @@ public: result.W = Math::Lerp(start.W, end.W, amount); } - // // Performs a linear interpolation between two vectors. - // - // @param start Start vector, - // @param end End vector, - // @param amount Value between 0 and 1 indicating the weight of @paramref end"/>, - // @returns The linear interpolation of the two vectors static Vector4Base Lerp(const Vector4Base& start, const Vector4Base& end, T amount) { Vector4Base result; @@ -558,7 +540,7 @@ inline Vector4Base operator/(typename TOtherFloat::Type a, const Vector4Ba template inline uint32 GetHash(const Vector4Base& key) { - return (((((*(uint32*)&key.X * 397) ^ *(uint32*)&key.Y) * 397) ^ *(uint32*)&key.Z) * 397) ^*(uint32*)&key.W; + return (((((*(uint32*)&key.X * 397) ^ *(uint32*)&key.Y) * 397) ^ *(uint32*)&key.Z) * 397) ^ *(uint32*)&key.W; } namespace Math diff --git a/Source/Engine/Core/Math/Viewport.h b/Source/Engine/Core/Math/Viewport.h index f749275f0..5087a537c 100644 --- a/Source/Engine/Core/Math/Viewport.h +++ b/Source/Engine/Core/Math/Viewport.h @@ -8,7 +8,9 @@ struct Matrix; struct Rectangle; -// Describes the viewport dimensions. +/// +/// Describes the viewport dimensions. +/// API_STRUCT(InBuild) struct FLAXENGINE_API Viewport { public: @@ -54,29 +56,16 @@ public: /// Viewport() = default; - // Init - // @param x The x coordinate of the upper-left corner of the viewport in pixels - // @param y The y coordinate of the upper-left corner of the viewport in pixels - // @param width The width of the viewport in pixels - // @param height The height of the viewport in pixels - Viewport(float x, float y, float width, float height) - : X(x) - , Y(y) - , Width(width) - , Height(height) - , MinDepth(0.0f) - , MaxDepth(1.0f) - { - } - - // Init - // @param x The x coordinate of the upper-left corner of the viewport in pixels - // @param y The y coordinate of the upper-left corner of the viewport in pixels - // @param width The width of the viewport in pixels - // @param height The height of the viewport in pixels - // @param minDepth The minimum depth of the clip volume - // @param maxDepth The maximum depth of the clip volume - Viewport(float x, float y, float width, float height, float minDepth, float maxDepth) + /// + /// Initializes a new instance of the struct. + /// + /// The x coordinate of the upper-left corner of the viewport in pixels. + /// The y coordinate of the upper-left corner of the viewport in pixels. + /// The width of the viewport in pixels. + /// The height of the viewport in pixels. + /// The minimum depth of the clip volume. + /// The maximum depth of the clip volumes. + Viewport(float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f) : X(x) , Y(y) , Width(width) @@ -100,31 +89,26 @@ public: { } - // Init - // @param bounds A bounding box that defines the location and size of the viewport in a render target + /// + /// Initializes a new instance of the struct. + /// + /// A bounding rectangle that defines the location and size of the viewport in a render target. Viewport(const Rectangle& bounds); public: String ToString() const; public: - // Gets the aspect ratio used by the viewport - // @returns The aspect ratio + // Gets the aspect ratio used by the viewport. float GetAspectRatio() const { - if (Height != 0.0f) - { - return Width / Height; - } - return 0.0f; + return Height != 0.0f ? Width / Height : 0.0f; } - // Gets the size of the viewport - // @eturns The bounds + // Gets the size of the viewport. Rectangle GetBounds() const; - // Sets the size of the viewport - // @param bounds The bounds + // Sets the size of the viewport. void SetBounds(const Rectangle& bounds); public: @@ -139,16 +123,20 @@ public: } public: - // Projects a 3D vector from object space into screen space - // @param source The vector to project - // @param vp A combined WorldViewProjection matrix - // @param vector The projected vector + /// + /// Projects a 3D vector from object space into screen space. + /// + /// The vector to project. + /// A combined World*View*Projection matrix. + /// The projected vector. void Project(const Vector3& source, const Matrix& vp, Vector3& result) const; - // Converts a screen space point into a corresponding point in world space - // @param source The vector to project - // @param vp An inverted combined WorldViewProjection matrix - // @param vector The unprojected vector + /// + /// Converts a screen space point into a corresponding point in world space. + /// + /// The vector to un-project. + /// An inverted combined World*View*Projection matrix. + /// The un-projected vector void Unproject(const Vector3& source, const Matrix& ivp, Vector3& result) const; }; diff --git a/Source/Engine/Core/Types/Guid.h b/Source/Engine/Core/Types/Guid.h index e57a1414c..ac4f936b2 100644 --- a/Source/Engine/Core/Types/Guid.h +++ b/Source/Engine/Core/Types/Guid.h @@ -7,16 +7,14 @@ #include "Engine/Core/Formatting.h" #include "Engine/Core/Templates.h" -class String; - /// -/// Globally Unique Identifier +/// Globally Unique Identifier (GUID) represented by 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. /// API_STRUCT(InBuild, Namespace="System") struct FLAXENGINE_API Guid { public: /// - /// Accepted format specifiers for the format parameter + /// Accepted format specifiers for the format parameter. /// enum class FormatType { @@ -42,28 +40,28 @@ public: { struct { - // The first component + // The first component. uint32 A; - // The second component + // The second component. uint32 B; - // The third component + // The third component. uint32 C; - // The fourth component + // The fourth component. uint32 D; }; - // Raw bytes with the GUID + // Raw bytes with the Guid. byte Raw[16]; - // Raw values with the GUID + // Raw values with the Guid. uint32 Values[4]; }; public: - // Empty Guid (considered as invalid ID) + // Empty Guid (considered as invalid ID). static Guid Empty; public: @@ -74,11 +72,13 @@ public: { } - // Creates and initializes a new Guid from the specified components - // @param a The first component - // @param b The second component - // @param c The third component - // @param d The fourth component + /// + /// Initializes a new instance of the struct. + /// + /// The first component. + /// The second component. + /// The third component. + /// The fourth component. Guid(uint32 a, uint32 b, uint32 c, uint32 d) : A(a) , B(b) @@ -98,41 +98,27 @@ public: return ((A ^ other.A) | (B ^ other.B) | (C ^ other.C) | (D ^ other.D)) != 0; } - // Provides access to the GUIDs components - // @param index The index of the component to return (0...3) - // @returns The component value + // Provides access to the Guid components (0...3). uint32& operator[](int32 index) { ASSERT(index >= 0 && index < 4); return Values[index]; } - // Provides read-only access to the GUIDs components. - // @param index The index of the component to return (0...3). - // @return The component + // Provides read-only access to the Guid components (0...3). const uint32& operator[](int index) const { ASSERT(index >= 0 && index < 4); return Values[index]; } - // Invalidates the Guid - FORCE_INLINE void Invalidate() - { - A = B = C = D = 0; - } - // Checks whether this Guid is valid or not. A Guid that has all its components set to zero is considered invalid. - // @return true if valid, otherwise false FORCE_INLINE bool IsValid() const { return (A | B | C | D) != 0; } - /// - /// Checks if Guid is valid - /// - /// True if Guid isn't empty + /// Checks if Guid is valid. explicit operator bool() const { return (A | B | C | D) != 0; diff --git a/Source/Engine/Core/Types/StringBuilder.h b/Source/Engine/Core/Types/StringBuilder.h index 54a16fc93..d4fdd91f9 100644 --- a/Source/Engine/Core/Types/StringBuilder.h +++ b/Source/Engine/Core/Types/StringBuilder.h @@ -26,7 +26,7 @@ public: } /// - /// Create string builder with initial capacity + /// Create string builder with initial capacity. /// /// Initial capacity for chars count StringBuilder(int32 capacity) @@ -36,16 +36,15 @@ public: public: /// - /// Gets capacity + /// Gets the buffer capacity. /// - /// Capacity of the string builder FORCE_INLINE int32 Capacity() const { return _data.Capacity(); } /// - /// Sets capacity. + /// Sets the buffer capacity. /// /// Capacity to set FORCE_INLINE void SetCapacity(const int32 capacity) @@ -71,7 +70,7 @@ public: } /// - /// Gets string + /// Gets the string. /// /// String void ToString(String& result) const @@ -80,27 +79,18 @@ public: } public: - // Append single character to the string - // @param c Character to append - // @return Current String Builder instance StringBuilder& Append(const Char c) { _data.Add(c); return *this; } - // Append single character to the string - // @param c Character to append - // @return Current String Builder instance StringBuilder& Append(const char c) { _data.Add(c); return *this; } - // Append characters sequence to the string - // @param str String to append - // @return Current String Builder instance StringBuilder& Append(const Char* str) { const int32 length = StringUtils::Length(str); @@ -108,19 +98,12 @@ public: return *this; } - // Append characters sequence to the string - // @param str String to append - // @param length String length - // @return Current String Builder instance StringBuilder& Append(const Char* str, int32 length) { _data.Add(str, length); return *this; } - // Append characters sequence to the string - // @param str String to append - // @return Current String Builder instance StringBuilder& Append(const char* str) { const int32 length = str && *str ? StringUtils::Length(str) : 0; @@ -131,23 +114,18 @@ public: return *this; } - // Append String to the string - // @param str String to append - // @return Current String Builder instance StringBuilder& Append(const String& str) { _data.Add(*str, str.Length()); return *this; } + StringBuilder& Append(const StringView& str) { _data.Add(*str, str.Length()); return *this; } - // Append int to the string - // @param val Value to append - // @return Current String Builder instance StringBuilder& Append(int32 val) { auto str = StringUtils::ToString(val); @@ -155,9 +133,6 @@ public: return *this; } - // Append int to the string - // @param val Value to append - // @return Current String Builder instance StringBuilder& Append(uint32 val) { auto str = StringUtils::ToString(val); @@ -165,11 +140,8 @@ public: return *this; } - // Append formatted message to the string - // @param format Format string - // @param args Array with custom arguments for the message template - StringBuilder& AppendFormat(const Char* format, const Args& ... args) + StringBuilder& AppendFormat(const Char* format, const Args&... args) { fmt_flax::allocator allocator; fmt_flax::memory_buffer buffer(allocator); @@ -177,16 +149,12 @@ public: return Append(buffer.data(), (int32)buffer.size()); } -public: StringBuilder& AppendLine() { Append(TEXT(PLATFORM_LINE_TERMINATOR)); return *this; } - // Append int to the string - // @param val Value to append - // @return Current String Builder instance StringBuilder& AppendLine(int32 val) { Append(val); @@ -194,9 +162,6 @@ public: return *this; } - // Append int to the string - // @param val Value to append - // @return Current String Builder instance StringBuilder& AppendLine(uint32 val) { Append(val); @@ -204,9 +169,6 @@ public: return *this; } - // Append String to the string - // @param str String to append - // @return Current String Builder instance StringBuilder& AppendLine(const Char* str) { const int32 length = StringUtils::Length(str); @@ -215,9 +177,6 @@ public: return *this; } - // Append String to the string - // @param str String to append - // @return Current String Builder instance StringBuilder& AppendLine(const String& str) { _data.Add(*str, str.Length()); @@ -226,38 +185,25 @@ public: } public: - // Retrieves substring created from characters starting from startIndex - // @param startIndex Index of the first character to subtract - // @param count Amount of characters to retrieve - // @return Substring created from StringBuilder data - String Substring(int32 startIndex, int32 count) const - { - ASSERT(startIndex >= 0 && startIndex + count <= _data.Count() && count > 0); - return String(_data.Get() + startIndex, count); - } - -public: - // Get pointer to the string - // @returns Pointer to Array of Chars if Num, otherwise the empty string + // Gets pointer to the string. FORCE_INLINE const Char* operator*() const { return _data.Count() > 0 ? _data.Get() : TEXT(""); } - // Get pointer to the string - // @returns Pointer to Array of Chars if Num, otherwise the empty string + // Gets pointer to the string. FORCE_INLINE Char* operator*() { return _data.Count() > 0 ? _data.Get() : (Char*)TEXT(""); } - // Get string as array of Chars + // Gets string buffer as array of Chars. FORCE_INLINE Array& GetCharArray() { return _data; } - // Get string as const array of Chars + // Gets string buffer as const array of Chars. FORCE_INLINE const Array& GetCharArray() const { return _data; diff --git a/Source/Engine/Core/Utilities.h b/Source/Engine/Core/Utilities.h index 1a637cfe7..940647ed7 100644 --- a/Source/Engine/Core/Utilities.h +++ b/Source/Engine/Core/Utilities.h @@ -38,11 +38,14 @@ namespace Utilities return (T)round((double)value * 1000.0) / (T)1000; } - // Converts units to the best fitting human-readable denominator - // @param units Units count - // @param divider Amount of units required for the next size - // @param sizes Array with human-readable sizes to convert from - // @return The best fitting string of the units + /// + /// Converts units to the best fitting human-readable denominator. + /// + /// Value type. + /// Units count + /// Amount of units required for the next size. + /// Array with human-readable sizes to convert from. + /// The best fitting string of the units. template String UnitsToText(T units, int32 divider, const Span sizes) { @@ -61,18 +64,24 @@ namespace Utilities return String::Format(TEXT("{0} {1}"), text, sizes[i]); } - // Converts size of the file (in bytes) to the best fitting string - // @param bytes Size of the file in bytes - // @return The best fitting string of the file size + /// + /// Converts size of the data (in bytes) to the best fitting string. + /// + /// Value type. + /// Size of the data in bytes. + /// The best fitting string of the data size. template String BytesToText(T bytes) { return UnitsToText(bytes, 1024, Private::BytesSizes); } - // Converts hertz to the best fitting string - // @param hertz Hertz for convertion - // @return The best fitting string + /// + /// Converts hertz to the best fitting string. + /// + /// Value type. + /// Value in hertz for conversion. + /// The best fitting string. template String HertzToText(T hertz) { diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp index 3e47d974c..75ca25d9a 100644 --- a/Source/Engine/Graphics/RenderTools.cpp +++ b/Source/Engine/Graphics/RenderTools.cpp @@ -600,31 +600,19 @@ void RenderTools::ComputeSphereModelDrawMatrix(const RenderView& view, const Flo resultIsViewInside = Float3::DistanceSquared(view.Position, position) < Math::Square(radius * 1.1f); // Manually tweaked bias } -int32 MipLevelsCount(int32 width, bool useMipLevels) +int32 MipLevelsCount(int32 width) { - if (!useMipLevels) - return 1; - int32 result = 1; while (width > 1) { width >>= 1; result++; } - return result; } -int32 MipLevelsCount(int32 width, int32 height, bool useMipLevels) +int32 MipLevelsCount(int32 width, int32 height) { - // Check if use mip maps - if (!useMipLevels) - { - // No mipmaps chain, only single mip map - return 1; - } - - // Count mip maps int32 result = 1; while (width > 1 || height > 1) { @@ -637,11 +625,8 @@ int32 MipLevelsCount(int32 width, int32 height, bool useMipLevels) return result; } -int32 MipLevelsCount(int32 width, int32 height, int32 depth, bool useMipLevels) +int32 MipLevelsCount(int32 width, int32 height, int32 depth) { - if (!useMipLevels) - return 1; - int32 result = 1; while (width > 1 || height > 1 || depth > 1) { @@ -653,7 +638,6 @@ int32 MipLevelsCount(int32 width, int32 height, int32 depth, bool useMipLevels) depth >>= 1; result++; } - return result; } diff --git a/Source/Engine/Graphics/RenderTools.h b/Source/Engine/Graphics/RenderTools.h index 3f3cab65f..de0d318c6 100644 --- a/Source/Engine/Graphics/RenderTools.h +++ b/Source/Engine/Graphics/RenderTools.h @@ -136,23 +136,11 @@ public: static void ComputeSphereModelDrawMatrix(const RenderView& view, const Float3& position, float radius, Matrix& resultWorld, bool& resultIsViewInside); }; -// Calculate mip levels count for a texture 1D -// @param width Most detailed mip width -// @param useMipLevels True if use mip levels, otherwise false (use only 1 mip) -// @returns Mip levels count -extern int32 MipLevelsCount(int32 width, bool useMipLevels = true); +// Calculates mip levels count for a texture 1D. +extern int32 MipLevelsCount(int32 width); -// Calculate mip levels count for a texture 2D -// @param width Most detailed mip width -// @param height Most detailed mip height -// @param useMipLevels True if use mip levels, otherwise false (use only 1 mip) -// @returns Mip levels count -extern int32 MipLevelsCount(int32 width, int32 height, bool useMipLevels = true); +// Calculates mip levels count for a texture 2D. +extern int32 MipLevelsCount(int32 width, int32 height); -// Calculate mip levels count for a texture 3D -// @param width Most detailed mip width -// @param height Most detailed mip height -// @param depth Most detailed mip depths -// @param useMipLevels True if use mip levels, otherwise false (use only 1 mip) -// @returns Mip levels count -extern int32 MipLevelsCount(int32 width, int32 height, int32 depth, bool useMipLevels = true); +// Calculates mip levels count for a texture 3D. +extern int32 MipLevelsCount(int32 width, int32 height, int32 depth); diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index 78b1b639c..715784d9e 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -852,7 +852,7 @@ public: API_FUNCTION() bool HasActorInChildren(Actor* a) const; /// - /// Determines if there is an intersection between the current object and a Ray. + /// Determines if there is an intersection between the current object and a ray. /// /// The ray to test. /// When the method completes, contains the distance of the intersection (if any valid). @@ -879,7 +879,7 @@ public: /// Rotates actor to orient it towards the specified world position with upwards direction. /// /// The world position to orient towards. - /// The up direction that Constrains y axis orientation to a plane this vector lies on. This rule might be broken if forward and up direction are nearly parallel. + /// The up direction that constrains up axis orientation to a plane this vector lies on. This rule might be broken if forward and up direction are nearly parallel. API_FUNCTION() void LookAt(const Vector3& worldPos, const Vector3& worldUp); /// diff --git a/Source/Engine/Platform/StringUtils.h b/Source/Engine/Platform/StringUtils.h index e27194e83..af82f9f8b 100644 --- a/Source/Engine/Platform/StringUtils.h +++ b/Source/Engine/Platform/StringUtils.h @@ -64,55 +64,27 @@ public: } public: - // Returns true if character is uppercase static bool IsUpper(char c); - - // Returns true if character is lowercase static bool IsLower(char c); - static bool IsAlpha(char c); - static bool IsPunct(char c); - static bool IsAlnum(char c); - static bool IsDigit(char c); - static bool IsHexDigit(char c); - - // Returns true if character is a whitespace static bool IsWhitespace(char c); - - // Convert wide character to upper case static char ToUpper(char c); - - // Convert wide character to lower case static char ToLower(char c); public: - // Returns true if character is uppercase static bool IsUpper(Char c); - - // Returns true if character is lowercase static bool IsLower(Char c); - static bool IsAlpha(Char c); - static bool IsPunct(Char c); - static bool IsAlnum(Char c); - static bool IsDigit(Char c); - static bool IsHexDigit(Char c); - - // Returns true if character is a whitespace static bool IsWhitespace(Char c); - - // Convert wide character to upper case static Char ToUpper(Char c); - - // Convert wide character to lower case static Char ToLower(Char c); public: @@ -141,40 +113,28 @@ public: static int32 CompareIgnoreCase(const char* str1, const char* str2, int32 maxCount); public: - // Get string length. Returns 0 if str is null. + // Gets the string length. Returns 0 if str is null. static int32 Length(const Char* str); - // Get string length. Returns 0 if str is null. + // Gets the string length. Returns 0 if str is null. static int32 Length(const char* str); - // Copy string + // Copies the string. static Char* Copy(Char* dst, const Char* src); - // Copy string (count is maximum amount of characters to copy) + // Copies the string (count is maximum amount of characters to copy). static Char* Copy(Char* dst, const Char* src, int32 count); - // Finds string in string, case sensitive - // @param str The string to look through - // @param toFind The string to find inside str - // @return Position in str if Find was found, otherwise null + // Finds specific sub-string in the input string. Returns the first found position in the input string or nulll if failed. static const Char* Find(const Char* str, const Char* toFind); - // Finds string in string, case sensitive - // @param str The string to look through - // @param toFind The string to find inside str - // @return Position in str if Find was found, otherwise null + // Finds specific sub-string in the input string, case sensitive. Returns the first found position in the input string or nulll if failed. static const char* Find(const char* str, const char* toFind); - // Finds string in string, case insensitive - // @param str The string to look through - // @param toFind The string to find inside str - // @return Position in str if toFind was found, otherwise null + // Finds specific sub-string in the input string, case insensitive. Returns the first found position in the input string or nulll if failed. static const Char* FindIgnoreCase(const Char* str, const Char* toFind); - // Finds string in string, case insensitive - // @param str The string to look through - // @param toFind The string to find inside str - // @return Position in str if toFind was found, otherwise null + // Finds specific sub-string in the input string, case insensitive. Returns the first found position in the input string or nulll if failed. static const char* FindIgnoreCase(const char* str, const char* toFind); public: @@ -197,101 +157,94 @@ public: static char* ConvertUTF162UTF8(const Char* from, int32 fromLength, int32& toLength); public: - // Returns the directory name of the specified path string - // @param path The path string from which to obtain the directory name - // @returns Directory name + /// + /// Gets the directory name of the specified path string. + /// + /// The path string from which to obtain the directory name. + /// Directory name. static StringView GetDirectoryName(const StringView& path); - // Returns the file name and extension of the specified path string - // @param path The path string from which to obtain the file name and extension - // @returns File name with extension + /// + /// Gets the file name and extension of the specified path string + /// + /// The path string from which to obtain the file name and extension. + /// File name with extension. static StringView GetFileName(const StringView& path); - // Returns the file name without extension of the specified path string - // @param path The path string from which to obtain the file name - // @returns File name without extension + /// + /// Gets the file name without extension of the specified path string. + /// + /// The path string from which to obtain the file name. + /// File name without extension. static StringView GetFileNameWithoutExtension(const StringView& path); + /// + /// Gets the path without extension. + /// + /// The path string. + /// The path string without extension. static StringView GetPathWithoutExtension(const StringView& path); + /// + /// Normalizes path string and removes any relative parts such as `/../` and `/./`. + /// + /// The input and output string with path to process. static void PathRemoveRelativeParts(String& path); public: // Converts hexadecimal character into the value. static int32 HexDigit(Char c); - // Parse text to unsigned integer value - // @param str String to parse - // @return Result value - // @returns True if cannot convert data, otherwise false + // Parses text to unsigned integer value. Returns true if failed to convert the value. template static bool ParseHex(const CharType* str, uint32* result) { uint32 sum = 0; const CharType* p = str; - if (*p == '0' && *(p + 1) == 'x') p += 2; - while (*p) { int32 c = *p - '0'; - if (c < 0 || c > 9) { c = ToLower(*p) - 'a' + 10; if (c < 10 || c > 15) return true; } - sum = 16 * sum + c; - p++; } - *result = sum; return false; } - // Parse text to unsigned integer value - // @param str String to parse - // @param length Text length - // @return Result value - // @returns True if cannot convert data, otherwise false + // Parses text to unsigned integer value. Returns true if failed to convert the value. template static bool ParseHex(const CharType* str, int32 length, uint32* result) { uint32 sum = 0; const CharType* p = str; const CharType* end = str + length; - if (*p == '0' && *(p + 1) == 'x') p += 2; - while (*p && p < end) { int32 c = *p - '0'; - if (c < 0 || c > 9) { c = ToLower(*p) - 'a' + 10; if (c < 10 || c > 15) return true; } - sum = 16 * sum + c; - p++; } - *result = sum; return false; } - // Parse text to scalar value - // @param str String to parse - // @return Result value - // @returns True if cannot convert data, otherwise false + // Parses text to scalar integer value. Returns true if failed to convert the value. template static bool Parse(const T* str, U* result) { @@ -308,11 +261,7 @@ public: return false; } - // Parse text to scalar value - // @param str String to parse - // @param length Text length to read - // @return Result value - // @returns True if cannot convert data, otherwise false + // Parses text to scalar integer value. Returns true if failed to convert the value. template static bool Parse(const T* str, uint32 length, U* result) { @@ -329,11 +278,10 @@ public: return false; } - // Parse Unicode text to float value - // @param str String to parse - // @return Result value - // @returns True if cannot convert data, otherwise false + // Parses text to the scalar value. Returns true if failed to convert the value. static bool Parse(const Char* str, float* result); + + // Parses text to the scalar value. Returns true if failed to convert the value. static bool Parse(const char* str, float* result); public: @@ -345,9 +293,7 @@ public: static String ToString(double value); public: - // Returns the String to double null-terminated string - // @param str Double null-terminated string - // @return Double null-terminated String + // Converts the string to double null-terminated string. static String GetZZString(const Char* str); }; diff --git a/Source/Engine/Serialization/ReadStream.h b/Source/Engine/Serialization/ReadStream.h index 696c6ab28..b7cec5e30 100644 --- a/Source/Engine/Serialization/ReadStream.h +++ b/Source/Engine/Serialization/ReadStream.h @@ -22,8 +22,6 @@ public: virtual void ReadBytes(void* data, uint32 bytes) = 0; public: - // Reads byte from the stream - // @returns Single byte byte ReadByte() { byte data; @@ -31,7 +29,6 @@ public: return data; } - // Reads bool from the stream bool ReadBool() { byte data; @@ -39,8 +36,6 @@ public: return data != 0; } - // Reads char from the stream - // @param data Data to read char ReadChar() { char data; @@ -53,78 +48,56 @@ public: ReadBytes(data, sizeof(byte)); } - // Reads Char from the stream - // @param data Data to read FORCE_INLINE void ReadChar(Char* data) { ReadBytes(data, sizeof(Char)); } - // Reads uint8 from the stream - // @param data Data to read FORCE_INLINE void ReadUint8(uint8* data) { ReadBytes(data, sizeof(uint8)); } - // Reads int8 from the stream - // @param data Data to read FORCE_INLINE void ReadInt8(int8* data) { ReadBytes(data, sizeof(int8)); } - // Reads uint16 from the stream - // @param data Data to read FORCE_INLINE void ReadUint16(uint16* data) { ReadBytes(data, sizeof(uint16)); } - // Reads int16 from the stream - // @param data Data to read FORCE_INLINE void ReadInt16(int16* data) { ReadBytes(data, sizeof(int16)); } - // Reads uint32 from the stream - // @param data Data to read FORCE_INLINE void ReadUint32(uint32* data) { ReadBytes(data, sizeof(uint32)); } - // Reads int32 from the stream - // @param data Data to read FORCE_INLINE void ReadInt32(int32* data) { ReadBytes(data, sizeof(int32)); } - // Reads uint64 from the stream - // @param data Data to read FORCE_INLINE void ReadUint64(uint64* data) { ReadBytes(data, sizeof(uint64)); } - // Reads int64 from the stream - // @param data Data to read FORCE_INLINE void ReadInt64(int64* data) { ReadBytes(data, sizeof(int64)); } - // Reads float from the stream - // @param data Data to read FORCE_INLINE void ReadFloat(float* data) { ReadBytes(data, sizeof(float)); } - // Reads double from the stream - // @param data Data to read FORCE_INLINE void ReadDouble(double* data) { ReadBytes(data, sizeof(double)); @@ -160,6 +133,7 @@ public: Read(ptr); v = ptr; } + template FORCE_INLINE void Read(SoftObjectReference& v) { @@ -167,6 +141,7 @@ public: ReadBytes(id, sizeof(id)); v.Set(*(Guid*)id); } + template FORCE_INLINE void Read(AssetReference& v) { @@ -174,6 +149,7 @@ public: ReadBytes(id, sizeof(id)); v = (T*)::LoadAsset(*(Guid*)id, T::TypeInitializer); } + template FORCE_INLINE void Read(WeakAssetReference& v) { @@ -181,6 +157,7 @@ public: ReadBytes(id, sizeof(id)); v = (T*)::LoadAsset(*(Guid*)id, T::TypeInitializer); } + template FORCE_INLINE void Read(SoftAssetReference& v) { @@ -240,38 +217,30 @@ public: public: // Reads StringAnsi from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadStringAnsi(StringAnsi* data); // Reads StringAnsi from the stream with a key /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadStringAnsi(StringAnsi* data, int8 lock); // Reads String from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadString(String* data); // Reads String from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read - // @param lock Characters pass in the stream void ReadString(String* data, int16 lock); // Reads CommonValue from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadCommonValue(CommonValue* data); // Reads VariantType from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadVariantType(VariantType* data); // Reads Variant from the stream /// [Deprecated on 11.10.2022, expires on 11.10.2024] - // @param data Data to read void ReadVariant(Variant* data); /// diff --git a/Source/Engine/Threading/IRunnable.h b/Source/Engine/Threading/IRunnable.h index 31da52817..fab9fd6b7 100644 --- a/Source/Engine/Threading/IRunnable.h +++ b/Source/Engine/Threading/IRunnable.h @@ -13,35 +13,44 @@ class IRunnable : public Object { public: - // Virtual destructor virtual ~IRunnable() { } - // Initializes the runnable object - // @return True if initialization was successful, otherwise false + /// + /// Initializes the runnable object. + /// + /// True if initialization was successful, otherwise false. virtual bool Init() { return true; } - // Runs the runnable object. - // @return The exit code + /// + /// Executes the runnable object. + /// + /// The exit code. Non-zero on error. virtual int32 Run() = 0; - // Stops the runnable object. Called when thread is being terminated + /// + /// Stops the runnable object. Called when thread is being terminated + /// virtual void Stop() { } - // Exits the runnable object + /// + /// Exits the runnable object + /// virtual void Exit() { } - // Called when thread ends work (via Kill or normally) - // @param wasKilled True if thread has been killed + /// + /// Called when thread ends work (via Kill or normally). + /// + /// True if thread has been killed. virtual void AfterWork(bool wasKilled) { } @@ -53,18 +62,15 @@ public: class SimpleRunnable : public IRunnable { private: - bool _autoDelete; public: - /// /// Working function /// Function OnWork; public: - /// /// Init /// @@ -75,7 +81,6 @@ public: } public: - // [IRunnable] String ToString() const override { diff --git a/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp b/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp index 2f20cd503..094daefda 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp @@ -710,7 +710,7 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path bool hasSourceMipLevels = isPowerOfTwo && sourceMipLevels > 1; bool useMipLevels = isPowerOfTwo && (options.GenerateMipMaps || hasSourceMipLevels) && (width > 1 || height > 1); int32 arraySize = (int32)currentImage->GetMetadata().arraySize; - int32 mipLevels = MipLevelsCount(width, height, useMipLevels); + int32 mipLevels = useMipLevels ? MipLevelsCount(width, height) : 1; if (useMipLevels && !options.GenerateMipMaps && mipLevels != sourceMipLevels) { errorMsg = String::Format(TEXT("Imported texture has not full mip chain, loaded mips count: {0}, expected: {1}"), sourceMipLevels, mipLevels);