Changed class `Trajectory` to interface `ITrajectory`

This commit is contained in:
ikpil 2024-05-31 22:36:57 +09:00
parent e9a5512bb2
commit d94408f7a1
12 changed files with 25 additions and 27 deletions

View File

@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Changed `MAX_STEER_POINTS` from class constant to local.
- Changed `List<DtStraightPath>` to `Span<DtStraightPath>` for enhanced memory efficiency
- Changed `DtWriter` to a static class and renamed it to `RcIO`
- Changed class `Trajectory` to interface `ITrajectory`
### Removed
- Nothing

View File

@ -4,9 +4,9 @@ using DotRecast.Core.Numerics;
namespace DotRecast.Detour.Extras.Jumplink
{
public class ClimbTrajectory : Trajectory
public class ClimbTrajectory : ITrajectory
{
public override RcVec3f Apply(RcVec3f start, RcVec3f end, float u)
public RcVec3f Apply(RcVec3f start, RcVec3f end, float u)
{
return new RcVec3f()
{

View File

@ -7,13 +7,13 @@ namespace DotRecast.Detour.Extras.Jumplink
{
public readonly GroundSegment start = new GroundSegment();
public readonly List<GroundSegment> end = new List<GroundSegment>();
public readonly Trajectory trajectory;
public readonly ITrajectory trajectory;
public readonly RcVec3f ax = new RcVec3f();
public readonly RcVec3f ay = new RcVec3f();
public readonly RcVec3f az = new RcVec3f();
public EdgeSampler(JumpEdge edge, Trajectory trajectory)
public EdgeSampler(JumpEdge edge, ITrajectory trajectory)
{
this.trajectory = trajectory;
ax = RcVec3f.Subtract(edge.sq, edge.sp);

View File

@ -4,7 +4,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{
public class GroundSample
{
public RcVec3f p = new RcVec3f();
public RcVec3f p;
public bool validTrajectory;
public bool validHeight;
}

View File

@ -4,8 +4,8 @@ namespace DotRecast.Detour.Extras.Jumplink
{
public class GroundSegment
{
public RcVec3f p = new RcVec3f();
public RcVec3f q = new RcVec3f();
public RcVec3f p;
public RcVec3f q;
public GroundSample[] gsamples;
public float height;
}

View File

@ -0,0 +1,10 @@
using System;
using DotRecast.Core.Numerics;
namespace DotRecast.Detour.Extras.Jumplink
{
public interface ITrajectory
{
public RcVec3f Apply(RcVec3f start, RcVec3f end, float u);
}
}

View File

@ -10,6 +10,6 @@ namespace DotRecast.Detour.Extras.Jumplink
public GroundSample[] endSamples;
public GroundSegment start;
public GroundSegment end;
public Trajectory trajectory;
public ITrajectory trajectory;
}
}

View File

@ -4,7 +4,7 @@ using DotRecast.Core.Numerics;
namespace DotRecast.Detour.Extras.Jumplink
{
public class JumpTrajectory : Trajectory
public class JumpTrajectory : ITrajectory
{
private readonly float jumpHeight;
@ -13,7 +13,7 @@ namespace DotRecast.Detour.Extras.Jumplink
this.jumpHeight = jumpHeight;
}
public override RcVec3f Apply(RcVec3f start, RcVec3f end, float u)
public RcVec3f Apply(RcVec3f start, RcVec3f end, float u)
{
return new RcVec3f
{

View File

@ -1,13 +0,0 @@
using System;
using DotRecast.Core.Numerics;
namespace DotRecast.Detour.Extras.Jumplink
{
public class Trajectory
{
public virtual RcVec3f Apply(RcVec3f start, RcVec3f end, float u)
{
throw new NotImplementedException();
}
}
}

View File

@ -32,7 +32,7 @@ namespace DotRecast.Detour.Extras.Jumplink
}
}
private bool SampleTrajectory(JumpLinkBuilderConfig acfg, RcHeightfield solid, RcVec3f pa, RcVec3f pb, Trajectory tra)
private bool SampleTrajectory(JumpLinkBuilderConfig acfg, RcHeightfield solid, RcVec3f pa, RcVec3f pb, ITrajectory tra)
{
float cs = Math.Min(acfg.cellSize, acfg.cellHeight);
float d = RcVecUtils.Dist2D(pa, pb) + MathF.Abs(pa.Y - pb.Y);

View File

@ -417,7 +417,7 @@ public class JumpLinkBuilderSampleTool : ISampleTool
}
private void DrawTrajectory(RecastDebugDraw dd, JumpLink link, RcVec3f pa, RcVec3f pb, Trajectory tra, int cola)
private void DrawTrajectory(RecastDebugDraw dd, JumpLink link, RcVec3f pa, RcVec3f pb, ITrajectory tra, int cola)
{
}