aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Maps/MapTree.cpp
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-06-19 17:26:12 +0200
committerMachiavelli <none@none>2010-06-19 17:26:12 +0200
commit8c8986b2bc7a5dee3c12252486ad68a40a482ee0 (patch)
tree0ffb64f293b409a10f898830515e3ee6e3dbe0a1 /src/server/collision/Maps/MapTree.cpp
parent706c0568a5a7261bbc1839d771bd885a5842a116 (diff)
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
Diffstat (limited to 'src/server/collision/Maps/MapTree.cpp')
-rw-r--r--src/server/collision/Maps/MapTree.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp
index c733ed37454..af4073fcc8c 100644
--- a/src/server/collision/Maps/MapTree.cpp
+++ b/src/server/collision/Maps/MapTree.cpp
@@ -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;
}