1
0
Fork 0

Use the 'all but self' capability of the scenery elevaton code instead of

playing with node masks.

Modified Files:
 	src/AIModel/AIAircraft.cxx src/AIModel/AIBallistic.cxx
 	src/AIModel/AIBase.cxx src/AIModel/AIBase.hxx
 	src/AIModel/AIShip.cxx src/AIModel/AIShip.hxx
	src/AIModel/AIThermal.cxx src/ATCDCL/AILocalTraffic.cxx
This commit is contained in:
frohlich 2009-08-10 05:21:44 +00:00 committed by Tim Moore
parent 5ccff35017
commit bb2e5fb2c9
8 changed files with 15 additions and 14 deletions

View file

@ -412,7 +412,7 @@ void FGAIAircraft::getGroundElev(double dt) {
} }
double alt; double alt;
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 20000), alt, 0)) if (getGroundElevationM(SGGeod::fromGeodM(pos, 20000), alt, 0))
tgt_altitude_ft = alt * SG_METER_TO_FEET; tgt_altitude_ft = alt * SG_METER_TO_FEET;
} }
} }

View file

@ -426,8 +426,8 @@ void FGAIBallistic::setForcePath(const string& p) {
bool FGAIBallistic::getHtAGL(){ bool FGAIBallistic::getHtAGL(){
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 10000), if (getGroundElevationM(SGGeod::fromGeodM(pos, 10000),
_elevation_m, &_material)){ _elevation_m, &_material)) {
_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET; _ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
if (_material) { if (_material) {
const vector<string>& names = _material->get_names(); const vector<string>& names = _material->get_names();

View file

@ -191,8 +191,6 @@ bool FGAIBase::init(bool search_in_AI_path) {
void FGAIBase::initModel(osg::Node *node) void FGAIBase::initModel(osg::Node *node)
{ {
if (model.valid()) { if (model.valid()) {
// Disable altitude computations for general AI models.
model->setNodeMask(model->getNodeMask() & ~SG_NODEMASK_TERRAIN_BIT);
fgSetString("/ai/models/model-added", props->getPath()); fgSetString("/ai/models/model-added", props->getPath());
@ -452,6 +450,12 @@ SGVec3d FGAIBase::getCartPos() const {
return cartPos; return cartPos;
} }
bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev,
const SGMaterial** material) const {
return globals->get_scenery()->get_elevation_m(pos, elev, material,
model.get());
}
double FGAIBase::_getCartPosX() const { double FGAIBase::_getCartPosX() const {
SGVec3d cartPos = getCartPos(); SGVec3d cartPos = getCartPos();
return cartPos.x(); return cartPos.x();

View file

@ -36,6 +36,7 @@
using std::string; using std::string;
using std::list; using std::list;
class SGMaterial;
class FGAIManager; class FGAIManager;
class FGAIFlightPlan; class FGAIFlightPlan;
@ -93,6 +94,9 @@ public:
SGVec3d getCartPosAt(const SGVec3d& off) const; SGVec3d getCartPosAt(const SGVec3d& off) const;
SGVec3d getCartPos() const; SGVec3d getCartPos() const;
bool getGroundElevationM(const SGGeod& pos, double& elev,
const SGMaterial** material) const;
double _getCartPosX() const; double _getCartPosX() const;
double _getCartPosY() const; double _getCartPosY() const;
double _getCartPosZ() const; double _getCartPosZ() const;

View file

@ -34,7 +34,6 @@
#include <simgear/math/sg_geodesy.hxx> #include <simgear/math/sg_geodesy.hxx>
#include <simgear/timing/sg_time.hxx> #include <simgear/timing/sg_time.hxx>
#include <simgear/math/sg_random.h> #include <simgear/math/sg_random.h>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include "AIShip.hxx" #include "AIShip.hxx"
@ -118,11 +117,6 @@ bool FGAIShip::init(bool search_in_AI_path) {
return FGAIBase::init(search_in_AI_path); return FGAIBase::init(search_in_AI_path);
} }
void FGAIShip::initModel(osg::Node *node) {
FGAIBase::initModel(node);
model->setNodeMask(model->getNodeMask() | SG_NODEMASK_TERRAIN_BIT);
}
void FGAIShip::bind() { void FGAIShip::bind() {
FGAIBase::bind(); FGAIBase::bind();

View file

@ -37,7 +37,6 @@ public:
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);
virtual bool init(bool search_in_AI_path=false); virtual bool init(bool search_in_AI_path=false);
virtual void initModel(osg::Node *node);
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update(double dt); virtual void update(double dt);

View file

@ -229,7 +229,7 @@ double user_altitude = manager->get_user_altitude(); // MSL
dt_count += dt; dt_count += dt;
if (dt_count >= 10.0 ) { if (dt_count >= 10.0 ) {
//double alt; //double alt;
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 20000), alt, 0)){ if (getGroundElevationM(SGGeod::fromGeodM(pos, 20000), alt, 0)) {
ground_elev_ft = alt * SG_METER_TO_FEET; ground_elev_ft = alt * SG_METER_TO_FEET;
do_agl_calc = 0; do_agl_calc = 0;
altitude_agl_ft = height - ground_elev_ft ; altitude_agl_ft = height - ground_elev_ft ;

View file

@ -1553,7 +1553,7 @@ void FGAILocalTraffic::DoGroundElev() {
// FIXME: make shure the pos.lat/pos.lon values are in degrees ... // FIXME: make shure the pos.lat/pos.lon values are in degrees ...
double alt; double alt;
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0)) if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0, _aip.getSceneGraph()))
_ground_elevation_m = alt; _ground_elevation_m = alt;
} }