Push SGMaterial use into these classes that need it.
This commit is contained in:
parent
7e97a4c693
commit
26664aaff0
20 changed files with 74 additions and 58 deletions
|
@ -498,9 +498,10 @@ void FGAIBallistic::setForcePath(const string& p) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -607,7 +607,7 @@ SGVec3d FGAIBase::getCartPos() const {
|
|||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
class FGAIManager;
|
||||
class FGAIFlightPlan;
|
||||
class FGFX;
|
||||
|
@ -114,7 +116,7 @@ public:
|
|||
SGVec3d getCartPos() const;
|
||||
|
||||
bool getGroundElevationM(const SGGeod& pos, double& elev,
|
||||
const SGMaterial** material) const;
|
||||
const simgear::BVHMaterial** material) const;
|
||||
|
||||
double _elevation_m;
|
||||
|
||||
|
|
|
@ -190,8 +190,9 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -1330,7 +1330,7 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off,
|
|||
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))
|
||||
|
|
|
@ -26,7 +26,7 @@ void FGGround::getGroundPlane(const double pos[3],
|
|||
{
|
||||
// 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);
|
||||
|
||||
|
@ -38,7 +38,7 @@ void FGGround::getGroundPlane(const double pos[3],
|
|||
|
||||
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];
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "Ground.hpp"
|
||||
|
||||
class FGInterface;
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
|
||||
namespace yasim {
|
||||
|
||||
|
@ -21,7 +23,7 @@ public:
|
|||
|
||||
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]);
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
#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 {
|
||||
|
@ -146,7 +147,7 @@ void Gear::setInitialLoad(float l)
|
|||
|
||||
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;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef _GEAR_HPP
|
||||
#define _GEAR_HPP
|
||||
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
|
||||
namespace yasim {
|
||||
|
||||
|
@ -50,7 +52,7 @@ public:
|
|||
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);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "Glue.hpp"
|
||||
|
||||
#include <simgear/scene/material/mat.hxx>
|
||||
#include <simgear/bvh/BVHMaterial.hxx>
|
||||
#include "Ground.hpp"
|
||||
namespace yasim {
|
||||
|
||||
|
@ -35,7 +35,7 @@ void Ground::getGroundPlane(const double pos[3],
|
|||
|
||||
void Ground::getGroundPlane(const double pos[3],
|
||||
double plane[4], float vel[3],
|
||||
const SGMaterial **material)
|
||||
const simgear::BVHMaterial **material)
|
||||
{
|
||||
getGroundPlane(pos,plane,vel);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef _GROUND_HPP
|
||||
#define _GROUND_HPP
|
||||
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
namespace yasim {
|
||||
|
||||
class Ground {
|
||||
|
@ -14,7 +16,7 @@ public:
|
|||
|
||||
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]);
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ void Model::updateGround(State* s)
|
|||
// 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);
|
||||
}
|
||||
|
|
|
@ -693,13 +693,13 @@ bool
|
|||
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
|
||||
|
@ -709,7 +709,6 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
|
|||
assign(normal, _normal);
|
||||
assign(linearVel, _linearVel);
|
||||
assign(angularVel, _angularVel);
|
||||
material = dynamic_cast<const SGMaterial*>(m);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -717,15 +716,15 @@ bool
|
|||
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
|
||||
|
@ -736,7 +735,6 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
|
|||
assign( normal, _normal );
|
||||
assign( linearVel, SG_METER_TO_FEET*_linearVel );
|
||||
assign( angularVel, _angularVel );
|
||||
material = dynamic_cast<const SGMaterial*>(m);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -744,19 +742,18 @@ bool
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -764,20 +761,19 @@ bool
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -831,7 +827,7 @@ FGInterface::get_groundlevel_m(const SGGeod& geod)
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -89,7 +89,9 @@ using std::list;
|
|||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
* A little helper class to update the track if
|
||||
|
@ -693,11 +695,11 @@ public:
|
|||
// 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);
|
||||
|
@ -708,11 +710,11 @@ public:
|
|||
// 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);
|
||||
|
||||
|
||||
|
|
|
@ -382,10 +382,9 @@ FGGroundCache::prepare_ground_cache(double startSimTime, double endSimTime,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -210,9 +210,10 @@ agRadar::setUserVec(double az, double el)
|
|||
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();
|
||||
|
||||
|
|
|
@ -323,10 +323,12 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
|
|||
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) {
|
||||
|
|
|
@ -262,7 +262,8 @@ void FGScenery::unbind() {
|
|||
|
||||
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);
|
||||
|
@ -272,7 +273,7 @@ FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
|
|||
|
||||
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);
|
||||
|
@ -291,7 +292,7 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
|
|||
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
|
||||
alt = geodEnd.getElevationM();
|
||||
if (material)
|
||||
*material = dynamic_cast<const SGMaterial*>(intersectVisitor.getMaterial());
|
||||
*material = intersectVisitor.getMaterial();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
#include "SceneryPager.hxx"
|
||||
|
||||
class SGMaterial;
|
||||
namespace simgear {
|
||||
class BVHMaterial;
|
||||
}
|
||||
|
||||
// Define a structure containing global scenery parameters
|
||||
class FGScenery : public SGSubsystem {
|
||||
|
@ -72,7 +74,7 @@ public:
|
|||
/// 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.
|
||||
|
@ -87,7 +89,8 @@ public:
|
|||
/// 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
|
||||
|
|
|
@ -894,10 +894,11 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args)
|
|||
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();
|
||||
|
|
Loading…
Add table
Reference in a new issue