fix(Core/Movement): correct weird pathing by clearing old path (#7034)

- Closes #5220.
This commit is contained in:
UltraNix
2021-07-24 16:26:18 +02:00
committed by GitHub
parent 6d1062f46f
commit 59c8f7276e
2 changed files with 8 additions and 6 deletions

View File

@@ -111,6 +111,12 @@ class PathGenerator
return len;
}
void Clear()
{
_polyLength = 0;
_pathPoints.clear();
}
private:
dtPolyRef _pathPolyRefs[MAX_PATH_LENGTH]; // array of detour polygon references
uint32 _polyLength; // number of polygons in the path
@@ -139,12 +145,6 @@ class PathGenerator
void SetActualEndPosition(G3D::Vector3 const& point) { _actualEndPosition = point; }
void NormalizePath();
void Clear()
{
_polyLength = 0;
_pathPoints.clear();
}
bool InRange(G3D::Vector3 const& p1, G3D::Vector3 const& p2, float r, float h) const;
float Dist3DSqr(G3D::Vector3 const& p1, G3D::Vector3 const& p2) const;
bool InRangeYZX(float const* v1, float const* v2, float r, float h) const;

View File

@@ -131,6 +131,8 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
if (!i_path || moveToward != _movingTowards)
i_path = std::make_unique<PathGenerator>(owner);
else
i_path->Clear();
float x, y, z;
bool shortenPath;