diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f0176e..c20195b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` to `Span` for enhanced memory efficiency - Changed `DtWriter` to a static class and renamed it to `RcIO` +- Changed class `Trajectory` to interface `ITrajectory` ### Removed - Nothing diff --git a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs index a8abd77..978d6ef 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs @@ -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() { diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs index 7810533..0daa7f6 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs @@ -20,7 +20,7 @@ namespace DotRecast.Detour.Extras.Jumplink { if (i > 41 || i < 41) { - // continue; + // continue; } int nvp = mesh.nvp; @@ -29,7 +29,7 @@ namespace DotRecast.Detour.Extras.Jumplink { if (j != 1) { - // continue; + // continue; } if (mesh.polys[p + j] == RC_MESH_NULL_IDX) diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs index 9a5a468..044ab83 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs @@ -7,13 +7,13 @@ namespace DotRecast.Detour.Extras.Jumplink { public readonly GroundSegment start = new GroundSegment(); public readonly List end = new List(); - 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); diff --git a/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs b/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs index 41cffc1..3c22759 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs @@ -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; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs b/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs index 1268bba..dbc8f1a 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs @@ -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; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/ITrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/ITrajectory.cs new file mode 100644 index 0000000..dfd04a5 --- /dev/null +++ b/src/DotRecast.Detour.Extras/Jumplink/ITrajectory.cs @@ -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); + } +} \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpLink.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpLink.cs index 4f02b83..9482b01 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpLink.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLink.cs @@ -10,6 +10,6 @@ namespace DotRecast.Detour.Extras.Jumplink public GroundSample[] endSamples; public GroundSegment start; public GroundSegment end; - public Trajectory trajectory; + public ITrajectory trajectory; } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs index 080eff3..663b558 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs @@ -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 { diff --git a/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs deleted file mode 100644 index e51802c..0000000 --- a/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs +++ /dev/null @@ -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(); - } - } -} \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs index a2ec1f1..7d3dcad 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs @@ -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); diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderSampleTool.cs index 4b31c47..db2fc07 100644 --- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderSampleTool.cs @@ -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) { }