From 243acb61c8cae76c269c5d83d8d05de17ad1153a Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sat, 25 Jun 2011 09:22:51 +0200 Subject: [PATCH 1/7] Fix issue #354: updateCameras reset viewport size to its initial value on OSG 3.0 --- src/Main/CameraGroup.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index e80e0c564..a185d70dd 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -191,8 +191,10 @@ void CameraGroup::update(const osg::Vec3d& position, for (CameraList::iterator i = _cameras.begin(); i != _cameras.end(); ++i) { const CameraInfo* info = i->get(); const View::Slave& slave = _viewer->getSlave(info->slaveIndex); +#if SG_OSG_VERSION_LESS_THAN(3,0,0) // refreshes camera viewports (for now) updateCameras(info); +#endif Camera* camera = info->camera.get(); Matrix viewMatrix; if ((info->flags & VIEW_ABSOLUTE) != 0) From 523f7f4cb72823be2048f381e867b29b50664b67 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sat, 25 Jun 2011 10:05:38 +0200 Subject: [PATCH 2/7] Trying to fix compilation failure on Linux and Mac --- src/Main/CameraGroup.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Main/CameraGroup.cxx b/src/Main/CameraGroup.cxx index a185d70dd..cb3f07d78 100644 --- a/src/Main/CameraGroup.cxx +++ b/src/Main/CameraGroup.cxx @@ -27,6 +27,7 @@ #include "WindowSystemAdapter.hxx" #include #include +#include #include #include From 029d2b00eb0dd267729bf49f2b5ca6bd80edefe9 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 25 Jun 2011 16:18:07 +0100 Subject: [PATCH 3/7] Tone down some log output for the release, especially related to airways/navaid loading. --- src/Airports/simple.cxx | 2 +- src/MultiPlayer/multiplaymgr.cxx | 2 +- src/Navaids/airways.cxx | 4 ++-- src/Navaids/navdb.cxx | 4 ++-- src/Navaids/navrecord.cxx | 2 +- src/Traffic/SchedFlight.cxx | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Airports/simple.cxx b/src/Airports/simple.cxx index 9df1cb254..7354db28b 100644 --- a/src/Airports/simple.cxx +++ b/src/Airports/simple.cxx @@ -442,7 +442,7 @@ void FGAirport::processThreshold(SGPropertyNode* aThreshold) // first, let's identify the current runway string id(aThreshold->getStringValue("rwy")); if (!hasRunwayWithIdent(id)) { - SG_LOG(SG_GENERAL, SG_WARN, "FGAirport::processThreshold: " + SG_LOG(SG_GENERAL, SG_DEBUG, "FGAirport::processThreshold: " "found runway not defined in the global data:" << ident() << "/" << id); return; } diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index a8f862388..40a9c438a 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -1205,7 +1205,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg, else { // We failed to find the property. We'll try the next packet immediately. - SG_LOG(SG_NETWORK, SG_INFO, "FGMultiplayMgr::ProcessPosMsg - " + SG_LOG(SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::ProcessPosMsg - " "message from " << MsgHdr->Callsign << " has unknown property id " << id); } diff --git a/src/Navaids/airways.cxx b/src/Navaids/airways.cxx index 5bdbb2bee..8313f75b4 100644 --- a/src/Navaids/airways.cxx +++ b/src/Navaids/airways.cxx @@ -197,13 +197,13 @@ void Airway::Network::addEdge(Airway* aWay, const SGGeod& aStartPos, FGPositionedRef end = FGPositioned::findClosestWithIdent(aEndIdent, aEndPos); if (!start) { - SG_LOG(SG_GENERAL, SG_INFO, "unknown airways start pt: '" << aStartIdent << "'"); + SG_LOG(SG_GENERAL, SG_DEBUG, "unknown airways start pt: '" << aStartIdent << "'"); start = FGPositioned::createUserWaypoint(aStartIdent, aStartPos); return; } if (!end) { - SG_LOG(SG_GENERAL, SG_INFO, "unknown airways end pt: '" << aEndIdent << "'"); + SG_LOG(SG_GENERAL, SG_DEBUG, "unknown airways end pt: '" << aEndIdent << "'"); end = FGPositioned::createUserWaypoint(aEndIdent, aEndPos); return; } diff --git a/src/Navaids/navdb.cxx b/src/Navaids/navdb.cxx index 96d38c153..b1a813d61 100644 --- a/src/Navaids/navdb.cxx +++ b/src/Navaids/navdb.cxx @@ -297,12 +297,12 @@ FGRunway* getRunwayFromName(const std::string& aName) const FGAirport* apt = fgFindAirportID(parts[0]); if (!apt) { - SG_LOG(SG_GENERAL, SG_WARN, "navaid " << aName << " associated with bogus airport ID:" << parts[0]); + SG_LOG(SG_GENERAL, SG_DEBUG, "navaid " << aName << " associated with bogus airport ID:" << parts[0]); return NULL; } if (!apt->hasRunwayWithIdent(parts[1])) { - SG_LOG(SG_GENERAL, SG_WARN, "navaid " << aName << " associated with bogus runway ID:" << parts[1]); + SG_LOG(SG_GENERAL, SG_DEBUG, "navaid " << aName << " associated with bogus runway ID:" << parts[1]); return NULL; } diff --git a/src/Navaids/navrecord.cxx b/src/Navaids/navrecord.cxx index 5edc64ef1..8c01c6a10 100644 --- a/src/Navaids/navrecord.cxx +++ b/src/Navaids/navrecord.cxx @@ -61,7 +61,7 @@ FGNavRecord::FGNavRecord(Type aTy, const std::string& aIdent, // assign our own defaults, unless the range is not set for some // reason. if (range < 0.1) { - SG_LOG(SG_GENERAL, SG_WARN, "navaid " << ident() << " has no range set, using defaults"); + SG_LOG(SG_GENERAL, SG_DEBUG, "navaid " << ident() << " has no range set, using defaults"); switch (type()) { case NDB: case VOR: diff --git a/src/Traffic/SchedFlight.cxx b/src/Traffic/SchedFlight.cxx index 5575f6ee0..8b5b6ee68 100644 --- a/src/Traffic/SchedFlight.cxx +++ b/src/Traffic/SchedFlight.cxx @@ -269,13 +269,13 @@ bool FGScheduledFlight::initializeAirports() departurePort = FGAirport::findByIdent(depId); if(departurePort == NULL) { - SG_LOG( SG_GENERAL, SG_WARN, "Traffic manager could not find departure airport : " << depId); + SG_LOG( SG_GENERAL, SG_DEBUG, "Traffic manager could not find departure airport : " << depId); return false; } arrivalPort = FGAirport::findByIdent(arrId); if(arrivalPort == NULL) { - SG_LOG( SG_GENERAL, SG_WARN, "Traffic manager could not find arrival airport : " << arrId); + SG_LOG( SG_GENERAL, SG_DEBUG, "Traffic manager could not find arrival airport : " << arrId); return false; } From c19664291f3a12ab2518978d0b51a8ad52fd53b5 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 25 Jun 2011 20:44:44 +0200 Subject: [PATCH 4/7] #221, #242: Fix/work-around for AI traffic issues Move the disable-HOT feature from the MP aircraft to the a/c base class, disable HOT for all AIaircraft, since that's a fix/work-around for #242: AI aircraft respect the user a/c only when HOT is _disabled_ for them #221: AI aircraft don't stack at parking positions when HOT is disabled Also generally disables HOT for ballistic and other models (suggested by vivian), allowing it for ship/carrier models only. --- src/AIModel/AIAircraft.cxx | 8 ++++++-- src/AIModel/AIBallistic.cxx | 2 +- src/AIModel/AIBase.cxx | 6 +++++- src/AIModel/AIBase.hxx | 2 +- src/AIModel/AIMultiplayer.cxx | 6 +++--- src/AIModel/AIShip.cxx | 3 ++- src/AIModel/AIStatic.cxx | 2 +- src/AIModel/AIStorm.cxx | 4 +++- src/AIModel/AIThermal.cxx | 4 +++- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index d0e319705..1c904b79b 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -52,11 +52,15 @@ using std::string; static string tempReg; -FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : FGAIBase(otAircraft) { +FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : + /* HOT must be disabled for AI Aircraft, + * otherwise traffic detection isn't working as expected.*/ + FGAIBase(otAircraft, false) +{ trafficRef = ref; if (trafficRef) { groundOffset = trafficRef->getGroundOffset(); - setCallSign(trafficRef->getCallSign()); + setCallSign(trafficRef->getCallSign()); } else groundOffset = 0; diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 69e090e3d..74b882821 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -40,7 +40,7 @@ const double FGAIBallistic::slugs_to_kgs = 14.5939029372; const double FGAIBallistic::slugs_to_lbs = 32.1740485564; FGAIBallistic::FGAIBallistic(object_type ot) : -FGAIBase(ot), +FGAIBase(ot, false), _height(0.0), _speed(0), _ht_agl_ft(0.0), diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 33cb073cb..ac907c2e3 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -52,7 +52,7 @@ const double FGAIBase::lbs_to_slugs = 0.031080950172; //conversion factor using namespace simgear; -FGAIBase::FGAIBase(object_type ot) : +FGAIBase::FGAIBase(object_type ot, bool enableHot) : _max_speed(300), _name(""), _parent(""), @@ -121,6 +121,10 @@ FGAIBase::FGAIBase(object_type ot) : p = 1e5; a = 340; Mach = 0; + + // explicitly disable HOT for (most) AI models + if (!enableHot) + aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); } FGAIBase::~FGAIBase() { diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 2f8362331..61351adbb 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -52,7 +52,7 @@ public: otEscort, otMultiplayer, MAX_OBJECTS }; // Needs to be last!!! - FGAIBase(object_type ot); + FGAIBase(object_type ot, bool enableHot); virtual ~FGAIBase(); virtual void readFromScenario(SGPropertyNode* scFileNode); diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index a9635c5f7..08f5afb40 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -29,18 +29,18 @@ #include "AIMultiplayer.hxx" -#include // #define SG_DEBUG SG_ALERT -FGAIMultiplayer::FGAIMultiplayer() : FGAIBase(otMultiplayer) { +FGAIMultiplayer::FGAIMultiplayer() : + FGAIBase(otMultiplayer, false) +{ no_roll = false; mTimeOffsetSet = false; mAllowExtrapolation = true; mLagAdjustSystemSpeed = 10; mLastTimestamp = 0; - aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); lastUpdateTime = 0; } diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 9b6a04705..b5df3d145 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -42,7 +42,8 @@ FGAIShip::FGAIShip(object_type ot) : -FGAIBase(ot), +// allow HOT to be enabled +FGAIBase(ot, true), _waiting(false), diff --git a/src/AIModel/AIStatic.cxx b/src/AIModel/AIStatic.cxx index 83be7c8d6..5ac1f4ce3 100644 --- a/src/AIModel/AIStatic.cxx +++ b/src/AIModel/AIStatic.cxx @@ -33,7 +33,7 @@ using std::string; #include "AIStatic.hxx" -FGAIStatic::FGAIStatic() : FGAIBase(otStatic) { +FGAIStatic::FGAIStatic() : FGAIBase(otStatic, false) { } diff --git a/src/AIModel/AIStorm.cxx b/src/AIModel/AIStorm.cxx index fded8012d..a4241df46 100644 --- a/src/AIModel/AIStorm.cxx +++ b/src/AIModel/AIStorm.cxx @@ -35,7 +35,9 @@ using std::string; #include "AIStorm.hxx" -FGAIStorm::FGAIStorm() : FGAIBase(otStorm) { +FGAIStorm::FGAIStorm() : + FGAIBase(otStorm, false) +{ delay = 3.6; subflashes = 1; timer = 0.0; diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index 172d1e68a..f47ba2356 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -35,7 +35,9 @@ using std::string; #include "AIThermal.hxx" -FGAIThermal::FGAIThermal() : FGAIBase(otThermal) { +FGAIThermal::FGAIThermal() : + FGAIBase(otThermal, false) +{ max_strength = 6.0; diameter = 0.5; strength = factor = 0.0; From 1ebab94710faaa5295470ad77cc44be5e8104473 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:08:19 +0200 Subject: [PATCH 5/7] #358: Missing option to disable AI scenarios --ai-scenario=... can only add/enable another scenario. Introduce --disable-ai-scenarios option to disable all scenarios (can be used by external launchers, GUIs etc) Also provide error instead of debug message when a scenario cannot be loaded. --- src/AIModel/AIManager.cxx | 6 +++--- src/Main/options.cxx | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 419098112..91ef65271 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -358,9 +358,9 @@ FGAIManager::loadScenarioFile(const std::string& filename) SGPropertyNode_ptr root = new SGPropertyNode; readProperties(path.str(), root); return root; - } catch (const sg_exception &) { - SG_LOG(SG_GENERAL, SG_DEBUG, "Incorrect path specified for AI " - "scenario: \"" << path.str() << "\""); + } catch (const sg_exception &t) { + SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '" + << path.str() << "': " << t.getFormattedMessage()); return 0; } } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 453e68e48..ff306e6d9 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -1167,6 +1167,15 @@ fgOptScenario( const char *arg ) return FG_OPTIONS_OK; } +static int +fgOptNoScenarios( const char *arg ) +{ + SGPropertyNode_ptr ai_node = fgGetNode( "/sim/ai", true ); + ai_node->removeChildren("scenario",false); + ai_node->setBoolValue( "enabled", false ); + return FG_OPTIONS_OK; +} + static int fgOptRunway( const char *arg ) { @@ -1465,6 +1474,7 @@ struct OptionDesc { {"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 }, {"livery", true, OPTION_FUNC, "", false, "", fgOptLivery }, {"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario }, + {"disable-ai-scenarios", false, OPTION_FUNC, "", false, "", fgOptNoScenarios}, {"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking }, {"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, From 68dec9af2dae7a46d2ad6a6be18150035ef1299c Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 16:18:36 +0200 Subject: [PATCH 6/7] #178 related: avoid sim from freezing when FDM goes wild --- src/Instrumentation/heading_indicator_dg.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index bb9c1620e..a4c478be0 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -153,6 +153,10 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; + // sanity check: bail out when the FDM runs wild, to avoid + // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. + if (fabs(heading)>1e10) + return; SG_NORMALIZE_RANGE(heading, 0.0, 360.0); _heading_out_node->setDoubleValue(heading); From b2c03e4efcf6b41bfe5660ab8c9098c843b891e7 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 26 Jun 2011 19:05:28 +0200 Subject: [PATCH 7/7] #178: improve normalization issue (avoid loops altogether) thanks to Torsten --- src/Instrumentation/heading_indicator_dg.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index a4c478be0..0c4864912 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -115,7 +115,7 @@ HeadingIndicatorDG::update (double dt) // Next, calculate time-based precession double offset = _offset_node->getDoubleValue(); offset -= dt * (0.25 / 60.0); // 360deg/day - SG_NORMALIZE_RANGE(offset, -360.0, 360.0); + offset = SGMiscd::normalizePeriodic(-360.0,360.0,offset); _offset_node->setDoubleValue(offset); // No magvar - set the alignment manually @@ -153,11 +153,7 @@ HeadingIndicatorDG::update (double dt) _last_heading_deg = heading; heading += offset + align + error; - // sanity check: bail out when the FDM runs wild, to avoid - // SG_NORMALIZE_RANGE from freezing on huge/infinite numbers. - if (fabs(heading)>1e10) - return; - SG_NORMALIZE_RANGE(heading, 0.0, 360.0); + heading = SGMiscd::normalizePeriodic(0.0,360.0,heading); _heading_out_node->setDoubleValue(heading);