1
0
Fork 0
This commit is contained in:
Torsten Dreyer 2011-06-28 12:48:39 +02:00
commit 0d900923b2
19 changed files with 52 additions and 26 deletions

View file

@ -52,11 +52,15 @@ using std::string;
static string tempReg; 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; trafficRef = ref;
if (trafficRef) { if (trafficRef) {
groundOffset = trafficRef->getGroundOffset(); groundOffset = trafficRef->getGroundOffset();
setCallSign(trafficRef->getCallSign()); setCallSign(trafficRef->getCallSign());
} }
else else
groundOffset = 0; groundOffset = 0;

View file

@ -40,7 +40,7 @@ const double FGAIBallistic::slugs_to_kgs = 14.5939029372;
const double FGAIBallistic::slugs_to_lbs = 32.1740485564; const double FGAIBallistic::slugs_to_lbs = 32.1740485564;
FGAIBallistic::FGAIBallistic(object_type ot) : FGAIBallistic::FGAIBallistic(object_type ot) :
FGAIBase(ot), FGAIBase(ot, false),
_height(0.0), _height(0.0),
_speed(0), _speed(0),
_ht_agl_ft(0.0), _ht_agl_ft(0.0),

View file

@ -52,7 +52,7 @@ const double FGAIBase::lbs_to_slugs = 0.031080950172; //conversion factor
using namespace simgear; using namespace simgear;
FGAIBase::FGAIBase(object_type ot) : FGAIBase::FGAIBase(object_type ot, bool enableHot) :
_max_speed(300), _max_speed(300),
_name(""), _name(""),
_parent(""), _parent(""),
@ -121,6 +121,10 @@ FGAIBase::FGAIBase(object_type ot) :
p = 1e5; p = 1e5;
a = 340; a = 340;
Mach = 0; Mach = 0;
// explicitly disable HOT for (most) AI models
if (!enableHot)
aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
} }
FGAIBase::~FGAIBase() { FGAIBase::~FGAIBase() {

View file

@ -52,7 +52,7 @@ public:
otEscort, otMultiplayer, otEscort, otMultiplayer,
MAX_OBJECTS }; // Needs to be last!!! MAX_OBJECTS }; // Needs to be last!!!
FGAIBase(object_type ot); FGAIBase(object_type ot, bool enableHot);
virtual ~FGAIBase(); virtual ~FGAIBase();
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);

View file

@ -358,9 +358,9 @@ FGAIManager::loadScenarioFile(const std::string& filename)
SGPropertyNode_ptr root = new SGPropertyNode; SGPropertyNode_ptr root = new SGPropertyNode;
readProperties(path.str(), root); readProperties(path.str(), root);
return root; return root;
} catch (const sg_exception &) { } catch (const sg_exception &t) {
SG_LOG(SG_GENERAL, SG_DEBUG, "Incorrect path specified for AI " SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '"
"scenario: \"" << path.str() << "\""); << path.str() << "': " << t.getFormattedMessage());
return 0; return 0;
} }
} }

View file

@ -29,18 +29,18 @@
#include "AIMultiplayer.hxx" #include "AIMultiplayer.hxx"
#include <simgear/scene/util/SGNodeMasks.hxx>
// #define SG_DEBUG SG_ALERT // #define SG_DEBUG SG_ALERT
FGAIMultiplayer::FGAIMultiplayer() : FGAIBase(otMultiplayer) { FGAIMultiplayer::FGAIMultiplayer() :
FGAIBase(otMultiplayer, false)
{
no_roll = false; no_roll = false;
mTimeOffsetSet = false; mTimeOffsetSet = false;
mAllowExtrapolation = true; mAllowExtrapolation = true;
mLagAdjustSystemSpeed = 10; mLagAdjustSystemSpeed = 10;
mLastTimestamp = 0; mLastTimestamp = 0;
aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT);
lastUpdateTime = 0; lastUpdateTime = 0;
} }

View file

@ -42,7 +42,8 @@
FGAIShip::FGAIShip(object_type ot) : FGAIShip::FGAIShip(object_type ot) :
FGAIBase(ot), // allow HOT to be enabled
FGAIBase(ot, true),
_waiting(false), _waiting(false),

View file

@ -33,7 +33,7 @@ using std::string;
#include "AIStatic.hxx" #include "AIStatic.hxx"
FGAIStatic::FGAIStatic() : FGAIBase(otStatic) { FGAIStatic::FGAIStatic() : FGAIBase(otStatic, false) {
} }

View file

@ -35,7 +35,9 @@ using std::string;
#include "AIStorm.hxx" #include "AIStorm.hxx"
FGAIStorm::FGAIStorm() : FGAIBase(otStorm) { FGAIStorm::FGAIStorm() :
FGAIBase(otStorm, false)
{
delay = 3.6; delay = 3.6;
subflashes = 1; subflashes = 1;
timer = 0.0; timer = 0.0;

View file

@ -35,7 +35,9 @@ using std::string;
#include "AIThermal.hxx" #include "AIThermal.hxx"
FGAIThermal::FGAIThermal() : FGAIBase(otThermal) { FGAIThermal::FGAIThermal() :
FGAIBase(otThermal, false)
{
max_strength = 6.0; max_strength = 6.0;
diameter = 0.5; diameter = 0.5;
strength = factor = 0.0; strength = factor = 0.0;

View file

@ -442,7 +442,7 @@ void FGAirport::processThreshold(SGPropertyNode* aThreshold)
// first, let's identify the current runway // first, let's identify the current runway
string id(aThreshold->getStringValue("rwy")); string id(aThreshold->getStringValue("rwy"));
if (!hasRunwayWithIdent(id)) { 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); "found runway not defined in the global data:" << ident() << "/" << id);
return; return;
} }

View file

@ -115,7 +115,7 @@ HeadingIndicatorDG::update (double dt)
// Next, calculate time-based precession // Next, calculate time-based precession
double offset = _offset_node->getDoubleValue(); double offset = _offset_node->getDoubleValue();
offset -= dt * (0.25 / 60.0); // 360deg/day 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); _offset_node->setDoubleValue(offset);
// No magvar - set the alignment manually // No magvar - set the alignment manually
@ -153,7 +153,7 @@ HeadingIndicatorDG::update (double dt)
_last_heading_deg = heading; _last_heading_deg = heading;
heading += offset + align + error; heading += offset + align + error;
SG_NORMALIZE_RANGE(heading, 0.0, 360.0); heading = SGMiscd::normalizePeriodic(0.0,360.0,heading);
_heading_out_node->setDoubleValue(heading); _heading_out_node->setDoubleValue(heading);

View file

@ -27,6 +27,7 @@
#include "WindowSystemAdapter.hxx" #include "WindowSystemAdapter.hxx"
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/structure/OSGUtils.hxx> #include <simgear/structure/OSGUtils.hxx>
#include <simgear/structure/OSGVersion.hxx>
#include <simgear/scene/material/EffectCullVisitor.hxx> #include <simgear/scene/material/EffectCullVisitor.hxx>
#include <simgear/scene/util/RenderConstants.hxx> #include <simgear/scene/util/RenderConstants.hxx>
@ -191,8 +192,10 @@ void CameraGroup::update(const osg::Vec3d& position,
for (CameraList::iterator i = _cameras.begin(); i != _cameras.end(); ++i) { for (CameraList::iterator i = _cameras.begin(); i != _cameras.end(); ++i) {
const CameraInfo* info = i->get(); const CameraInfo* info = i->get();
const View::Slave& slave = _viewer->getSlave(info->slaveIndex); const View::Slave& slave = _viewer->getSlave(info->slaveIndex);
#if SG_OSG_VERSION_LESS_THAN(3,0,0)
// refreshes camera viewports (for now) // refreshes camera viewports (for now)
updateCameras(info); updateCameras(info);
#endif
Camera* camera = info->camera.get(); Camera* camera = info->camera.get();
Matrix viewMatrix; Matrix viewMatrix;
if ((info->flags & VIEW_ABSOLUTE) != 0) if ((info->flags & VIEW_ABSOLUTE) != 0)

View file

@ -1167,6 +1167,15 @@ fgOptScenario( const char *arg )
return FG_OPTIONS_OK; 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 static int
fgOptRunway( const char *arg ) fgOptRunway( const char *arg )
{ {
@ -1465,6 +1474,7 @@ struct OptionDesc {
{"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 }, {"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 },
{"livery", true, OPTION_FUNC, "", false, "", fgOptLivery }, {"livery", true, OPTION_FUNC, "", false, "", fgOptLivery },
{"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario }, {"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario },
{"disable-ai-scenarios", false, OPTION_FUNC, "", false, "", fgOptNoScenarios},
{"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking }, {"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking },
{"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, {"version", false, OPTION_FUNC, "", false, "", fgOptVersion },
{"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe},

View file

@ -1205,7 +1205,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg,
else else
{ {
// We failed to find the property. We'll try the next packet immediately. // 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 " "message from " << MsgHdr->Callsign << " has unknown property id "
<< id); << id);
} }

View file

@ -197,13 +197,13 @@ void Airway::Network::addEdge(Airway* aWay, const SGGeod& aStartPos,
FGPositionedRef end = FGPositioned::findClosestWithIdent(aEndIdent, aEndPos); FGPositionedRef end = FGPositioned::findClosestWithIdent(aEndIdent, aEndPos);
if (!start) { 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); start = FGPositioned::createUserWaypoint(aStartIdent, aStartPos);
return; return;
} }
if (!end) { 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); end = FGPositioned::createUserWaypoint(aEndIdent, aEndPos);
return; return;
} }

View file

@ -297,12 +297,12 @@ FGRunway* getRunwayFromName(const std::string& aName)
const FGAirport* apt = fgFindAirportID(parts[0]); const FGAirport* apt = fgFindAirportID(parts[0]);
if (!apt) { 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; return NULL;
} }
if (!apt->hasRunwayWithIdent(parts[1])) { 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; return NULL;
} }

View file

@ -61,7 +61,7 @@ FGNavRecord::FGNavRecord(Type aTy, const std::string& aIdent,
// assign our own defaults, unless the range is not set for some // assign our own defaults, unless the range is not set for some
// reason. // reason.
if (range < 0.1) { 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()) { switch (type()) {
case NDB: case NDB:
case VOR: case VOR:

View file

@ -269,13 +269,13 @@ bool FGScheduledFlight::initializeAirports()
departurePort = FGAirport::findByIdent(depId); departurePort = FGAirport::findByIdent(depId);
if(departurePort == NULL) 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; return false;
} }
arrivalPort = FGAirport::findByIdent(arrId); arrivalPort = FGAirport::findByIdent(arrId);
if(arrivalPort == NULL) 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; return false;
} }