Core/Movement: Properly calculate the first Catmull-Rom spline point
Port From (https://github.com/TrinityCore/TrinityCore/commit/5db7d25700c12b15c7effa313814e5d874c95419)
This commit is contained in:
@@ -81,11 +81,11 @@ namespace Game.Movement
|
||||
Spline.EvaluationMode[] modes = new Spline.EvaluationMode[2] { Spline.EvaluationMode.Linear, Spline.EvaluationMode.Catmullrom };
|
||||
if (args.flags.HasFlag(SplineFlag.Cyclic))
|
||||
{
|
||||
spline.InitCyclicSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], 0);
|
||||
spline.InitCyclicSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], 0, args.initialOrientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
spline.InitSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())]);
|
||||
spline.InitSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], args.initialOrientation);
|
||||
}
|
||||
|
||||
// init spline timestamps
|
||||
|
||||
@@ -79,17 +79,18 @@ namespace Game.Movement
|
||||
{
|
||||
initializer.Initialize(ref m_mode, ref _cyclic, ref points, ref index_lo, ref index_hi);
|
||||
}
|
||||
public void InitCyclicSpline(Vector3[] controls, int count, EvaluationMode m, int cyclic_point)
|
||||
public void InitCyclicSpline(Vector3[] controls, int count, EvaluationMode m, int cyclic_point, float orientation)
|
||||
{
|
||||
m_mode = m;
|
||||
_cyclic = true;
|
||||
|
||||
InitSpline(controls, count, m);
|
||||
InitSpline(controls, count, m, orientation);
|
||||
}
|
||||
public void InitSpline(Span<Vector3> controls, int count, EvaluationMode m)
|
||||
public void InitSpline(Span<Vector3> controls, int count, EvaluationMode m, float orientation = 0)
|
||||
{
|
||||
m_mode = m;
|
||||
_cyclic = false;
|
||||
initialOrientation = orientation;
|
||||
|
||||
switch (m_mode)
|
||||
{
|
||||
@@ -139,14 +140,14 @@ namespace Game.Movement
|
||||
if (cyclic_point == 0)
|
||||
points[0] = controls[count - 1];
|
||||
else
|
||||
points[0] = Vector3.Lerp(controls[0], controls[1], -1);
|
||||
points[0] = controls[0] - new Vector3(MathF.Cos(initialOrientation), MathF.Sin(initialOrientation), 0.0f);
|
||||
|
||||
points[high_index + 1] = controls[cyclic_point];
|
||||
points[high_index + 2] = controls[cyclic_point + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
points[0] = Vector3.Lerp(controls[0], controls[1], -1);
|
||||
points[0] = controls[0] - new Vector3(MathF.Cos(initialOrientation), MathF.Sin(initialOrientation), 0.0f);
|
||||
points[high_index + 1] = controls[count - 1];
|
||||
}
|
||||
|
||||
@@ -360,6 +361,7 @@ namespace Game.Movement
|
||||
Vector3[] points = Array.Empty<Vector3>();
|
||||
public EvaluationMode m_mode;
|
||||
bool _cyclic;
|
||||
float initialOrientation;
|
||||
int index_lo;
|
||||
int index_hi;
|
||||
public enum EvaluationMode
|
||||
|
||||
Reference in New Issue
Block a user