1
0
Fork 0

Fix bug 905.

When a position is modified for an in-cache FGPositioned, we need to update the runtime information too, or the Octree code may (rightly) complain that it's seeing inconsistent data. Also make the Octree check an exception throw, and verbose, so this is easier to detect in the future.
This commit is contained in:
James Turner 2012-11-10 14:48:00 +00:00
parent b7e79c1231
commit 08d82294bd
4 changed files with 27 additions and 4 deletions

View file

@ -40,8 +40,10 @@ double FGTaxiNode::getElevationFt()
double elevationEnd = -100;
if (local_scenery->get_elevation_m( center2, elevationEnd, NULL )) {
mPosition.setElevationM(elevationEnd);
NavDataCache::instance()->updatePosition(guid(), mPosition);
SGGeod newPos = mPosition;
newPos.setElevationM(elevationEnd);
// this will call modifyPosition to update mPosition
NavDataCache::instance()->updatePosition(guid(), newPos);
}
}

View file

@ -1337,6 +1337,11 @@ PositionedID NavDataCache::insertAirport(FGPositioned::Type ty, const string& id
void NavDataCache::updatePosition(PositionedID item, const SGGeod &pos)
{
if (d->cache.find(item) != d->cache.end()) {
SG_LOG(SG_GENERAL, SG_DEBUG, "updating position of an item in the cache");
d->cache[item]->modifyPosition(pos);
}
SGVec3d cartPos(SGVec3d::fromGeod(pos));
d->reset(d->setAirportPos);

View file

@ -36,6 +36,7 @@
#include <boost/foreach.hpp>
#include <simgear/debug/logstream.hxx>
#include <simgear/structure/exception.hxx>
namespace flightgear
{
@ -66,7 +67,22 @@ void Leaf::visit(const SGVec3d& aPos, double aCutoff,
for (; it != end; ++it) {
FGPositioned* p = cache->loadById(it->second);
assert(intersects(_box, p->cart()));
if (!intersects(_box, p->cart())) {
// see http://code.google.com/p/flightgear-bugs/issues/detail?id=905
SG_LOG(SG_GENERAL, SG_WARN, "XXXXXXXXX bad spatial index for " << it->second
<< "; " << p->ident() << " of type " <<
FGPositioned::nameForType(p->type()));
SG_LOG(SG_GENERAL, SG_WARN, "\tgeodetic location:" << p->geod());
SG_LOG(SG_GENERAL, SG_WARN, "\tcartesian location:" << p->cart());
SG_LOG(SG_GENERAL, SG_WARN, "leaf box:" <<
_box.getMin() << " x " << _box.getMax());
throw sg_exception("Bad spatial index data");
}
double d = dist(aPos, p->cart());
if (d > aCutoff) {
continue;

View file

@ -229,7 +229,7 @@ protected:
void modifyPosition(const SGGeod& newPos);
const PositionedID mGuid;
SGGeod mPosition;
const SGGeod mPosition;
const SGVec3d mCart;
const Type mType;
const std::string mIdent;