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:
@@ -109,7 +109,7 @@ namespace VMAP
|
||||
ss2 >> map_num;
|
||||
if (map_num >= 0)
|
||||
{
|
||||
std::cout << "ingoring Map " << map_num << " for VMaps\n";
|
||||
sLog.outDebug("Ignoring Map %i for VMaps", map_num);
|
||||
iIgnoreMapIds[map_num] = true;
|
||||
// unload map in case it is loaded
|
||||
unloadMap(map_num);
|
||||
@@ -299,11 +299,11 @@ namespace VMAP
|
||||
WorldModel *worldmodel = new WorldModel();
|
||||
if (!worldmodel->readFile(basepath + filename + ".vmo"))
|
||||
{
|
||||
std::cout << "VMapManager2: could not load '" << basepath << filename << ".vmo'!\n";
|
||||
sLog.outError("VMapManager2: could not load '%s%s.vmo'!", basepath, filename);
|
||||
delete worldmodel;
|
||||
return NULL;
|
||||
}
|
||||
std::cout << "VMapManager2: loading file '" << basepath << filename << "'.\n";
|
||||
sLog.outDebug("VMapManager2: loading file '%s%s'.", basepath, filename);
|
||||
model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first;
|
||||
model->second.setModel(worldmodel);
|
||||
}
|
||||
@@ -316,12 +316,12 @@ namespace VMAP
|
||||
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
|
||||
if (model == iLoadedModelFiles.end())
|
||||
{
|
||||
std::cout << "VMapManager2: trying to unload non-loaded file '" << filename << "'!\n";
|
||||
sLog.outError("VMapManager2: trying to unload non-loaded file '%s'!", filename);
|
||||
return;
|
||||
}
|
||||
if( model->second.decRefCount() == 0)
|
||||
{
|
||||
std::cout << "VMapManager2: unloading file '" << filename << "'.\n";
|
||||
sLog.outDebug("VMapManager2: unloading file '%s'", filename);
|
||||
delete model->second.getModel();
|
||||
iLoadedModelFiles.erase(model);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Define.h"
|
||||
#include "Dynamic/UnorderedMap.h"
|
||||
#include "BoundingIntervalHierarchy.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace VMAP
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user