Compare commits
	
		
			8 Commits
		
	
	
		
			767fc28488
			...
			7212094a3d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 7212094a3d | |||
| 14843ddeba | |||
| 5315db0077 | |||
| 026f343d43 | |||
| da5f31f9d7 | |||
| fa1614f238 | |||
| 0c096d39db | |||
| dae6549bad | 
@@ -1,6 +1,5 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
@@ -50,17 +49,13 @@ public class BehaviourController : BaseEntity, IBehaviourController
 | 
			
		||||
 | 
			
		||||
    public IReadOnlyList<T> GetBehaviours<T>()
 | 
			
		||||
    {
 | 
			
		||||
        List<T>? behaviours = null;
 | 
			
		||||
        List<T> behaviours = [];
 | 
			
		||||
 | 
			
		||||
        foreach (IBehaviour behaviourItem in this.behaviours)
 | 
			
		||||
        {
 | 
			
		||||
            if (behaviourItem is not T behaviour)
 | 
			
		||||
                continue;
 | 
			
		||||
            if (behaviourItem is T behaviour)
 | 
			
		||||
                behaviours.Add(behaviour);
 | 
			
		||||
 | 
			
		||||
            behaviours ??= [];
 | 
			
		||||
            behaviours.Add(behaviour);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return behaviours ?? Enumerable.Empty<T>().ToList();
 | 
			
		||||
        return behaviours;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void GetBehaviours<T>(IList<T> results)
 | 
			
		||||
 
 | 
			
		||||
@@ -6,29 +6,29 @@ namespace Syntriax.Engine.Core;
 | 
			
		||||
public static class Math
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The value of Pi (π), a mathematical constant approximately equal to 3.14159.
 | 
			
		||||
    /// The value of Pi (π).
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const float PI = 3.1415926535897932f;
 | 
			
		||||
    public const float Pi = 3.1415926535897932f;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The value of Tau (τ), a mathematical constant equal to 2π, approximately equal to 6.28319.
 | 
			
		||||
    /// The value of Tau (τ), mathematical constant equal to 2π.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const float Tau = 2f * PI;
 | 
			
		||||
    public const float Tau = 2f * Pi;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The base of the natural logarithm, approximately equal to 2.71828.
 | 
			
		||||
    /// The base of the natural logarithm.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const float E = 2.718281828459045f;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The conversion factor from radians to degrees.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const float RadianToDegree = 180f / PI;
 | 
			
		||||
    public const float RadianToDegree = 180f / Pi;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The conversion factor from degrees to radians.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public const float DegreeToRadian = PI / 180f;
 | 
			
		||||
    public const float DegreeToRadian = Pi / 180f;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets one minus of given <see cref="T"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,9 @@ public readonly struct AABB(Vector2D lowerBoundary, Vector2D upperBoundary)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly Vector2D SizeHalf => Size * .5f;
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(AABB left, AABB right) => left.UpperBoundary == right.UpperBoundary && left.LowerBoundary == right.LowerBoundary;
 | 
			
		||||
    public static bool operator !=(AABB left, AABB right) => left.UpperBoundary != right.UpperBoundary || left.LowerBoundary != right.LowerBoundary;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates an <see cref="AABB"/> from a collection of <see cref="Vector2D"/>s.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -78,7 +81,7 @@ public readonly struct AABB(Vector2D lowerBoundary, Vector2D upperBoundary)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="AABB"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="AABB"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is AABB aabb && LowerBoundary.Equals(aabb.LowerBoundary) && UpperBoundary.Equals(aabb.UpperBoundary);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is AABB aabb && this == aabb;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="AABB"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,9 @@ public readonly struct Circle(Vector2D center, float radius)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static readonly Circle UnitCircle = new(Vector2D.Zero, 1f);
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Circle left, Circle right) => left.Center == right.Center && left.Radius == right.Radius;
 | 
			
		||||
    public static bool operator !=(Circle left, Circle right) => left.Center != right.Center || left.Radius != right.Radius;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the center of the <see cref="Circle"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -83,7 +86,7 @@ public readonly struct Circle(Vector2D center, float radius)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Circle"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Circle"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Circle circle && Center.Equals(circle.Center) && Radius.Equals(circle.Radius);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Circle circle && this == circle;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Circle"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -34,8 +34,8 @@ public readonly struct ColorHSV(float hue, float saturation, float value)
 | 
			
		||||
    public static ColorHSV operator *(ColorHSV color, float value) => new((color.Hue * value).Clamp(0f, 1f), (color.Saturation * value).Clamp(0f, 1f), (color.Value * value).Clamp(0f, 1f));
 | 
			
		||||
    public static ColorHSV operator *(float value, ColorHSV color) => new((color.Hue * value).Clamp(0f, 1f), (color.Saturation * value).Clamp(0f, 1f), (color.Value * value).Clamp(0f, 1f));
 | 
			
		||||
    public static ColorHSV operator /(ColorHSV color, float value) => new((color.Hue / value).Clamp(0f, 1f), (color.Saturation / value).Clamp(0f, 1f), (color.Value / value).Clamp(0f, 1f));
 | 
			
		||||
    public static bool operator ==(ColorHSV left, ColorHSV right) => left.Hue.ApproximatelyEquals(right.Hue) && left.Saturation.ApproximatelyEquals(right.Saturation) && left.Value.ApproximatelyEquals(right.Value);
 | 
			
		||||
    public static bool operator !=(ColorHSV left, ColorHSV right) => !left.Hue.ApproximatelyEquals(right.Hue) || !left.Saturation.ApproximatelyEquals(right.Saturation) || !left.Value.ApproximatelyEquals(right.Value);
 | 
			
		||||
    public static bool operator ==(ColorHSV left, ColorHSV right) => left.Hue == right.Hue && left.Saturation == right.Saturation && left.Value == right.Value;
 | 
			
		||||
    public static bool operator !=(ColorHSV left, ColorHSV right) => left.Hue != right.Hue || left.Saturation != right.Saturation || left.Value != right.Value;
 | 
			
		||||
 | 
			
		||||
    public static implicit operator ColorHSV(ColorRGBA rgba) => (ColorRGB)rgba;
 | 
			
		||||
    public static implicit operator ColorHSV(ColorRGB rgb)
 | 
			
		||||
@@ -142,7 +142,7 @@ public readonly struct ColorHSV(float hue, float saturation, float value)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="ColorHSV"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorHSV"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorHSV colorHSV && Hue.Equals(colorHSV.Hue) && Saturation.Equals(colorHSV.Saturation) && Value.Equals(colorHSV.Value);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorHSV colorHSV && this == colorHSV;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="ColorHSV"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -124,7 +124,7 @@ public readonly struct ColorRGB(byte r, byte g, byte b)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="ColorRGB"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorRGB"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorRGB colorRGB && R.Equals(colorRGB.R) && G.Equals(colorRGB.G) && B.Equals(colorRGB.B);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorRGB colorRGB && this == colorRGB;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="ColorRGB"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -107,7 +107,7 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="ColorRGBA"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="ColorRGBA"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorRGBA colorRGBA && R.Equals(colorRGBA.R) && G.Equals(colorRGBA.G) && B.Equals(colorRGBA.B) && A.Equals(colorRGBA.A);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is ColorRGBA colorRGBA && this == colorRGBA;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="ColorRGBA"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,9 @@ public readonly struct Line2D(Vector2D from, Vector2D to)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly float LengthSquared => From.FromTo(To).LengthSquared();
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Line2D left, Line2D right) => left.From == right.From && left.To == right.To;
 | 
			
		||||
    public static bool operator !=(Line2D left, Line2D right) => left.From != right.From || left.To != right.To;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The equation of the <see cref="Line2D"/> defined by this <see cref="Line2D"/> segment.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -192,7 +195,7 @@ public readonly struct Line2D(Vector2D from, Vector2D to)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Line2D"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Line2D"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Line2D line2D && From.Equals(line2D.From) && To.Equals(line2D.To);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Line2D line2D && this == line2D;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Line2D"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,41 +1,44 @@
 | 
			
		||||
namespace Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Represents a line equation in the form y = mx + b.
 | 
			
		||||
/// Represents a <see cref="Line2DEquation"/> in the form y = mx + b.
 | 
			
		||||
/// </summary>
 | 
			
		||||
/// <param name="slope">The slope of the line.</param>
 | 
			
		||||
/// <param name="offsetY">The y-intercept of the line.</param>
 | 
			
		||||
/// <param name="offsetY">The Y intercept of the line.</param>
 | 
			
		||||
/// <remarks>
 | 
			
		||||
/// Initializes a new instance of the <see cref="Line2DEquation"/> struct with the specified slope and y-intercept.
 | 
			
		||||
/// Initializes a new instance of the <see cref="Line2DEquation"/> struct with the specified slope and Y intercept.
 | 
			
		||||
/// </remarks>
 | 
			
		||||
[System.Diagnostics.DebuggerDisplay("y = {Slope}x + {OffsetY}")]
 | 
			
		||||
public readonly struct Line2DEquation(float slope, float offsetY)
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The slope of the line equation.
 | 
			
		||||
    /// The slope of the <see cref="Line2DEquation"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly float Slope = slope;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The y-intercept of the line equation.
 | 
			
		||||
    /// The Y intercept of the <see cref="Line2DEquation"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly float OffsetY = offsetY;
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Line2DEquation left, Line2DEquation right) => left.Slope == right.Slope && left.OffsetY == right.OffsetY;
 | 
			
		||||
    public static bool operator !=(Line2DEquation left, Line2DEquation right) => left.Slope != right.Slope || left.OffsetY != right.OffsetY;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Resolves the y-coordinate for a given x-coordinate using the line equation.
 | 
			
		||||
    /// Resolves the Y coordinate for a given X coordinate using the <see cref="Line2DEquation"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="lineEquation">The line equation to resolve.</param>
 | 
			
		||||
    /// <param name="x">The x-coordinate for which to resolve the y-coordinate.</param>
 | 
			
		||||
    /// <returns>The y-coordinate resolved using the line equation.</returns>
 | 
			
		||||
    /// <param name="lineEquation">The <see cref="Line2DEquation"/> to resolve.</param>
 | 
			
		||||
    /// <param name="x">The X coordinate for which to resolve the Y coordinate.</param>
 | 
			
		||||
    /// <returns>The Y coordinate resolved using the <see cref="Line2DEquation"/>.</returns>
 | 
			
		||||
    public static float Resolve(Line2DEquation lineEquation, float x) => lineEquation.Slope * x + lineEquation.OffsetY; // y = mx + b
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Checks if two line equations are approximately equal.
 | 
			
		||||
    /// Checks if two <see cref="Line2DEquation"/> are approximately equal.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="left">The first line equation to compare.</param>
 | 
			
		||||
    /// <param name="right">The second line equation to compare.</param>
 | 
			
		||||
    /// <param name="left">The first <see cref="Line2DEquation"/> to compare.</param>
 | 
			
		||||
    /// <param name="right">The second <see cref="Line2DEquation"/> to compare.</param>
 | 
			
		||||
    /// <param name="epsilon">The epsilon range.</param>
 | 
			
		||||
    /// <returns>True if the line equations are approximately equal; otherwise, false.</returns>
 | 
			
		||||
    /// <returns>True if the <see cref="Line2DEquation"/> are approximately equal; otherwise, false.</returns>
 | 
			
		||||
    public static bool ApproximatelyEquals(Line2DEquation left, Line2DEquation right, float epsilon = float.Epsilon)
 | 
			
		||||
        => left.Slope.ApproximatelyEquals(right.Slope, epsilon) && left.OffsetY.ApproximatelyEquals(right.OffsetY, epsilon);
 | 
			
		||||
 | 
			
		||||
@@ -44,7 +47,7 @@ public readonly struct Line2DEquation(float slope, float offsetY)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Line2DEquation"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Line2DEquation"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Line2DEquation lineEquation && Slope.Equals(lineEquation.Slope) && OffsetY.Equals(lineEquation.OffsetY);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Line2DEquation lineEquation && this == lineEquation;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Line2DEquation"/>.
 | 
			
		||||
@@ -60,7 +63,7 @@ public readonly struct Line2DEquation(float slope, float offsetY)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Provides extension methods for the LineEquation struct.
 | 
			
		||||
/// Provides extension methods for the <see cref="Line2DEquation"/> struct.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class Line2DEquationExtensions
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,9 @@ public readonly struct Projection1D(float min, float max)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly float Max = max;
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Projection1D left, Projection1D right) => left.Min == right.Min && left.Max == right.Max;
 | 
			
		||||
    public static bool operator !=(Projection1D left, Projection1D right) => left.Min != right.Min || left.Max != right.Max;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Checks if two projections overlap.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
@@ -71,12 +74,22 @@ public readonly struct Projection1D(float min, float max)
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Checks if two <see cref="Projection1D"/>s are approximately equal within a specified epsilon range.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="left">The first <see cref="Projection1D"/>.</param>
 | 
			
		||||
    /// <param name="right">The second <see cref="Projection1D"/>.</param>
 | 
			
		||||
    /// <param name="epsilon">The epsilon range.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the <see cref="Projection1D"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public static bool ApproximatelyEquals(Projection1D left, Projection1D right, float epsilon = float.Epsilon)
 | 
			
		||||
        => left.Min.ApproximatelyEquals(right.Min, epsilon) && left.Max.ApproximatelyEquals(right.Max, epsilon);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines whether the specified object is equal to the current <see cref="Projection1D"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Projection1D"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Projection1D"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Projection1D projection1D && Min.Equals(projection1D.Min) && Max.Equals(projection1D.Max);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Projection1D projection1D && this == projection1D;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Projection1D"/>.
 | 
			
		||||
@@ -101,4 +114,7 @@ public static class Projection1DExtensions
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc cref="Projection1D.Overlaps(Projection1D, Projection1D, out float)" />
 | 
			
		||||
    public static bool Overlaps(this Projection1D left, Projection1D right, out float depth) => Projection1D.Overlaps(left, right, out depth);
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc cref="Projection1D.ApproximatelyEquals(Projection1D, Projection1D, float)" />
 | 
			
		||||
    public static bool ApproximatelyEquals(this Projection1D left, Projection1D right, float epsilon = float.Epsilon) => Projection1D.ApproximatelyEquals(left, right, epsilon);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -287,7 +287,7 @@ public readonly struct Quaternion(float x, float y, float z, float w)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Quaternion"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Quaternion"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Quaternion quaternion && X.Equals(quaternion.X) && Y.Equals(quaternion.Y) && Z.Equals(quaternion.Z) && W.Equals(quaternion.W);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Quaternion quaternion && this == quaternion;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Quaternion"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,8 @@ public readonly struct Ray2D(Vector2D Origin, Vector2D Direction)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public readonly Ray2D Reversed => new(Origin, -Direction);
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Ray2D left, Ray2D right) => left.Origin == right.Origin && left.Direction == right.Direction;
 | 
			
		||||
    public static bool operator !=(Ray2D left, Ray2D right) => left.Origin != right.Origin || left.Direction != right.Direction;
 | 
			
		||||
    public static implicit operator Ray2D(Line2D line) => new(line.From, line.From.FromTo(line.To).Normalized);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -54,12 +56,22 @@ public readonly struct Ray2D(Vector2D Origin, Vector2D Direction)
 | 
			
		||||
        return ray.Origin + ray.Direction * dot;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Checks if two <see cref="Ray2D"/>s are approximately equal within a specified epsilon range.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="left">The first <see cref="Ray2D"/>.</param>
 | 
			
		||||
    /// <param name="right">The second <see cref="Ray2D"/>.</param>
 | 
			
		||||
    /// <param name="epsilon">The epsilon range.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the <see cref="Ray2D"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public static bool ApproximatelyEquals(Ray2D left, Ray2D right, float epsilon = float.Epsilon)
 | 
			
		||||
        => left.Origin.ApproximatelyEquals(right.Origin, epsilon) && left.Direction.ApproximatelyEquals(right.Direction, epsilon);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Determines whether the specified object is equal to the current <see cref="Ray2D"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Ray2D"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Ray2D"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Ray2D ray2D && Origin.Equals(ray2D.Origin) && Direction.Equals(ray2D.Direction);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Ray2D ray2D && this == ray2D;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Ray2D"/>.
 | 
			
		||||
@@ -87,4 +99,7 @@ public static class Ray2DExtensions
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc cref="Ray2D.ClosestPointTo(Ray2D, Vector2D) />
 | 
			
		||||
    public static Vector2D ClosestPointTo(this Ray2D ray, Vector2D point) => Ray2D.ClosestPointTo(ray, point);
 | 
			
		||||
 | 
			
		||||
    /// <inheritdoc cref="Ray2D.ApproximatelyEquals(Ray2D, Ray2D, float)" />
 | 
			
		||||
    public static bool ApproximatelyEquals(this Ray2D left, Ray2D right, float epsilon = float.Epsilon) => Ray2D.ApproximatelyEquals(left, right, epsilon);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,9 @@ public readonly struct Triangle(Vector2D A, Vector2D B, Vector2D C)
 | 
			
		||||
    public readonly Vector2D B { get; init; } = B;
 | 
			
		||||
    public readonly Vector2D C { get; init; } = C;
 | 
			
		||||
 | 
			
		||||
    public static bool operator ==(Triangle left, Triangle right) => left.A == right.A && left.B == right.B && left.C == right.C;
 | 
			
		||||
    public static bool operator !=(Triangle left, Triangle right) => left.A != right.A || left.B != right.B || left.C != right.C;
 | 
			
		||||
 | 
			
		||||
    public readonly float Area
 | 
			
		||||
        => .5f * Math.Abs(
 | 
			
		||||
                A.X * (B.Y - C.Y) +
 | 
			
		||||
@@ -50,7 +53,7 @@ public readonly struct Triangle(Vector2D A, Vector2D B, Vector2D C)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Triangle"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Triangle"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Triangle triangle && A.Equals(triangle.A) && B.Equals(triangle.B) && C.Equals(triangle.C);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Triangle triangle && this == triangle;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Triangle"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -307,7 +307,7 @@ public readonly struct Vector2D(float x, float y)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Vector2D"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector2D"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Vector2D vector2D && X.Equals(vector2D.X) && Y.Equals(vector2D.Y);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Vector2D vector2D && this == vector2D;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Vector2D"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -276,7 +276,7 @@ public readonly struct Vector3D(float x, float y, float z)
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The object to compare with the current <see cref="Vector3D"/>.</param>
 | 
			
		||||
    /// <returns><see cref="true"/> if the specified object is equal to the current <see cref="Vector3D"/>; otherwise, <see cref="false"/>.</returns>
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Vector3D vector3D && X.Equals(vector3D.X) && Y.Equals(vector3D.Y) && Z.Equals(vector3D.Z);
 | 
			
		||||
    public override bool Equals(object? obj) => obj is Vector3D vector3D && this == vector3D;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Generates a hash code for the <see cref="Vector3D"/>.
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ namespace Syntriax.Engine.Core;
 | 
			
		||||
 | 
			
		||||
public class UpdateManager : Behaviour
 | 
			
		||||
{
 | 
			
		||||
    // We use Ascending order because draw calls are running from last to first
 | 
			
		||||
    // We use Ascending order because we are using reverse for loop to call them
 | 
			
		||||
    private static Comparer<IBehaviour> SortByAscendingPriority() => Comparer<IBehaviour>.Create((x, y) => x.Priority.CompareTo(y.Priority));
 | 
			
		||||
 | 
			
		||||
    private readonly ActiveBehaviourCollectorSorted<IFirstFrameUpdate> firstFrameUpdates = new() { SortBy = SortByAscendingPriority() };
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,8 @@ internal static class EaseConstants
 | 
			
		||||
    internal const float c1 = 1.70158f;
 | 
			
		||||
    internal const float c2 = c1 * 1.525f;
 | 
			
		||||
    internal const float c3 = c1 + 1f;
 | 
			
		||||
    internal const float c4 = 2f * Math.PI / 3f;
 | 
			
		||||
    internal const float c5 = 2f * Math.PI / 4.5f;
 | 
			
		||||
    internal const float c4 = 2f * Math.Pi / 3f;
 | 
			
		||||
    internal const float c5 = 2f * Math.Pi / 4.5f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public abstract class EasingBase<T> where T : IEasing, new() { public static readonly T Instance = new(); }
 | 
			
		||||
@@ -33,9 +33,9 @@ public class EaseInQuint : EasingBase<EaseInQuint>, IEasing { public float Evalu
 | 
			
		||||
public class EaseOutQuint : EasingBase<EaseOutQuint>, IEasing { public float Evaluate(float x) => 1f - Math.Pow(1f - x, 5f); }
 | 
			
		||||
public class EaseInOutQuint : EasingBase<EaseInOutQuint>, IEasing { public float Evaluate(float x) => x < .5f ? 16f * x * x * x * x * x : 1f - Math.Pow(-2f * x + 2f, 5f) * .5f; }
 | 
			
		||||
 | 
			
		||||
public class EaseInSine : EasingBase<EaseInSine>, IEasing { public float Evaluate(float x) => 1f - Math.Cos(x * Math.PI * .5f); }
 | 
			
		||||
public class EaseOutSine : EasingBase<EaseOutSine>, IEasing { public float Evaluate(float x) => Math.Sin(x * Math.PI * .5f); }
 | 
			
		||||
public class EaseInOutSine : EasingBase<EaseInOutSine>, IEasing { public float Evaluate(float x) => -(Math.Cos(Math.PI * x) - 1f) * .5f; }
 | 
			
		||||
public class EaseInSine : EasingBase<EaseInSine>, IEasing { public float Evaluate(float x) => 1f - Math.Cos(x * Math.Pi * .5f); }
 | 
			
		||||
public class EaseOutSine : EasingBase<EaseOutSine>, IEasing { public float Evaluate(float x) => Math.Sin(x * Math.Pi * .5f); }
 | 
			
		||||
public class EaseInOutSine : EasingBase<EaseInOutSine>, IEasing { public float Evaluate(float x) => -(Math.Cos(Math.Pi * x) - 1f) * .5f; }
 | 
			
		||||
 | 
			
		||||
public class EaseInExpo : EasingBase<EaseInExpo>, IEasing { public float Evaluate(float x) => x == 0f ? 0f : Math.Pow(2f, 10f * x - 10f); }
 | 
			
		||||
public class EaseOutExpo : EasingBase<EaseOutExpo>, IEasing { public float Evaluate(float x) => x == 1f ? 1f : 1f - Math.Pow(2f, -10f * x); }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user