}
bool FGAIBallistic::getHtAGL(double start){
- const SGMaterial* material = 0;
+ const simgear::BVHMaterial* mat = 0;
if (getGroundElevationM(SGGeod::fromGeodM(pos, start),
- _elevation_m, &material)) {
+ _elevation_m, &mat)) {
+ const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
if (material) {
}
bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev,
- const SGMaterial** material) const {
+ const simgear::BVHMaterial** material) const {
return globals->get_scenery()->get_elevation_m(pos, elev, material,
_model.get());
}
using std::string;
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
class FGAIManager;
class FGAIFlightPlan;
class FGFX;
SGVec3d getCartPos() const;
bool getGroundElevationM(const SGGeod& pos, double& elev,
- const SGMaterial** material) const;
+ const simgear::BVHMaterial** material) const;
double _elevation_m;
double height_m ;
- const SGMaterial* material = 0;
- if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &material,0)){
+ const simgear::BVHMaterial* mat = 0;
+ if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &mat, 0)){
+ const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
if (material) {
double contact[3], double normal[3], double vel[3],
double angularVel[3], double *agl)
{
- const SGMaterial* material;
+ const simgear::BVHMaterial* material;
simgear::BVHNode::Id id;
if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
angularVel, material, id))
{
// Return values for the callback.
double cp[3], dvel[3], dangvel[3];
- const SGMaterial* material;
+ const simgear::BVHMaterial* material;
simgear::BVHNode::Id id;
_iface->get_agl_m(_toff, pos, 2, cp, plane, dvel, dangvel, material, id);
void FGGround::getGroundPlane(const double pos[3],
double plane[4], float vel[3],
- const SGMaterial **material)
+ const simgear::BVHMaterial **material)
{
// Return values for the callback.
double cp[3], dvel[3], dangvel[3];
#include "Ground.hpp"
class FGInterface;
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
namespace yasim {
virtual void getGroundPlane(const double pos[3],
double plane[4], float vel[3],
- const SGMaterial **material);
+ const simgear::BVHMaterial **material);
virtual bool caughtWire(const double pos[4][3]);
#include "BodyEnvironment.hpp"
#include "RigidBody.hpp"
-#include <simgear/scene/material/mat.hxx>
+#include <cfloat>
+#include <simgear/bvh/BVHMaterial.hxx>
#include <FDM/flight.hxx>
#include "Gear.hpp"
namespace yasim {
void Gear::setGlobalGround(double *global_ground, float* global_vel,
double globalX, double globalY,
- const SGMaterial *material)
+ const simgear::BVHMaterial *material)
{
int i;
double frictionFactor,rollingFriction,loadCapacity,loadResistance,bumpiness;
#ifndef _GEAR_HPP
#define _GEAR_HPP
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
namespace yasim {
void setIgnoreWhileSolving(bool c);
void setGlobalGround(double* global_ground, float* global_vel,
double globalX, double globalY,
- const SGMaterial *material);
+ const simgear::BVHMaterial *material);
void getPosition(float* out);
void getCompression(float* out);
void getGlobalGround(double* global_ground);
#include "Glue.hpp"
-#include <simgear/scene/material/mat.hxx>
+#include <simgear/bvh/BVHMaterial.hxx>
#include "Ground.hpp"
namespace yasim {
void Ground::getGroundPlane(const double pos[3],
double plane[4], float vel[3],
- const SGMaterial **material)
+ const simgear::BVHMaterial **material)
{
getGroundPlane(pos,plane,vel);
}
#ifndef _GROUND_HPP
#define _GROUND_HPP
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
namespace yasim {
class Ground {
virtual void getGroundPlane(const double pos[3],
double plane[4], float vel[3],
- const SGMaterial **material);
+ const simgear::BVHMaterial **material);
virtual bool caughtWire(const double pos[4][3]);
// Ask for the ground plane in the global coordinate system
double global_ground[4];
float global_vel[3];
- const SGMaterial* material;
+ const simgear::BVHMaterial* material;
_ground_cb->getGroundPlane(pt, global_ground, global_vel, &material);
g->setGlobalGround(global_ground, global_vel, pt[0], pt[1], material);
}
FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
double contact[3], double normal[3],
double linearVel[3], double angularVel[3],
- SGMaterial const*& material, simgear::BVHNode::Id& id)
+ simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
{
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
SGVec3d _contact, _normal, _linearVel, _angularVel;
- const simgear::BVHMaterial* m = 0;
+ material = 0;
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
- _angularVel, id, m);
+ _angularVel, id, material);
// correct the linear velocity, since the line intersector delivers
// values for the start point and the get_agl function should
// traditionally deliver for the contact point
assign(normal, _normal);
assign(linearVel, _linearVel);
assign(angularVel, _angularVel);
- material = dynamic_cast<const SGMaterial*>(m);
return ret;
}
FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
double contact[3], double normal[3],
double linearVel[3], double angularVel[3],
- SGMaterial const*& material, simgear::BVHNode::Id& id)
+ simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
{
// Convert units and do the real work.
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
pt_m *= SG_FEET_TO_METER;
SGVec3d _contact, _normal, _linearVel, _angularVel;
- const simgear::BVHMaterial* m = 0;
+ material = 0;
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
- _angularVel, id, m);
+ _angularVel, id, material);
// correct the linear velocity, since the line intersector delivers
// values for the start point and the get_agl function should
// traditionally deliver for the contact point
assign( normal, _normal );
assign( linearVel, SG_METER_TO_FEET*_linearVel );
assign( angularVel, _angularVel );
- material = dynamic_cast<const SGMaterial*>(m);
return ret;
}
FGInterface::get_nearest_m(double t, const double pt[3], double maxDist,
double contact[3], double normal[3],
double linearVel[3], double angularVel[3],
- SGMaterial const*& material,
+ simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id)
{
SGVec3d _contact, _linearVel, _angularVel;
- const simgear::BVHMaterial* m = 0;
+ material = 0;
if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
- _angularVel, id, m))
+ _angularVel, id, material))
return false;
assign(contact, _contact);
assign(linearVel, _linearVel);
assign(angularVel, _angularVel);
- material = dynamic_cast<const SGMaterial*>(m);
return true;
}
FGInterface::get_nearest_ft(double t, const double pt[3], double maxDist,
double contact[3], double normal[3],
double linearVel[3], double angularVel[3],
- SGMaterial const*& material,
+ simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id)
{
SGVec3d _contact, _linearVel, _angularVel;
- const simgear::BVHMaterial* m = 0;
+ material = 0;
if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
SG_FEET_TO_METER*maxDist, _contact, _linearVel,
- _angularVel, id, m))
+ _angularVel, id, material))
return false;
assign(contact, SG_METER_TO_FEET*_contact);
assign(linearVel, SG_METER_TO_FEET*_linearVel);
assign(angularVel, _angularVel);
- material = dynamic_cast<const SGMaterial*>(m);
return true;
}
}
double contact[3], normal[3], vel[3], angvel[3];
- const SGMaterial* material;
+ const simgear::BVHMaterial* material;
simgear::BVHNode::Id id;
// Ignore the return value here, since it just tells us if
// the returns stem from the groundcache or from the coarse
using std::vector;
using std::string;
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
/**
* A little helper class to update the track if
// contact point.
bool get_agl_m(double t, const double pt[3], double max_altoff,
double contact[3], double normal[3], double linearVel[3],
- double angularVel[3], SGMaterial const*& material,
+ double angularVel[3], simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id);
bool get_agl_ft(double t, const double pt[3], double max_altoff,
double contact[3], double normal[3], double linearVel[3],
- double angularVel[3], SGMaterial const*& material,
+ double angularVel[3], simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id);
double get_groundlevel_m(double lat, double lon, double alt);
double get_groundlevel_m(const SGGeod& geod);
// position pt.
bool get_nearest_m(double t, const double pt[3], double maxDist,
double contact[3], double normal[3], double linearVel[3],
- double angularVel[3], SGMaterial const*& material,
+ double angularVel[3], simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id);
bool get_nearest_ft(double t, const double pt[3], double maxDist,
double contact[3], double normal[3],double linearVel[3],
- double angularVel[3], SGMaterial const*& material,
+ double angularVel[3], simgear::BVHMaterial const*& material,
simgear::BVHNode::Id& id);
if (!found_ground) {
// Ok, still nothing here?? Last resort ...
double alt = 0;
- const SGMaterial* m = NULL;
+ _material = 0;
found_ground = globals->get_scenery()->
- get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &m);
- _material = m;
+ get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &_material);
if (found_ground)
_altitude = alt;
}
bool
agRadar::getMaterial(){
- const SGMaterial* material = 0;
- if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &material)){
+ const simgear::BVHMaterial* mat = 0;
+ if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &mat)){
//_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
+ const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
if (material) {
const std::vector<std::string>& names = material->get_names();
while (elevations.size() <= e_size) {
probe_distance += point_distance;
SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, probe_distance ));
- const SGMaterial *mat = 0;
+ const simgear::BVHMaterial *material = 0;
double elevation_m = 0.0;
- if (scenery->get_elevation_m( probe, elevation_m, &mat )) {
+ if (scenery->get_elevation_m( probe, elevation_m, &material )) {
+ const SGMaterial *mat;
+ mat = dynamic_cast<const SGMaterial*>(material);
if((transmission_type == 3) || (transmission_type == 4)) {
elevations.push_back(elevation_m);
if(mat) {
bool
FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
- double& alt, const SGMaterial** material,
+ double& alt,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom)
{
SGGeod geod = SGGeod::fromCart(pos);
bool
FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
- const SGMaterial** material,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom)
{
SGVec3d start = SGVec3d::fromGeod(geod);
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
alt = geodEnd.getElevationM();
if (material)
- *material = dynamic_cast<const SGMaterial*>(intersectVisitor.getMaterial());
+ *material = intersectVisitor.getMaterial();
return true;
}
#include "SceneryPager.hxx"
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
// Define a structure containing global scenery parameters
class FGScenery : public SGSubsystem {
/// value is undefined.
/// All values are meant to be in meters or degrees.
bool get_elevation_m(const SGGeod& geod, double& alt,
- const SGMaterial** material,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom = 0);
/// Compute the elevation of the scenery below the cartesian point pos.
/// value is undefined.
/// All values are meant to be in meters.
bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
- double& elevation, const SGMaterial** material,
+ double& elevation,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom = 0);
/// Compute the nearest intersection point of the line starting from
double lat = naNumValue(args[0]).num;
double lon = naNumValue(args[1]).num;
double elev = argc == 3 ? naNumValue(args[2]).num : 10000;
- const SGMaterial *mat;
+ const simgear::BVHMaterial *material;
SGGeod geod = SGGeod::fromDegM(lon, lat, elev);
- if(!globals->get_scenery()->get_elevation_m(geod, elev, &mat))
+ if(!globals->get_scenery()->get_elevation_m(geod, elev, &material))
return naNil();
+ const SGMaterial *mat = dynamic_cast<const SGMaterial *>(material);
naRef vec = naNewVector(c);
naVec_append(vec, naNum(elev));
naRef matdata = naNil();