1
0
Fork 0

Merge branch 'next' of git@gitorious.org:fg/flightgear into next

This commit is contained in:
Durk Talsma 2010-07-24 09:21:06 +02:00
commit a49d553ea8
16 changed files with 108 additions and 76 deletions

View file

@ -175,20 +175,12 @@ FGAIFlightPlan::FGAIFlightPlan(FGAIAircraft *ac,
if (wpt->name == "END") wpt->finished = true;
else wpt->finished = false;
waypoints.push_back(wpt);
} // of node loop
} catch (const sg_exception &e) {
SG_LOG(SG_GENERAL, SG_WARN, "Error reading AI flight plan: " <<
e.getMessage() << " from " << e.getOrigin());
}
}
catch (const sg_exception &) {
SG_LOG(SG_GENERAL, SG_WARN,
"Error reading AI flight plan: ");
cerr << "Errno = " << errno << endl;
if (errno == ENOENT)
{
SG_LOG(SG_GENERAL, SG_WARN, "Reason: No such file or directory");
}
}
}
else
{
} else {
// cout << path.str() << endl;
// cout << "Trying to create this plan dynamically" << endl;
// cout << "Route from " << dep->id << " to " << arr->id << endl;

View file

@ -38,7 +38,6 @@
#include "AIAircraft.hxx"
#include "performancedata.hxx"
using std::iostream;
void FGAIFlightPlan::evaluateRoutePart(double deplat,
@ -55,28 +54,18 @@ void FGAIFlightPlan::evaluateRoutePart(double deplat,
SGGeoc arr(SGGeoc::fromDegM(arrlon, arrlat, 100.0));
SGVec3d a = SGVec3d::fromGeoc(dep);
SGVec3d b = SGVec3d::fromGeoc(arr);
SGVec3d _cross = cross(b, a);
SGVec3d nb = normalize(SGVec3d::fromGeoc(arr));
SGVec3d na = normalize(a);
double angle = sgACos(dot(a, b));
SGVec3d _cross = cross(nb, na);
double angle = acos(dot(na, nb));
const double angleStep = 0.05 * SG_DEGREES_TO_RADIANS;
tmpNode = 0;
for (double ang = 0.0; ang < angle; ang += 0.05)
for (double ang = 0.0; ang < angle; ang += angleStep)
{
sgdVec3 newPos;
sgdMat4 matrix;
//cerr << "Angle = " << ang << endl;
sgdMakeRotMat4(matrix, ang, _cross.data());
for(int j = 0; j < 3; j++)
{
newPos[j] =0.0;
for (int k = 0; k<3; k++)
{
newPos[j] += matrix[j][k]*a[k];
}
}
//cerr << "1"<< endl;
SGGeod geod = SGGeod::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
SGQuatd q = SGQuatd::fromAngleAxis(ang, _cross);
SGGeod geod = SGGeod::fromCart(q.transform(a));
prevNode = tmpNode;
tmpNode = globals->get_airwaynet()->findNearestNode(geod);

View file

@ -108,6 +108,12 @@ FGAILocalTraffic::FGAILocalTraffic() {
_controlled = false;
_invisible = false;
ground = NULL;
tower = NULL;
ourGate = NULL;
nextTaxiNode = NULL;
holdShortNode = NULL;
}
FGAILocalTraffic::~FGAILocalTraffic() {
@ -1254,13 +1260,13 @@ void FGAILocalTraffic::ProcessCallback(int code) {
if(code == 1) {
ground->RequestDeparture(plane, this);
} else if(code == 2) {
tower->ContactAtHoldShort(plane, this, CIRCUIT);
if (_controlled) tower->ContactAtHoldShort(plane, this, CIRCUIT);
} else if(code == 3) {
tower->ReportRunwayVacated(plane.callsign);
if (_controlled) tower->ReportRunwayVacated(plane.callsign);
} else if(code == 11) {
tower->ReportDownwind(plane.callsign);
if (_controlled) tower->ReportDownwind(plane.callsign);
} else if(code == 13) {
tower->ReportFinal(plane.callsign);
if (_controlled) tower->ReportFinal(plane.callsign);
} else if(code == 99) { // Flag this instance for deletion
responseCounter = 0;
_removeSelf = true;

View file

@ -273,8 +273,7 @@ typedef map<string,int> MSI;
void FGATCMgr::ZapOtherService(const string ncunit, const string svc_name){
for (atc_list_iterator svc = atc_list->begin(); svc != atc_list->end(); svc++) {
//cout << "Zapping " << navcomm
// << "[" << unit << "]" << " otherthan: " << svc_name << endl;
if (svc->first != svc_name) {
MSI &actv = svc->second->active_on;
// OK, we have found some OTHER service;
@ -286,7 +285,9 @@ void FGATCMgr::ZapOtherService(const string ncunit, const string svc_name){
//cout << "Eradicating service: '" << svc->first << "'" << endl;
svc->second->SetNoDisplay();
svc->second->Update(0); // one last update
delete svc->second;
SG_LOG(SG_GENERAL, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/"
<< svc->second->get_ident());
// delete svc->second;
atc_list->erase(svc);
// ALL pointers into the ATC list are now invalid,
// so let's reset them:

View file

@ -211,20 +211,32 @@ FGEnvironment::read (const SGPropertyNode * node)
maybe_copy_value(this, node, "visibility-m",
&FGEnvironment::set_visibility_m);
maybe_copy_value(this, node, "elevation-ft",
&FGEnvironment::set_elevation_ft);
if (!maybe_copy_value(this, node, "temperature-sea-level-degc",
&FGEnvironment::set_temperature_sea_level_degc))
maybe_copy_value(this, node, "temperature-degc",
&FGEnvironment::set_temperature_degc);
&FGEnvironment::set_temperature_sea_level_degc)) {
if( maybe_copy_value(this, node, "temperature-degc",
&FGEnvironment::set_temperature_degc)) {
_recalc_sl_temperature();
}
}
if (!maybe_copy_value(this, node, "dewpoint-sea-level-degc",
&FGEnvironment::set_dewpoint_sea_level_degc))
maybe_copy_value(this, node, "dewpoint-degc",
&FGEnvironment::set_dewpoint_degc);
&FGEnvironment::set_dewpoint_sea_level_degc)) {
if( maybe_copy_value(this, node, "dewpoint-degc",
&FGEnvironment::set_dewpoint_degc)) {
_recalc_sl_dewpoint();
}
}
if (!maybe_copy_value(this, node, "pressure-sea-level-inhg",
&FGEnvironment::set_pressure_sea_level_inhg))
maybe_copy_value(this, node, "pressure-inhg",
&FGEnvironment::set_pressure_inhg);
&FGEnvironment::set_pressure_sea_level_inhg)) {
if( maybe_copy_value(this, node, "pressure-inhg",
&FGEnvironment::set_pressure_inhg)) {
_recalc_sl_pressure();
}
}
maybe_copy_value(this, node, "wind-from-heading-deg",
&FGEnvironment::set_wind_from_heading_deg);
@ -232,9 +244,6 @@ FGEnvironment::read (const SGPropertyNode * node)
maybe_copy_value(this, node, "wind-speed-kt",
&FGEnvironment::set_wind_speed_kt);
maybe_copy_value(this, node, "elevation-ft",
&FGEnvironment::set_elevation_ft);
maybe_copy_value(this, node, "turbulence/magnitude-norm",
&FGEnvironment::set_turbulence_magnitude_norm);
@ -652,7 +661,7 @@ FGEnvironment::_recalc_sl_temperature ()
}
#endif
if (elevation_ft >= ISA_def[1].height) {
if (elevation_ft * atmodel::foot >= ISA_def[1].height) {
SG_LOG(SG_GENERAL, SG_ALERT, "recalc_sl_temperature: "
<< "valid only in troposphere, not " << elevation_ft);
return;

View file

@ -132,7 +132,9 @@ void
FGInterpolateEnvironmentCtrl::init ()
{
read_table( boundary_n, _boundary_table);
read_table( aloft_n, _aloft_table);
// pass in a pointer to the environment of the last bondary layer as
// a starting point
read_table( aloft_n, _aloft_table, &(*(_boundary_table.end()-1))->environment);
}
void
@ -142,7 +144,7 @@ FGInterpolateEnvironmentCtrl::reinit ()
}
void
FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table)
FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table, FGEnvironment * parent )
{
double last_altitude_ft = 0.0;
double sort_required = false;
@ -163,8 +165,11 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bu
b = new bucket;
table.push_back(b);
}
if (i == 0 && parent != NULL )
b->environment.copy( *parent );
if (i > 0)
b->environment.copy(table[i-1]->environment);
b->environment.read(child);
b->altitude_ft = b->environment.get_elevation_ft();

View file

@ -101,7 +101,7 @@ private:
static bool lessThan(bucket *a, bucket *b);
};
void read_table (const SGPropertyNode * node, std::vector<bucket *> &table);
void read_table (const SGPropertyNode * node, std::vector<bucket *> &table, FGEnvironment * parent = NULL );
void do_interpolate (std::vector<bucket *> &table, double altitude_ft,
FGEnvironment * environment);

View file

@ -295,7 +295,9 @@ FGEnvironmentMgr::update (double dt)
osg::Vec3 windVec(-_environment->get_wind_from_north_fps(),
-_environment->get_wind_from_east_fps(),
_environment->get_wind_from_down_fps());
simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
// simgear::Particles::setWindVector(windVec * SG_FEET_TO_METER);
simgear::Particles::setWindFrom( _environment->get_wind_from_heading_deg(),
_environment->get_wind_speed_kt() );
}
FGEnvironment

View file

@ -100,8 +100,7 @@ double FGClouds::buildCloud(SGPropertyNode *cloud_def_root, SGPropertyNode *box_
double y = sg_random() * SGCloudField::fieldSize - (SGCloudField::fieldSize / 2.0);
double z = grid_z_rand * (sg_random() - 0.5);
sgVec3 pos={x,y,z};
SGVec3f pos(x,y,z);
for(int i = 0; i < box_def->nChildren() ; i++) {
SGPropertyNode *abox = box_def->getChild(i);

View file

@ -24,11 +24,10 @@
#endif
#include <sstream>
#include <simgear/math/vector.hxx>
#include <simgear/math/SGGeometry.hxx>
#include <Main/viewer.hxx>
#include "HUD.hxx"
// FIXME
static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
@ -424,12 +423,11 @@ void HUD::Ladder::draw(void)
// however the horizon line should always stay on the horizon. We
// project the alpha/beta offset onto the horizon line to get the
// result we want.
sgdVec3 p1; // result
sgdVec3 p; sgdSetVec3(p, vel_x, vel_y, 0.0);
sgdVec3 p0; sgdSetVec3(p0, 0.0, 0.0, 0.0);
sgdVec3 d; sgdSetVec3(d, cos(roll_value), sin(roll_value), 0.0);
sgdClosestPointToLine(p1, p, p0, d);
glTranslatef(p1[0], p1[1], 0);
SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
SGRayd r(SGVec3d::zeros(), d);
SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
glTranslatef(p[0], p[1], 0);
}
} else {
// ladder position is fixed relative to the center of the screen.

View file

@ -31,7 +31,6 @@
#include <simgear/sg_inlines.h>
#include <simgear/timing/sg_time.hxx>
#include <simgear/math/vector.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx>
#include <simgear/math/sg_geodesy.hxx>

View file

@ -1777,6 +1777,11 @@ private:
int maturity = 0;
string descStr(" ");
descStr += path.file();
// trim common suffix from file names
int nPos = descStr.rfind("-set.xml");
if (nPos == (int)(descStr.size() - 8)) {
descStr.resize(nPos);
}
SGPropertyNode *node = root.getNode("sim");
if (node) {

View file

@ -34,7 +34,6 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/scene/model/placement.hxx>
#include <simgear/math/vector.hxx>
#include <Main/globals.hxx>
#include <Scenery/scenery.hxx>

View file

@ -190,7 +190,7 @@ FGViewMgr::bind ()
fgTie("/sim/current-view/view-number", this,
&FGViewMgr::getView, &FGViewMgr::setView);
fgSetArchivable("/sim/current-view/view-number", FALSE);
fgSetArchivable("/sim/current-view/view-number", false);
fgTie("/sim/current-view/axes/long", this,
(double_getter)0, &FGViewMgr::setViewAxisLong);

View file

@ -32,7 +32,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/vector.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/scene/model/modellib.hxx>
#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>

View file

@ -26,7 +26,6 @@
#endif
#include <simgear/math/SGMath.hxx>
#include <simgear/math/vector.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/timing/sg_time.hxx>
@ -39,6 +38,37 @@
#include "sunsolver.hxx"
#include "tmp.hxx"
/**
* Map i.e. project a vector onto a plane.
* @param normal (in) normal vector for the plane
* @param v0 (in) a point on the plane
* @param vec (in) the vector to map onto the plane
*/
static SGVec3f map_vec_onto_cur_surface_plane(const SGVec3f& normal,
const SGVec3f& v0,
const SGVec3f& vec)
{
// calculate a vector "u1" representing the shortest distance from
// the plane specified by normal and v0 to a point specified by
// "vec". "u1" represents both the direction and magnitude of
// this desired distance.
// u1 = ( (normal <dot> vec) / (normal <dot> normal) ) * normal
SGVec3f u1 = (dot(normal, vec) / dot(normal, normal)) * normal;
// calculate the vector "v" which is the vector "vec" mapped onto
// the plane specified by "normal" and "v0".
// v = v0 + vec - u1
SGVec3f v = v0 + vec - u1;
// Calculate the vector "result" which is "v" - "v0" which is a
// directional vector pointing from v0 towards v
// result = v - v0
return v - v0;
}
// periodic time updater wrapper
void fgUpdateLocalTime() {
@ -158,10 +188,9 @@ void fgUpdateSunPos( void ) {
// local plane representing "horizontal".
// surface direction to go to head towards sun
SGVec3f surface_to_sun;
SGVec3f view_pos = toVec3f(v->get_view_pos());
sgmap_vec_onto_cur_surface_plane( world_up.data(), view_pos.data(),
to_sun.data(), surface_to_sun.data() );
SGVec3f surface_to_sun = map_vec_onto_cur_surface_plane(world_up, view_pos, to_sun);
surface_to_sun = normalize(surface_to_sun);
// cout << "(sg) Surface direction to sun is "
// << surface_to_sun[0] << ","