1
0
Fork 0

Many NavDisplay bug-fixes - almost usable now!

This commit is contained in:
James Turner 2011-10-24 23:55:46 +01:00
parent 9bd4ba6eb0
commit 34f86cd317

View file

@ -172,11 +172,20 @@ public:
} }
} // of matches parsing } // of matches parsing
xy0.x() = node->getFloatValue("x0", -5); if (node->hasChild("width")) {
xy0.y() = node->getFloatValue("y0", -5); float w = node->getFloatValue("width");
float h = node->getFloatValue("height", w);
xy0.x() = -w * 0.5;
xy0.y() = -h * 0.5;
xy1.x() = w * 0.5;
xy1.y() = h * 0.5;
} else {
xy0.x() = node->getFloatValue("x0", 0.0);
xy0.y() = node->getFloatValue("y0", 0.0);
xy1.x() = node->getFloatValue("x1", 5); xy1.x() = node->getFloatValue("x1", 5);
xy1.y() = node->getFloatValue("y1", 5); xy1.y() = node->getFloatValue("y1", 5);
}
double texSize = node->getFloatValue("texture-size", 1.0); double texSize = node->getFloatValue("texture-size", 1.0);
uv0.x() = node->getFloatValue("u0", 0) / texSize; uv0.x() = node->getFloatValue("u0", 0) / texSize;
@ -201,7 +210,7 @@ public:
drawLine = node->getBoolValue("draw-line", false); drawLine = node->getBoolValue("draw-line", false);
lineColor = readColor(node->getChild("line-color"), color); lineColor = readColor(node->getChild("line-color"), color);
drawRouteLeg = node->getBoolValue("draw-line", false); drawRouteLeg = node->getBoolValue("draw-leg", false);
stretchSymbol = node->getBoolValue("stretch-symbol", false); stretchSymbol = node->getBoolValue("stretch-symbol", false);
if (stretchSymbol) { if (stretchSymbol) {
@ -250,21 +259,19 @@ public:
bool matches(const string_set& states) const bool matches(const string_set& states) const
{ {
string_set::const_iterator it = states.begin(), BOOST_FOREACH(const string& s, required_states) {
end = states.end(); if (states.count(s) == 0) {
for (; it != end; ++it) {
if (!required_states.empty() && (required_states.count(*it) == 0)) {
// required state not matched
return false; return false;
} }
}
if (excluded_states.count(*it) > 0) {
// excluded state matched BOOST_FOREACH(const string& s, excluded_states) {
if (states.count(s) != 0) {
return false; return false;
} }
} // of applicable states iteration }
return true; // matches! return true;
} }
}; };
@ -287,14 +294,12 @@ public:
string text() const string text() const
{ {
assert(definition->hasText); assert(definition->hasText);
string r; string r;
size_t lastPos = 0;
size_t pos = 0; while (true) {
int lastPos = 0; size_t pos = definition->textTemplate.find('{', lastPos);
if (pos == string::npos) { // no more replacements
for (; pos < definition->textTemplate.size();) {
pos = definition->textTemplate.find('{', pos);
if (pos == string::npos) { // no more replacements
r.append(definition->textTemplate.substr(lastPos)); r.append(definition->textTemplate.substr(lastPos));
break; break;
} }
@ -309,7 +314,7 @@ public:
string spec = definition->textTemplate.substr(pos + 1, endReplacement - (pos + 1)); string spec = definition->textTemplate.substr(pos + 1, endReplacement - (pos + 1));
// look for formatter in spec // look for formatter in spec
size_t colonPos = spec.find(':'); size_t colonPos = spec.find(':');
if (colonPos == string::npos) { if (colonPos == string::npos) {
// simple replacement // simple replacement
r.append(props->getStringValue(spec)); r.append(props->getStringValue(spec));
} else { } else {
@ -386,7 +391,10 @@ NavDisplay::init ()
string path = _Instrument->getStringValue("symbol-texture-path", string path = _Instrument->getStringValue("symbol-texture-path",
"Aircraft/Instruments/Textures/nd-symbols.png"); "Aircraft/Instruments/Textures/nd-symbols.png");
SGPath tpath = globals->resolve_aircraft_path(path); SGPath tpath = globals->resolve_aircraft_path(path);
if (!tpath.exists()) {
SG_LOG(SG_INSTR, SG_WARN, "ND symbol texture not found:" << path);
}
// no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect // no mipmap or else alpha will mix with pixels on the border of shapes, ruining the effect
_symbolTexture = SGLoadTexture2D(tpath, NULL, false, false); _symbolTexture = SGLoadTexture2D(tpath, NULL, false, false);
@ -427,6 +435,7 @@ NavDisplay::init ()
_geom->setTexCoordArray(0, _texCoords); _geom->setTexCoordArray(0, _texCoords);
_quadColors = new osg::Vec4Array; _quadColors = new osg::Vec4Array;
_quadColors->setDataVariance(osg::Object::DYNAMIC);
_geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); _geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
_geom->setColorArray(_quadColors); _geom->setColorArray(_quadColors);
@ -436,6 +445,7 @@ NavDisplay::init ()
_geom->setInitialBound(osg::BoundingBox(osg::Vec3f(-256.0f, -256.0f, 0.0f), _geom->setInitialBound(osg::BoundingBox(osg::Vec3f(-256.0f, -256.0f, 0.0f),
osg::Vec3f(256.0f, 256.0f, 0.0f))); osg::Vec3f(256.0f, 256.0f, 0.0f)));
_radarGeode->addDrawable(_geom); _radarGeode->addDrawable(_geom);
_odg->allocRT(); _odg->allocRT();
// Texture in the 2D panel system // Texture in the 2D panel system
@ -524,6 +534,7 @@ NavDisplay::update (double delta_time_sec)
_vertices->clear(); _vertices->clear();
_lineVertices->clear(); _lineVertices->clear();
_lineColors->clear(); _lineColors->clear();
_quadColors->clear();
_texCoords->clear(); _texCoords->clear();
_textGeode->removeDrawables(0, _textGeode->getNumDrawables()); _textGeode->removeDrawables(0, _textGeode->getNumDrawables());
@ -609,7 +620,7 @@ void NavDisplay::addSymbolToScene(SymbolInstance* sym)
_texCoords->push_back(osg::Vec2(def->uv1.x(), def->uv0.y())); _texCoords->push_back(osg::Vec2(def->uv1.x(), def->uv0.y()));
_texCoords->push_back(def->uv1); _texCoords->push_back(def->uv1);
_texCoords->push_back(osg::Vec2(def->uv0.x(), def->uv1.y())); _texCoords->push_back(osg::Vec2(def->uv0.x(), def->uv1.y()));
for (int i=0; i<4; ++i) { for (int i=0; i<4; ++i) {
_vertices->push_back(verts[i] + pos); _vertices->push_back(verts[i] + pos);
_quadColors->push_back(def->color); _quadColors->push_back(def->color);
@ -743,6 +754,8 @@ osg::Vec2 NavDisplay::projectGeod(const SGGeod& geod) const
class Filter : public FGPositioned::Filter class Filter : public FGPositioned::Filter
{ {
public: public:
double minRunwayLengthFt;
virtual bool pass(FGPositioned* aPos) const virtual bool pass(FGPositioned* aPos) const
{ {
if (aPos->type() == FGPositioned::FIX) { if (aPos->type() == FGPositioned::FIX) {
@ -753,6 +766,13 @@ public:
} }
} }
if (aPos->type() == FGPositioned::AIRPORT) {
FGAirport* apt = (FGAirport*) aPos;
if (!apt->hasHardRunwayOfLengthFt(minRunwayLengthFt)) {
return false;
}
}
return true; return true;
} }
@ -768,6 +788,8 @@ public:
void NavDisplay::findItems() void NavDisplay::findItems()
{ {
Filter filt; Filter filt;
filt.minRunwayLengthFt = 2000;
FGPositioned::List items = FGPositioned::List items =
FGPositioned::findWithinRange(_pos, _rangeNm, &filt); FGPositioned::findWithinRange(_pos, _rangeNm, &filt);
@ -950,7 +972,8 @@ void NavDisplay::computePositionedPropsAndHeading(FGPositioned* pos, SGPropertyN
switch (pos->type()) { switch (pos->type()) {
case FGPositioned::VOR: case FGPositioned::VOR:
case FGPositioned::LOC: { case FGPositioned::LOC:
case FGPositioned::TACAN: {
FGNavRecord* nav = static_cast<FGNavRecord*>(pos); FGNavRecord* nav = static_cast<FGNavRecord*>(pos);
nd->setDoubleValue("frequency-mhz", nav->get_freq()); nd->setDoubleValue("frequency-mhz", nav->get_freq());