1
0
Fork 0

Merge branch 'next' of git://gitorious.org/fg/flightgear into next

This commit is contained in:
Frederic Bouvier 2011-11-11 14:05:39 +01:00
commit 03db1bfdc5
6 changed files with 80 additions and 29 deletions

View file

@ -3,11 +3,7 @@
You *must* have OpenSceneGraph (OSG) installed to build this version of You *must* have OpenSceneGraph (OSG) installed to build this version of
FlightGear. FlightGear.
Notice that from FlightGear version 1.9.0, OSG version 2.7.8 or later Notice that FlightGear 2.6.0 requires at least version 3.0.0.
is required. Using earlier versions of OSG will yield serious
rendering bugs. If you are using an 'older' distribution, this may mean
a suitable version of OSG may not be availble through the usual package
repositories.
You can get the latest version of OSG from: You can get the latest version of OSG from:

View file

@ -267,7 +267,7 @@ bool FGAIBase::init(bool search_in_AI_path) {
else else
_installed = true; _installed = true;
osg::Node * mdl = SGModelLib::loadPagedModel(f, props, new FGNasalModelData(props)); osg::Node * mdl = SGModelLib::loadDeferredModel(f, props, new FGNasalModelData(props));
if (_model.valid()) if (_model.valid())
{ {

View file

@ -374,7 +374,7 @@ int MapData::_fontDescender = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
const int MAX_ZOOM = 16; const int MAX_ZOOM = 12;
const int SHOW_DETAIL_ZOOM = 8; const int SHOW_DETAIL_ZOOM = 8;
const int CURSOR_PAN_STEP = 32; const int CURSOR_PAN_STEP = 32;
@ -403,11 +403,13 @@ MapWidget::~MapWidget()
void MapWidget::setProperty(SGPropertyNode_ptr prop) void MapWidget::setProperty(SGPropertyNode_ptr prop)
{ {
_root = prop; _root = prop;
int zoom = _root->getBoolValue("zoom", -1); int zoom = _root->getIntValue("zoom", -1);
if (zoom < 0) { if (zoom < 0) {
_root->setIntValue("zoom", 6); // default zoom _root->setIntValue("zoom", 6); // default zoom
} }
// expose MAX_ZOOM to the UI
_root->setIntValue("max-zoom", MAX_ZOOM);
_root->setBoolValue("centre-on-aircraft", true); _root->setBoolValue("centre-on-aircraft", true);
_root->setBoolValue("draw-data", false); _root->setBoolValue("draw-data", false);
_root->setBoolValue("magnetic-headings", true); _root->setBoolValue("magnetic-headings", true);
@ -515,15 +517,6 @@ int MapWidget::zoom() const
} }
void MapWidget::zoomIn() void MapWidget::zoomIn()
{
if (zoom() <= 0) {
return;
}
_root->setIntValue("zoom", zoom() - 1);
}
void MapWidget::zoomOut()
{ {
if (zoom() >= MAX_ZOOM) { if (zoom() >= MAX_ZOOM) {
return; return;
@ -532,6 +525,15 @@ void MapWidget::zoomOut()
_root->setIntValue("zoom", zoom() + 1); _root->setIntValue("zoom", zoom() + 1);
} }
void MapWidget::zoomOut()
{
if (zoom() <= 0) {
return;
}
_root->setIntValue("zoom", zoom() - 1);
}
void MapWidget::draw(int dx, int dy) void MapWidget::draw(int dx, int dy)
{ {
_aircraft = SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"), _aircraft = SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
@ -561,7 +563,7 @@ void MapWidget::draw(int dx, int dy)
_upHeading = 0.0; _upHeading = 0.0;
} }
_cachedZoom = zoom(); _cachedZoom = MAX_ZOOM - zoom();
SGGeod topLeft = unproject(SGVec2d(_width/2, _height/2)); SGGeod topLeft = unproject(SGVec2d(_width/2, _height/2));
// compute draw range, including a fudge factor for ILSs and other 'long' // compute draw range, including a fudge factor for ILSs and other 'long'
// symbols // symbols

View file

@ -1560,6 +1560,10 @@ public:
{ {
OptionValueVec::const_iterator it = values.begin(); OptionValueVec::const_iterator it = values.begin();
for (; it != values.end(); ++it) { for (; it != values.end(); ++it) {
if (!it->desc) {
continue; // ignore markers
}
if (it->desc->option == key) { if (it->desc->option == key) {
return it; return it;
} }
@ -1580,6 +1584,10 @@ public:
int processOption(OptionDesc* desc, const string& arg_value) int processOption(OptionDesc* desc, const string& arg_value)
{ {
if (!desc) {
return FG_OPTIONS_OK; // tolerate marker options
}
switch ( desc->type & 0xffff ) { switch ( desc->type & 0xffff ) {
case OPTION_BOOL: case OPTION_BOOL:
fgSetBool( desc->property, desc->b_param ); fgSetBool( desc->property, desc->b_param );
@ -1647,10 +1655,36 @@ public:
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
/**
* insert a marker value into the values vector. This is necessary
* when processing options, to ensure the correct ordering, where we scan
* for marker values in reverse, and then forwards within each group.
*/
void insertGroupMarker()
{
values.push_back(OptionValue(NULL, "-"));
}
/**
* given a current iterator into the values, find the preceeding group marker,
* or return the beginning of the value vector.
*/
OptionValueVec::const_iterator rfindGroup(OptionValueVec::const_iterator pos) const
{
while (--pos != values.begin()) {
if (pos->desc == NULL) {
return pos; // found a marker, we're done
}
}
return pos;
}
bool showHelp, bool showHelp,
verbose, verbose,
showAircraft; showAircraft;
OptionDescDict options; OptionDescDict options;
OptionValueVec values; OptionValueVec values;
simgear::PathList propertyFiles; simgear::PathList propertyFiles;
@ -1710,6 +1744,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
p->propertyFiles.push_back(f); p->propertyFiles.push_back(f);
} }
} // of arguments iteration } // of arguments iteration
p->insertGroupMarker(); // command line is one group
// then config files // then config files
SGPath config; SGPath config;
@ -1850,6 +1885,7 @@ void Options::readConfig(const SGPath& path)
in >> skipcomment; in >> skipcomment;
} }
p->insertGroupMarker(); // each config file is a group
} }
int Options::parseOption(const string& s) int Options::parseOption(const string& s)
@ -1898,6 +1934,7 @@ int Options::addOption(const string &key, const string &value)
{ {
OptionDesc* desc = p->findOption(key); OptionDesc* desc = p->findOption(key);
if (!desc) { if (!desc) {
SG_LOG(SG_GENERAL, SG_ALERT, "unknown option:" << key);
return FG_OPTIONS_ERROR; return FG_OPTIONS_ERROR;
} }
@ -1934,6 +1971,10 @@ string_list Options::valuesForOption(const std::string& key) const
string_list result; string_list result;
OptionValueVec::const_iterator it = p->values.begin(); OptionValueVec::const_iterator it = p->values.begin();
for (; it != p->values.end(); ++it) { for (; it != p->values.end(); ++it) {
if (!it->desc) {
continue; // ignore marker values
}
if (it->desc->option == key) { if (it->desc->option == key) {
result.push_back(it->value); result.push_back(it->value);
} }
@ -1951,17 +1992,28 @@ void Options::processOptions()
exit(0); exit(0);
} }
// proces options in LIFO order, so earlier (first in) options are processed // processing order is complicated. We must process groups LIFO, but the
// after, and hence override, later specified options. // values *within* each group in FIFO order, to retain consistency with
OptionValueVec::const_reverse_iterator it = p->values.rbegin(); // older versions of FG, and existing user configs.
for (; it != p->values.rend(); ++it) { // in practice this means system.fgfsrc must be *processed* before
int result = p->processOption(it->desc, it->value); // .fgfsrc, which must be processed before the command line args, and so on.
if (result == FG_OPTIONS_ERROR) { OptionValueVec::const_iterator groupEnd = p->values.end();
showUsage();
exit(-1); while (groupEnd != p->values.begin()) {
OptionValueVec::const_iterator groupBegin = p->rfindGroup(groupEnd);
// run over the group in FIFO order
OptionValueVec::const_iterator it;
for (it = groupBegin; it != groupEnd; ++it) {
int result = p->processOption(it->desc, it->value);
if (result == FG_OPTIONS_ERROR) {
showUsage();
exit(-1);
}
} }
groupEnd = groupBegin;
} }
BOOST_FOREACH(const SGPath& file, p->propertyFiles) { BOOST_FOREACH(const SGPath& file, p->propertyFiles) {
if (!file.exists()) { if (!file.exists()) {
SG_LOG(SG_GENERAL, SG_ALERT, "config file not found:" << file.str()); SG_LOG(SG_GENERAL, SG_ALERT, "config file not found:" << file.str());

View file

@ -276,7 +276,7 @@ FGTileMgr::loadTileModel(const string& modelPath, bool cacheModel)
new FGNasalModelData); new FGNasalModelData);
else else
result= result=
SGModelLib::loadDeferedModel(fullPath.str(), globals->get_props(), SGModelLib::loadDeferredModel(fullPath.str(), globals->get_props(),
new FGNasalModelData); new FGNasalModelData);
} catch (const sg_io_exception& exc) { } catch (const sg_io_exception& exc) {
string m(exc.getMessage()); string m(exc.getMessage());

View file

@ -149,7 +149,8 @@ void FGLight::bind () {
prop->tie("/rendering/scene/overcast",SGRawValuePointer<float>(&_overcast)); prop->tie("/rendering/scene/overcast",SGRawValuePointer<float>(&_overcast));
_sunAngleRad = prop->getNode("/sim/time/sun-angle-rad", true); _sunAngleRad = prop->getNode("/sim/time/sun-angle-rad", true);
_sunAngleRad->setDoubleValue(_sun_angle);
// Read Only // Read Only
prop->tie("/rendering/scene/ambient/red",SGRawValuePointer<float>(&_scene_ambient[0])); prop->tie("/rendering/scene/ambient/red",SGRawValuePointer<float>(&_scene_ambient[0]));
prop->tie("/rendering/scene/ambient/green",SGRawValuePointer<float>(&_scene_ambient[1])); prop->tie("/rendering/scene/ambient/green",SGRawValuePointer<float>(&_scene_ambient[1]));