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;
|
ss2 >> map_num;
|
||||||
if (map_num >= 0)
|
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;
|
iIgnoreMapIds[map_num] = true;
|
||||||
// unload map in case it is loaded
|
// unload map in case it is loaded
|
||||||
unloadMap(map_num);
|
unloadMap(map_num);
|
||||||
@@ -299,11 +299,11 @@ namespace VMAP
|
|||||||
WorldModel *worldmodel = new WorldModel();
|
WorldModel *worldmodel = new WorldModel();
|
||||||
if (!worldmodel->readFile(basepath + filename + ".vmo"))
|
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;
|
delete worldmodel;
|
||||||
return NULL;
|
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 = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first;
|
||||||
model->second.setModel(worldmodel);
|
model->second.setModel(worldmodel);
|
||||||
}
|
}
|
||||||
@@ -316,12 +316,12 @@ namespace VMAP
|
|||||||
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
|
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
|
||||||
if (model == iLoadedModelFiles.end())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if( model->second.decRefCount() == 0)
|
if( model->second.decRefCount() == 0)
|
||||||
{
|
{
|
||||||
std::cout << "VMapManager2: unloading file '" << filename << "'.\n";
|
sLog.outDebug("VMapManager2: unloading file '%s'", filename);
|
||||||
delete model->second.getModel();
|
delete model->second.getModel();
|
||||||
iLoadedModelFiles.erase(model);
|
iLoadedModelFiles.erase(model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,32 +146,19 @@ namespace VMAP
|
|||||||
|
|
||||||
bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const
|
bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = true;
|
||||||
float maxDist = (pos2 - pos1).magnitude();
|
float maxDist = (pos2 - pos1).magnitude();
|
||||||
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too
|
// 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
|
// prevent NaN values which can cause BIH intersection to enter infinite loop
|
||||||
if (maxDist < 1e-10f)
|
if (maxDist < 1e-10f)
|
||||||
return true;
|
return true;
|
||||||
// direction with length of 1
|
// 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);
|
G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist);
|
||||||
|
float resultDist = getIntersectionTime(ray, maxDist, true);
|
||||||
Vector3 checkFinite = ray.intersection(checkPlane);
|
if (resultDist < maxDist)
|
||||||
if (!checkFinite.isFinite())
|
|
||||||
{
|
{
|
||||||
ray = G3D::Ray::fromOriginAndDirection(pos1, -((pos2 - pos1)/maxDist));
|
result = false;
|
||||||
checkFinite = ray.intersection(checkPlane);
|
|
||||||
}
|
|
||||||
if (checkFinite.isFinite())
|
|
||||||
{
|
|
||||||
float resultDist = getIntersectionTime(ray, maxDist, true);
|
|
||||||
if (resultDist >= maxDist)
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "Dynamic/UnorderedMap.h"
|
#include "Dynamic/UnorderedMap.h"
|
||||||
#include "BoundingIntervalHierarchy.h"
|
#include "BoundingIntervalHierarchy.h"
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
namespace VMAP
|
namespace VMAP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,15 +51,13 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
|
|||||||
|
|
||||||
for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
|
for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
|
||||||
{
|
{
|
||||||
|
const float wanderX = wander_distance*rand_norm() - wander_distance/2;
|
||||||
|
const float wanderY = wander_distance*rand_norm() - wander_distance/2;
|
||||||
|
i_waypoints[idx][0] = x + wanderX;
|
||||||
|
i_waypoints[idx][1] = y + wanderY;
|
||||||
|
|
||||||
const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f);
|
const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f);
|
||||||
if (isInLoS)
|
if (!isInLoS)
|
||||||
{
|
|
||||||
const float wanderX = wander_distance*rand_norm() - wander_distance/2;
|
|
||||||
const float wanderY = wander_distance*rand_norm() - wander_distance/2;
|
|
||||||
i_waypoints[idx][0] = x + wanderX;
|
|
||||||
i_waypoints[idx][1] = y + wanderY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
i_waypoints[idx][0] = x;
|
i_waypoints[idx][0] = x;
|
||||||
i_waypoints[idx][1] = y;
|
i_waypoints[idx][1] = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user