feat: added raycasting support for physics engine 2D
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
@@ -35,6 +37,26 @@ public interface IPhysicsEngine2D
|
||||
/// <param name="deltaTime">The time step.</param>
|
||||
void StepIndividual(IRigidBody2D rigidBody, float deltaTime);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Ray2D"/> into the scene and returns the closest <see cref="RaycastResult"/> it hits, if any.
|
||||
/// </summary>
|
||||
/// <param name="ray">The <see cref="Ray2D"/> to cast.</param>
|
||||
/// <param name="length">The maximum distance to check for intersections. Defaults to <see cref="float.MaxValue"/>.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="RaycastResult"/> containing information about the hit, or <see cref="null"/> if no hit was detected.
|
||||
/// </returns>
|
||||
RaycastResult? Raycast(Ray2D ray, float length = float.MaxValue);
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Ray2D"/> into the scene and stores all hit results in the provided list.
|
||||
/// </summary>
|
||||
/// <param name="ray">The <see cref="Ray2D"/> to cast.</param>
|
||||
/// <param name="results">
|
||||
/// A list to which all <see cref="RaycastResult"/>s will be added. The list will be populated with zero or more <see cref="RaycastResult"/> objects.
|
||||
/// </param>
|
||||
/// <param name="length">The maximum distance to check for intersections. Defaults to <see cref="float.MaxValue"/>.</param>
|
||||
void Raycast(Ray2D ray, IList<RaycastResult> results, float length = float.MaxValue);
|
||||
|
||||
readonly record struct PhysicsIterationArguments(IPhysicsEngine2D Sender, float IterationDeltaTime);
|
||||
readonly record struct PhysicsStepArguments(IPhysicsEngine2D Sender, float StepDeltaTime);
|
||||
}
|
||||
|
Reference in New Issue
Block a user