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
}
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;
}
}
bool FGAIBallistic::getHtAGL(){
- if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 10000),
- _elevation_m, &_material)){
+ if (getGroundElevationM(SGGeod::fromGeodM(pos, 10000),
+ _elevation_m, &_material)) {
_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
if (_material) {
const vector<string>& names = _material->get_names();
void FGAIBase::initModel(osg::Node *node)
{
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());
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 {
SGVec3d cartPos = getCartPos();
return cartPos.x();
using std::string;
using std::list;
+class SGMaterial;
class FGAIManager;
class FGAIFlightPlan;
SGVec3d getCartPosAt(const SGVec3d& off) const;
SGVec3d getCartPos() const;
+ bool getGroundElevationM(const SGGeod& pos, double& elev,
+ const SGMaterial** material) const;
+
double _getCartPosX() const;
double _getCartPosY() const;
double _getCartPosZ() const;
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/math/sg_random.h>
-#include <simgear/scene/util/SGNodeMasks.hxx>
#include "AIShip.hxx"
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() {
FGAIBase::bind();
virtual void readFromScenario(SGPropertyNode* scFileNode);
virtual bool init(bool search_in_AI_path=false);
- virtual void initModel(osg::Node *node);
virtual void bind();
virtual void unbind();
virtual void update(double dt);
dt_count += dt;
if (dt_count >= 10.0 ) {
//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;
do_agl_calc = 0;
altitude_agl_ft = height - ground_elev_ft ;
// FIXME: make shure the pos.lat/pos.lon values are in degrees ...
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;
}