From e5b1ab483125944465a80534f727bb3c98029661 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 28 Oct 2004 08:29:15 +0000 Subject: [PATCH] Vivian Meazza: As a result of recent requests, I've implemented the ability to switch off aerodynamic stabilisation: This has to be added to the submodel.xml files: false When false the submodel retains the pitch given at instantiation. It defaults to true. --- src/AIModel/AIBallistic.cxx | 8 ++++---- src/AIModel/AIBallistic.hxx | 4 ++-- src/AIModel/AIBase.hxx | 1 + src/AIModel/AIManager.cxx | 1 + src/AIModel/submodel.cxx | 2 ++ src/AIModel/submodel.hxx | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 2a9f97e73..86f1e3ad1 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -44,7 +44,6 @@ FGAIBallistic::~FGAIBallistic() { bool FGAIBallistic::init() { FGAIBase::init(); - aero_stabilized = true; hdg = azimuth; pitch = elevation; roll = rotation; @@ -84,8 +83,8 @@ void FGAIBallistic::setRoll(double rl) { rotation = rl; } -void FGAIBallistic::setStabilization(bool val) { - aero_stabilized = val; +void FGAIBallistic::setStabilisation(bool val) { + aero_stabilised = val; } void FGAIBallistic::setDragArea(double a) { @@ -181,7 +180,8 @@ void FGAIBallistic::Run(double dt) { pos.setelev(altitude * SG_FEET_TO_METER); // recalculate pitch (velocity vector) if aerostabilized - if (aero_stabilized) pitch = atan2( vs, hs ) * SG_RADIANS_TO_DEGREES; + // cout << "aero_stabilised " << aero_stabilised << endl ; + if (aero_stabilised) pitch = atan2( vs, hs ) * SG_RADIANS_TO_DEGREES; // recalculate total speed speed = sqrt( vs * vs + hs * hs); diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index 82309ea2b..c9df2a8d6 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -39,7 +39,7 @@ public: void setAzimuth( double az ); void setElevation( double el ); void setRoll( double rl ); - void setStabilization( bool val ); + void setStabilisation( bool val ); void setDragArea( double a ); void setLife( double seconds ); void setBuoyancy( double fpss ); @@ -57,7 +57,7 @@ private: double elevation; // degrees double rotation; // degrees double hs; // horizontal speed (fps) - bool aero_stabilized; // if true, object will point where it's going + bool aero_stabilised; // if true, object will align wit trajectory double drag_area; // equivalent drag area in ft2 double life_timer; // seconds double gravity; // fps2 diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 190500d3a..daf0caedb 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -65,6 +65,7 @@ typedef struct { double cd; // coefficient of drag bool wind; // if true, model reacts to parent wind double mass; // in slugs + bool aero_stabilised; // if true, ballistic object aligns with trajectory } FGAIModelEntity; diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 4faa4c269..a3d670e33 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -207,6 +207,7 @@ FGAIManager::createBallistic( FGAIModelEntity *entity ) { ai_ballistic->setRoll(entity->roll); ai_ballistic->setCd(entity->cd); ai_ballistic->setMass(entity->mass); + ai_ballistic->setStabilisation(entity->aero_stabilised); ai_ballistic->init(); ai_ballistic->bind(); return ai_ballistic; diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index a9992885b..b24e44eb8 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -129,6 +129,7 @@ FGSubmodelMgr::release (submodel* sm, double dt) entity.wind = sm->wind; entity.cd = sm->cd; entity.mass = IC.mass; + entity.aero_stabilised = sm->aero_stabilised; ai->createBallistic( &entity ); if (sm->count > 0) (sm->count)--; @@ -184,6 +185,7 @@ FGSubmodelMgr::load () sm->first_time = false; sm->cd = entry_node->getDoubleValue("cd", 0.193); sm->weight = entry_node->getDoubleValue("weight", 0.25); + sm->aero_stabilised = entry_node->getBoolValue ("aero-stabilised", true); sm->contents_node = fgGetNode(entry_node->getStringValue("contents", "none"), true); sm->trigger->setBoolValue(false); diff --git a/src/AIModel/submodel.hxx b/src/AIModel/submodel.hxx index dbddf39fd..e02233a0a 100644 --- a/src/AIModel/submodel.hxx +++ b/src/AIModel/submodel.hxx @@ -52,6 +52,7 @@ public: double cd; double weight; double contents; + bool aero_stabilised; } submodel; typedef struct { -- 2.39.5