]> git.mxchange.org Git - flightgear.git/commitdiff
Vivian Meazza:
authorehofman <ehofman>
Mon, 27 Sep 2004 14:24:20 +0000 (14:24 +0000)
committerehofman <ehofman>
Mon, 27 Sep 2004 14:24:20 +0000 (14:24 +0000)
The calculation of submodel mass from weight has been moved from AIBallistic
to Submodel so that it is calculated only once, rather than on every
iteration as a present. The parameter <contents> has been added, primarily
so that droptanks will have the proper mass. It is the path to an
appropriate property containing a weight in lbs.

Care has to be taken with the use of <contents> because after a reset there
appears to be a delay in submodel instantiation (dt not properly reset???)
and the weight property is not always picked up before it is set to zero in
the key bindings. Slightly hard to explain. It works fine if FGFS has not
been reset though. There is a partial solution which involves the rejigging
of the fuel and gui nasal scripts, but there is still the visible delay in
instantiation to be resolved. I've nearly done the nasal fixes, which will
form part of an update to the Hunter only. I'll probably complete those
later today.

src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIScenario.cxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx

index 590177c310921136e0101ffe5ab83da794bc148c..6ebe6f753e64a2c343c8db6723385d9be92eec6c 100644 (file)
@@ -116,8 +116,8 @@ void FGAIBallistic::setCd(double c) {
    Cd = c;
 }
 
-void FGAIBallistic::setWeight(double w) {
-   weight = w;
+void FGAIBallistic::setMass(double m) {
+   mass = m;
 }
 
 void FGAIBallistic::Run(double dt) {
@@ -129,14 +129,10 @@ void FGAIBallistic::Run(double dt) {
    double speed_east_deg_sec;
    double wind_speed_from_north_deg_sec;
    double wind_speed_from_east_deg_sec;
-   double mass;
-   
-   // the drag calculations below assume sea-level density,
-   // rho = 0.023780  slugs/ft3
-   // calculate mass
-   mass = weight * lbs_to_slugs;
    
    // drag = Cd * 0.5 * rho * speed * speed * drag_area;
+   // rho is adjusted for altitude in void FGAIBase::update,
+   // using Standard Atmosphere (sealevel temperature 15C)
    // acceleration = drag/mass;
    // adjust speed by drag
    speed -= (Cd * 0.5 * rho * speed * speed * drag_area/mass) * dt; 
@@ -189,3 +185,4 @@ double FGAIBallistic::_getTime() const {
 }
 
 // end AIBallistic
+
index bc97ced2cac99b95cbf8d8717bc73d2bbb16ea24..82309ea2b8bbb1ec62c613917c4f4cbbe6a720b9 100644 (file)
@@ -1,4 +1,4 @@
-// FGAIBallistic - AIBase derived class creates an AI ballistic object
+// FGAIBallistic.hxx - AIBase derived class creates an AI ballistic object
 //
 // Written by David Culp, started November 2003.
 // - davidculp2@comcast.net
@@ -47,7 +47,7 @@ public:
     void setWind_from_north( double fps );
     void setWind( bool val );
     void setCd( double c );
-    void setWeight( double w );
+    void setMass( double m );
 
     double _getTime() const;
 
@@ -66,9 +66,10 @@ private:
     double wind_from_north; // fps
     bool wind;              // if true, local wind will be applied to object
     double Cd;              // drag coefficient
-    double weight;          // lbs
+    double mass;            // slugs
 
     void Run(double dt);
 };
 
 #endif  // _FG_AIBALLISTIC_HXX
+
index 6b71e2c861e0485b67c4c413083e9b4cce777fd3..f8728561d0b446d0582a0e5e472c938084656ccf 100644 (file)
@@ -64,7 +64,7 @@ typedef struct {
    double wind_from_north;    // in feet per second
    double cd;                 // coefficient of drag
    bool wind;                 // if true, model reacts to parent wind
-   double weight;             // in lbs
+   double mass;               // in slugs
 } FGAIModelEntity;
 
 
index e066b5a09135417219599e94b6550238c14cf843..6c50a0f5808d9268a9f9a2081ab07721c8947023 100644 (file)
@@ -206,7 +206,7 @@ FGAIManager::createBallistic( FGAIModelEntity *entity ) {
         ai_ballistic->setWind(entity->wind);
         ai_ballistic->setRoll(entity->roll);
         ai_ballistic->setCd(entity->cd);
-        ai_ballistic->setWeight(entity->weight);
+        ai_ballistic->setMass(entity->mass);
         ai_ballistic->init();
         ai_ballistic->bind();
         return ai_ballistic;
index cd46c170c8c6fd872b594fb81e1f5f2864f80c4a..9742db92c340f2d4dea1bea9a4e676f3cef45ca8 100644 (file)
@@ -81,7 +81,8 @@ FGAIScenario::FGAIScenario(string &filename)
      en->wind_from_north = entry_node->getDoubleValue("wind_from_north", 0);
      en->wind            = entry_node->getBoolValue("wind", false);
      en->cd              = entry_node->getDoubleValue  ("cd", 0.029); 
-     en->weight          = entry_node->getDoubleValue  ("weight", 0.030); 
+     en->mass            = entry_node->getDoubleValue  ("mass", 0.007); 
+
 
      en->fp             = NULL;
      if (en->flightplan != ""){
@@ -118,3 +119,4 @@ int FGAIScenario::nEntries( void )
 }
 
 // end scenario.cxx
+
index 975ca9329e82b8f98f0a1bb3fc10bd6da92e06b1..2e4ee7b7a26a771f8a6408b33b7d879b19f703d1 100644 (file)
@@ -25,6 +25,7 @@ SubmodelSystem::SubmodelSystem ()
   
   out[0] = out[1] = out[2] = 0;
   in[3] = out[3] = 1;
+  string contents_node;
 }
 
 SubmodelSystem::~SubmodelSystem ()
@@ -127,7 +128,7 @@ SubmodelSystem::release (submodel* sm, double dt)
   entity.wind_from_north = IC.wind_from_north;
   entity.wind = sm->wind;
   entity.cd = sm->cd;
-  entity.weight = sm->weight;
+  entity.mass = IC.mass;
   ai->createBallistic( &entity );
  
   if (sm->count > 0) (sm->count)--; 
@@ -138,6 +139,7 @@ SubmodelSystem::release (submodel* sm, double dt)
 void
 SubmodelSystem::load ()
 {
+
     int i;
     SGPropertyNode *path = fgGetNode("/sim/systems/submodels/path");
     SGPropertyNode root;
@@ -182,13 +184,18 @@ SubmodelSystem::load ()
      sm->first_time     = false;
      sm->cd             = entry_node->getDoubleValue("cd", 0.295);
      sm->weight         = entry_node->getDoubleValue("weight", 0.25);
+     sm->contents_node    = fgGetNode(entry_node->getStringValue("contents", "none"), true);
 
      sm->trigger->setBoolValue(false);
      sm->timer = sm->delay;
-
+     sm->contents = sm->contents_node->getDoubleValue();
      sm->prop = fgGetNode("/systems/submodels/submodel", i, true);
      sm->prop->tie("count", SGRawValuePointer<int>(&(sm->count)));
 
+//   sm->prop->tie("contents", SGRawValuePointer<double>(&(sm->contents)));
+//   sm->prop->tie("contents path", SGRawValuePointer<const char *>(&(sm->contents_node)));
      submodels.push_back( sm );
    }
 
@@ -201,7 +208,16 @@ void
 SubmodelSystem::transform( submodel* sm) 
 {
 
- // get initial conditions 
+// get initial conditions 
+// get the weight of the contents (lbs) and convert to mass (slugs)
+  sm->contents = sm->contents_node->getDoubleValue();
+  
+  IC.mass = (sm->weight + sm->contents) * lbs_to_slugs;;
+//  cout << IC.mass << endl;
+    
+// set contents to 0 in the parent
+   sm->contents_node->setDoubleValue(0); 
     
   IC.lat =        _user_lat_node->getDoubleValue();    
   IC.lon =        _user_lon_node->getDoubleValue();   
@@ -222,9 +238,8 @@ SubmodelSystem::transform( submodel* sm)
   in[0] = sm->x_offset;
   in[1] = sm->y_offset;
   in[2] = sm->z_offset; 
   
-  IC.mass = sm->weight * lbs_to_slugs;
-   
 // pre-process the trig functions
 
     cosRx = cos(-IC.roll * SG_DEGREES_TO_RADIANS);
@@ -331,3 +346,4 @@ SubmodelSystem::updatelat(double lat)
 
 
 
+
index ec9dbabb98e828e5ceb440376318e862624e3be3..a0c4dd6398e51e3f78b9626bf767c5b800b70a3d 100644 (file)
@@ -29,6 +29,7 @@ public:
  typedef struct {
   SGPropertyNode* trigger;
   SGPropertyNode* prop;
+  SGPropertyNode* contents_node;
   
   string             name;
   string             model;
@@ -50,7 +51,7 @@ public:
   bool               first_time;
   double             cd;
   double             weight;
-//  double             mass;
+  double             contents;
  } submodel; 
 
  typedef struct {
@@ -136,3 +137,4 @@ private:
 #endif // __SYSTEMS_SUBMODEL_HXX
 
 
+