]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIShip.cxx
Clean-up: move autosave.xml loading code to proper method
[flightgear.git] / src / AIModel / AIShip.cxx
index b7ce2ef348ef696b79a7baa335f7cd729b945528..5cf94f19dc97c35f1046180cbd83cf7ae942cba6 100644 (file)
@@ -101,6 +101,7 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
     setFixedTurnRadius(scFileNode->getDoubleValue("fixed-turn-radius-ft", 500));
     setSpeedConstant(scFileNode->getDoubleValue("speed-constant", 0.5));
     setSMPath(scFileNode->getStringValue("submodel-path", ""));
+    setRollFactor(scFileNode->getDoubleValue("roll-factor", 1));
 
     if (!flightplan.empty()) {
         SG_LOG(SG_AI, SG_ALERT, "getting flightplan: " << _name );
@@ -112,6 +113,12 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
 }
 
 bool FGAIShip::init(bool search_in_AI_path) {
+    reinit();
+    return FGAIBase::init(search_in_AI_path);
+}
+
+void FGAIShip::reinit()
+{
     prev = 0; // the one behind you
     curr = 0; // the one ahead
     next = 0; // the next plus 1
@@ -133,7 +140,7 @@ bool FGAIShip::init(bool search_in_AI_path) {
     if (fp)
         _fp_init = initFlightPlan();
 
-    return FGAIBase::init(search_in_AI_path);
+    FGAIBase::reinit();
 }
 
 void FGAIShip::bind() {
@@ -244,6 +251,7 @@ void FGAIShip::unbind() {
     props->untie("velocities/speed-kts");
 
 }
+
 void FGAIShip::update(double dt) {
     //SG_LOG(SG_AI, SG_ALERT, "updating Ship: " << _name <<hdg<<pitch<<roll);
     // For computation of rotation speeds we just use finite differences here.
@@ -258,7 +266,7 @@ void FGAIShip::update(double dt) {
     // local frame
     SGQuatd ec2body = ec2hl*hl2body;
     // The cartesian position of the ship in the wgs84 world
-    SGVec3d cartPos = SGVec3d::fromGeod(pos);
+    //SGVec3d cartPos = SGVec3d::fromGeod(pos);
 
     // The simulation time this transform is meant for
     aip.setReferenceTime(globals->get_sim_time_sec());
@@ -560,6 +568,10 @@ void FGAIShip::setFixedTurnRadius(double ftr) {
     _fixed_turn_radius = ftr;
 }
 
+void FGAIShip::setRollFactor(double rf) {
+    _roll_factor = rf * -0.0083335;
+}
+
 void FGAIShip::setInitialTunnel(bool t) {
     _initial_tunnel = t;
     setTunnel(_initial_tunnel);