mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Fix usage of uninitialized waypoint array variables in ConfusedMovementGenerator<T>::Initialize and revert 9b1c565510+ad8ce5245e that covered up this problem without fixing it and introduced a faulty LOS calculation.
With thanks to Lynx3d and click, and Aokromes and ritchy for testing. --HG-- branch : trunk
This commit is contained in:
@@ -146,32 +146,19 @@ namespace VMAP
|
||||
|
||||
bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const
|
||||
{
|
||||
bool result = false;
|
||||
bool result = true;
|
||||
float maxDist = (pos2 - pos1).magnitude();
|
||||
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too
|
||||
|
||||
//ASSERT(maxDist < std::numeric_limits<float>::max());
|
||||
|
||||
ASSERT(maxDist < std::numeric_limits<float>::max());
|
||||
// prevent NaN values which can cause BIH intersection to enter infinite loop
|
||||
if (maxDist < 1e-10f)
|
||||
return true;
|
||||
// direction with length of 1
|
||||
G3D::Plane checkPlane = G3D::Plane((pos2 - pos1)/maxDist,pos1, pos2);
|
||||
G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist);
|
||||
|
||||
Vector3 checkFinite = ray.intersection(checkPlane);
|
||||
if (!checkFinite.isFinite())
|
||||
float resultDist = getIntersectionTime(ray, maxDist, true);
|
||||
if (resultDist < maxDist)
|
||||
{
|
||||
ray = G3D::Ray::fromOriginAndDirection(pos1, -((pos2 - pos1)/maxDist));
|
||||
checkFinite = ray.intersection(checkPlane);
|
||||
}
|
||||
if (checkFinite.isFinite())
|
||||
{
|
||||
float resultDist = getIntersectionTime(ray, maxDist, true);
|
||||
if (resultDist >= maxDist)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user