bvh: Adapt to upstream bvh changes in simgear.
This commit is contained in:
parent
cce186a57c
commit
e3ad3d3a07
19 changed files with 104 additions and 75 deletions
|
@ -151,6 +151,7 @@ else(SIMGEAR_SHARED)
|
||||||
environment
|
environment
|
||||||
nasal
|
nasal
|
||||||
tsync
|
tsync
|
||||||
|
bvh
|
||||||
bucket
|
bucket
|
||||||
io
|
io
|
||||||
serial
|
serial
|
||||||
|
@ -172,7 +173,6 @@ else(SIMGEAR_SHARED)
|
||||||
tgdb
|
tgdb
|
||||||
model
|
model
|
||||||
screen
|
screen
|
||||||
bvh
|
|
||||||
util
|
util
|
||||||
sound)
|
sound)
|
||||||
|
|
||||||
|
|
|
@ -498,16 +498,16 @@ void FGAIBallistic::setForcePath(const string& p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGAIBallistic::getHtAGL(double start){
|
bool FGAIBallistic::getHtAGL(double start){
|
||||||
|
const SGMaterial* material = 0;
|
||||||
if (getGroundElevationM(SGGeod::fromGeodM(pos, start),
|
if (getGroundElevationM(SGGeod::fromGeodM(pos, start),
|
||||||
_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();
|
||||||
_solid = _material->get_solid();
|
_solid = material->get_solid();
|
||||||
_load_resistance = _material->get_load_resistance();
|
_load_resistance = material->get_load_resistance();
|
||||||
_frictionFactor =_material->get_friction_factor();
|
_frictionFactor = material->get_friction_factor();
|
||||||
|
|
||||||
if (!names.empty())
|
if (!names.empty())
|
||||||
props->setStringValue("material/name", names[0].c_str());
|
props->setStringValue("material/name", names[0].c_str());
|
||||||
|
|
|
@ -219,8 +219,6 @@ private:
|
||||||
string _force_path;
|
string _force_path;
|
||||||
string _contents_path;
|
string _contents_path;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
void handle_collision();
|
void handle_collision();
|
||||||
void handle_expiry();
|
void handle_expiry();
|
||||||
void handle_impact();
|
void handle_impact();
|
||||||
|
|
|
@ -729,7 +729,7 @@ double FGAIBase::_getAltitude() const {
|
||||||
|
|
||||||
double FGAIBase::_getAltitudeAGL(SGGeod inpos, double start){
|
double FGAIBase::_getAltitudeAGL(SGGeod inpos, double start){
|
||||||
getGroundElevationM(SGGeod::fromGeodM(inpos, start),
|
getGroundElevationM(SGGeod::fromGeodM(inpos, start),
|
||||||
_elevation_m, &_material);
|
_elevation_m, NULL);
|
||||||
return inpos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
|
return inpos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,6 @@ public:
|
||||||
const SGMaterial** material) const;
|
const SGMaterial** material) const;
|
||||||
|
|
||||||
double _elevation_m;
|
double _elevation_m;
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
double _getCartPosX() const;
|
double _getCartPosX() const;
|
||||||
double _getCartPosY() const;
|
double _getCartPosY() const;
|
||||||
|
|
|
@ -190,13 +190,14 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
|
||||||
|
|
||||||
double height_m ;
|
double height_m ;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &_material,0)){
|
const SGMaterial* material = 0;
|
||||||
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &material,0)){
|
||||||
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
|
_ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
|
||||||
|
|
||||||
if (_material) {
|
if (material) {
|
||||||
const vector<string>& names = _material->get_names();
|
const vector<string>& names = material->get_names();
|
||||||
|
|
||||||
_solid = _material->get_solid();
|
_solid = material->get_solid();
|
||||||
|
|
||||||
if (!names.empty())
|
if (!names.empty())
|
||||||
props->setStringValue("material/name", names[0].c_str());
|
props->setStringValue("material/name", names[0].c_str());
|
||||||
|
|
|
@ -89,8 +89,6 @@ private:
|
||||||
|
|
||||||
double _max_speed;
|
double _max_speed;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
bool _MPControl, _patrol, _stn_deg_true;
|
bool _MPControl, _patrol, _stn_deg_true;
|
||||||
|
|
||||||
// std::string _parent;
|
// std::string _parent;
|
||||||
|
|
|
@ -237,13 +237,13 @@ bool FGAIGroundVehicle::getPitch() {
|
||||||
//double max_alt = 10000;
|
//double max_alt = 10000;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 3000),
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodFront, 3000),
|
||||||
elev_front, &_material, 0)){
|
elev_front, NULL, 0)){
|
||||||
front_elev_m = elev_front + _z_offset_m;
|
front_elev_m = elev_front + _z_offset_m;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 3000),
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 3000),
|
||||||
elev_rear, &_material, 0)){
|
elev_rear, NULL, 0)){
|
||||||
rear_elev_m = elev_rear;
|
rear_elev_m = elev_rear;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -93,8 +93,6 @@ private:
|
||||||
double _hitch_x_offset_m, _hitch_y_offset_m, _hitch_z_offset_m;
|
double _hitch_x_offset_m, _hitch_y_offset_m, _hitch_z_offset_m;
|
||||||
double _dt_count, _next_run, _break_count;
|
double _dt_count, _next_run, _break_count;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FG_AIGROUNDVEHICLE_HXX
|
#endif // FG_AIGROUNDVEHICLE_HXX
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ void FGAIShip::setWPPos() {
|
||||||
if (curr->getOn_ground()){
|
if (curr->getOn_ground()){
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(wppos, 3000),
|
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(wppos, 3000),
|
||||||
elevation_m, &_material, 0)){
|
elevation_m, NULL, 0)){
|
||||||
wppos.setElevationM(elevation_m);
|
wppos.setElevationM(elevation_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,6 @@ private:
|
||||||
|
|
||||||
SGGeod wppos;
|
SGGeod wppos;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
double getRange(double lat, double lon, double lat2, double lon2) const;
|
double getRange(double lat, double lon, double lat2, double lon2) const;
|
||||||
double getCourse(double lat, double lon, double lat2, double lon2) const;
|
double getCourse(double lat, double lon, double lat2, double lon2) const;
|
||||||
double getDaySeconds();
|
double getDaySeconds();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
#include <simgear/scene/material/mat.hxx>
|
||||||
|
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
@ -696,9 +697,9 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
|
||||||
{
|
{
|
||||||
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
|
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
|
||||||
SGVec3d _contact, _normal, _linearVel, _angularVel;
|
SGVec3d _contact, _normal, _linearVel, _angularVel;
|
||||||
material = 0;
|
const simgear::BVHMaterial* m = 0;
|
||||||
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
|
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
|
||||||
_angularVel, id, material);
|
_angularVel, id, m);
|
||||||
// correct the linear velocity, since the line intersector delivers
|
// correct the linear velocity, since the line intersector delivers
|
||||||
// values for the start point and the get_agl function should
|
// values for the start point and the get_agl function should
|
||||||
// traditionally deliver for the contact point
|
// traditionally deliver for the contact point
|
||||||
|
@ -708,6 +709,7 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
|
||||||
assign(normal, _normal);
|
assign(normal, _normal);
|
||||||
assign(linearVel, _linearVel);
|
assign(linearVel, _linearVel);
|
||||||
assign(angularVel, _angularVel);
|
assign(angularVel, _angularVel);
|
||||||
|
material = dynamic_cast<const SGMaterial*>(m);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,9 +723,9 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
|
||||||
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
|
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
|
||||||
pt_m *= SG_FEET_TO_METER;
|
pt_m *= SG_FEET_TO_METER;
|
||||||
SGVec3d _contact, _normal, _linearVel, _angularVel;
|
SGVec3d _contact, _normal, _linearVel, _angularVel;
|
||||||
material = 0;
|
const simgear::BVHMaterial* m = 0;
|
||||||
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
|
bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
|
||||||
_angularVel, id, material);
|
_angularVel, id, m);
|
||||||
// correct the linear velocity, since the line intersector delivers
|
// correct the linear velocity, since the line intersector delivers
|
||||||
// values for the start point and the get_agl function should
|
// values for the start point and the get_agl function should
|
||||||
// traditionally deliver for the contact point
|
// traditionally deliver for the contact point
|
||||||
|
@ -734,6 +736,7 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
|
||||||
assign( normal, _normal );
|
assign( normal, _normal );
|
||||||
assign( linearVel, SG_METER_TO_FEET*_linearVel );
|
assign( linearVel, SG_METER_TO_FEET*_linearVel );
|
||||||
assign( angularVel, _angularVel );
|
assign( angularVel, _angularVel );
|
||||||
|
material = dynamic_cast<const SGMaterial*>(m);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,13 +748,15 @@ FGInterface::get_nearest_m(double t, const double pt[3], double maxDist,
|
||||||
simgear::BVHNode::Id& id)
|
simgear::BVHNode::Id& id)
|
||||||
{
|
{
|
||||||
SGVec3d _contact, _linearVel, _angularVel;
|
SGVec3d _contact, _linearVel, _angularVel;
|
||||||
|
const simgear::BVHMaterial* m = 0;
|
||||||
if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
|
if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
|
||||||
_angularVel, id, material))
|
_angularVel, id, m))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
assign(contact, _contact);
|
assign(contact, _contact);
|
||||||
assign(linearVel, _linearVel);
|
assign(linearVel, _linearVel);
|
||||||
assign(angularVel, _angularVel);
|
assign(angularVel, _angularVel);
|
||||||
|
material = dynamic_cast<const SGMaterial*>(m);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,14 +768,16 @@ FGInterface::get_nearest_ft(double t, const double pt[3], double maxDist,
|
||||||
simgear::BVHNode::Id& id)
|
simgear::BVHNode::Id& id)
|
||||||
{
|
{
|
||||||
SGVec3d _contact, _linearVel, _angularVel;
|
SGVec3d _contact, _linearVel, _angularVel;
|
||||||
|
const simgear::BVHMaterial* m = 0;
|
||||||
if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
|
if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
|
||||||
SG_FEET_TO_METER*maxDist, _contact, _linearVel,
|
SG_FEET_TO_METER*maxDist, _contact, _linearVel,
|
||||||
_angularVel, id, material))
|
_angularVel, id, m))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
assign(contact, SG_METER_TO_FEET*_contact);
|
assign(contact, SG_METER_TO_FEET*_contact);
|
||||||
assign(linearVel, SG_METER_TO_FEET*_linearVel);
|
assign(linearVel, SG_METER_TO_FEET*_linearVel);
|
||||||
assign(angularVel, _angularVel);
|
assign(angularVel, _angularVel);
|
||||||
|
material = dynamic_cast<const SGMaterial*>(m);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ using std::list;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
class SGMaterial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A little helper class to update the track if
|
* A little helper class to update the track if
|
||||||
* the position has changed. In the constructor,
|
* the position has changed. In the constructor,
|
||||||
|
|
|
@ -45,22 +45,22 @@
|
||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
#include <simgear/scene/util/OsgMath.hxx>
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
|
|
||||||
#include <simgear/scene/bvh/BVHNode.hxx>
|
#include <simgear/bvh/BVHNode.hxx>
|
||||||
#include <simgear/scene/bvh/BVHGroup.hxx>
|
#include <simgear/bvh/BVHGroup.hxx>
|
||||||
#include <simgear/scene/bvh/BVHTransform.hxx>
|
#include <simgear/bvh/BVHTransform.hxx>
|
||||||
#include <simgear/scene/bvh/BVHMotionTransform.hxx>
|
#include <simgear/bvh/BVHMotionTransform.hxx>
|
||||||
#include <simgear/scene/bvh/BVHLineGeometry.hxx>
|
#include <simgear/bvh/BVHLineGeometry.hxx>
|
||||||
#include <simgear/scene/bvh/BVHStaticGeometry.hxx>
|
#include <simgear/bvh/BVHStaticGeometry.hxx>
|
||||||
#include <simgear/scene/bvh/BVHStaticData.hxx>
|
#include <simgear/bvh/BVHStaticData.hxx>
|
||||||
#include <simgear/scene/bvh/BVHStaticNode.hxx>
|
#include <simgear/bvh/BVHStaticNode.hxx>
|
||||||
#include <simgear/scene/bvh/BVHStaticTriangle.hxx>
|
#include <simgear/bvh/BVHStaticTriangle.hxx>
|
||||||
#include <simgear/scene/bvh/BVHStaticBinary.hxx>
|
#include <simgear/bvh/BVHStaticBinary.hxx>
|
||||||
#include <simgear/scene/bvh/BVHSubTreeCollector.hxx>
|
#include <simgear/bvh/BVHSubTreeCollector.hxx>
|
||||||
#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
|
#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
|
||||||
#include <simgear/scene/bvh/BVHNearestPointVisitor.hxx>
|
#include <simgear/bvh/BVHNearestPointVisitor.hxx>
|
||||||
|
|
||||||
#ifdef GROUNDCACHE_DEBUG
|
#ifdef GROUNDCACHE_DEBUG
|
||||||
#include <simgear/scene/bvh/BVHDebugCollectVisitor.hxx>
|
#include <simgear/scene/model/BVHDebugCollectVisitor.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
SGVec3d down = _down;
|
SGVec3d down = _down;
|
||||||
double radius = _radius;
|
double radius = _radius;
|
||||||
bool haveHit = _haveHit;
|
bool haveHit = _haveHit;
|
||||||
const SGMaterial* material = _material;
|
const simgear::BVHMaterial* material = _material;
|
||||||
|
|
||||||
_haveHit = false;
|
_haveHit = false;
|
||||||
_center = toSG(inverseMatrix.preMult(toOsg(_center)));
|
_center = toSG(inverseMatrix.preMult(toOsg(_center)));
|
||||||
|
@ -275,7 +275,7 @@ public:
|
||||||
{ return _haveHit; }
|
{ return _haveHit; }
|
||||||
double getElevationBelowCache() const
|
double getElevationBelowCache() const
|
||||||
{ return SGGeod::fromCart(_sceneryHit).getElevationM(); }
|
{ return SGGeod::fromCart(_sceneryHit).getElevationM(); }
|
||||||
const SGMaterial* getMaterialBelowCache() const
|
const simgear::BVHMaterial* getMaterialBelowCache() const
|
||||||
{ return _material; }
|
{ return _material; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -288,7 +288,7 @@ private:
|
||||||
simgear::BVHSubTreeCollector mSubTreeCollector;
|
simgear::BVHSubTreeCollector mSubTreeCollector;
|
||||||
SGVec3d _sceneryHit;
|
SGVec3d _sceneryHit;
|
||||||
double _maxDown;
|
double _maxDown;
|
||||||
const SGMaterial* _material;
|
const simgear::BVHMaterial* _material;
|
||||||
bool _haveHit;
|
bool _haveHit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -381,8 +381,10 @@ FGGroundCache::prepare_ground_cache(double startSimTime, double endSimTime,
|
||||||
if (!found_ground) {
|
if (!found_ground) {
|
||||||
// Ok, still nothing here?? Last resort ...
|
// Ok, still nothing here?? Last resort ...
|
||||||
double alt = 0;
|
double alt = 0;
|
||||||
|
const SGMaterial* m = NULL;
|
||||||
found_ground = globals->get_scenery()->
|
found_ground = globals->get_scenery()->
|
||||||
get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &_material);
|
get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &m);
|
||||||
|
_material = m;
|
||||||
if (found_ground)
|
if (found_ground)
|
||||||
_altitude = alt;
|
_altitude = alt;
|
||||||
}
|
}
|
||||||
|
@ -456,6 +458,12 @@ public:
|
||||||
return;
|
return;
|
||||||
leaf.traverse(*this);
|
leaf.traverse(*this);
|
||||||
}
|
}
|
||||||
|
virtual void apply(BVHPageNode& leaf)
|
||||||
|
{
|
||||||
|
if (_foundId)
|
||||||
|
return;
|
||||||
|
leaf.traverse(*this);
|
||||||
|
}
|
||||||
virtual void apply(BVHTransform& transform)
|
virtual void apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
if (_foundId)
|
if (_foundId)
|
||||||
|
@ -553,6 +561,12 @@ public:
|
||||||
return;
|
return;
|
||||||
leaf.traverse(*this);
|
leaf.traverse(*this);
|
||||||
}
|
}
|
||||||
|
virtual void apply(BVHPageNode& leaf)
|
||||||
|
{
|
||||||
|
if (!intersects(_sphere, leaf.getBoundingSphere()))
|
||||||
|
return;
|
||||||
|
leaf.traverse(*this);
|
||||||
|
}
|
||||||
virtual void apply(BVHTransform& transform)
|
virtual void apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
if (!intersects(_sphere, transform.getBoundingSphere()))
|
if (!intersects(_sphere, transform.getBoundingSphere()))
|
||||||
|
@ -678,7 +692,7 @@ FGGroundCache::get_cat(double t, const SGVec3d& pt,
|
||||||
bool
|
bool
|
||||||
FGGroundCache::get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
|
FGGroundCache::get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
|
||||||
SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel,
|
SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel,
|
||||||
simgear::BVHNode::Id& id, const SGMaterial*& material)
|
simgear::BVHNode::Id& id, const simgear::BVHMaterial*& material)
|
||||||
{
|
{
|
||||||
#ifdef GROUNDCACHE_DEBUG
|
#ifdef GROUNDCACHE_DEBUG
|
||||||
SGTimeStamp t0 = SGTimeStamp::now();
|
SGTimeStamp t0 = SGTimeStamp::now();
|
||||||
|
@ -731,7 +745,7 @@ bool
|
||||||
FGGroundCache::get_nearest(double t, const SGVec3d& pt, double maxDist,
|
FGGroundCache::get_nearest(double t, const SGVec3d& pt, double maxDist,
|
||||||
SGVec3d& contact, SGVec3d& linearVel,
|
SGVec3d& contact, SGVec3d& linearVel,
|
||||||
SGVec3d& angularVel, simgear::BVHNode::Id& id,
|
SGVec3d& angularVel, simgear::BVHNode::Id& id,
|
||||||
const SGMaterial*& material)
|
const simgear::BVHMaterial*& material)
|
||||||
{
|
{
|
||||||
if (!_localBvhTree)
|
if (!_localBvhTree)
|
||||||
return false;
|
return false;
|
||||||
|
@ -787,6 +801,13 @@ public:
|
||||||
|
|
||||||
leaf.traverse(*this);
|
leaf.traverse(*this);
|
||||||
}
|
}
|
||||||
|
virtual void apply(BVHPageNode& leaf)
|
||||||
|
{
|
||||||
|
if (!_intersects(leaf.getBoundingSphere()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
leaf.traverse(*this);
|
||||||
|
}
|
||||||
virtual void apply(BVHTransform& transform)
|
virtual void apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
if (!_intersects(transform.getBoundingSphere()))
|
if (!_intersects(transform.getBoundingSphere()))
|
||||||
|
@ -920,6 +941,12 @@ public:
|
||||||
return;
|
return;
|
||||||
leaf.traverse(*this);
|
leaf.traverse(*this);
|
||||||
}
|
}
|
||||||
|
virtual void apply(BVHPageNode& leaf)
|
||||||
|
{
|
||||||
|
if (_haveLineSegment)
|
||||||
|
return;
|
||||||
|
leaf.traverse(*this);
|
||||||
|
}
|
||||||
virtual void apply(BVHTransform& transform)
|
virtual void apply(BVHTransform& transform)
|
||||||
{
|
{
|
||||||
if (_haveLineSegment)
|
if (_haveLineSegment)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/math/SGMath.hxx>
|
#include <simgear/math/SGMath.hxx>
|
||||||
#include <simgear/math/SGGeometry.hxx>
|
#include <simgear/math/SGGeometry.hxx>
|
||||||
#include <simgear/scene/bvh/BVHNode.hxx>
|
#include <simgear/bvh/BVHNode.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
|
||||||
// #define GROUNDCACHE_DEBUG
|
// #define GROUNDCACHE_DEBUG
|
||||||
|
@ -37,9 +37,9 @@
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SGMaterial;
|
|
||||||
namespace simgear {
|
namespace simgear {
|
||||||
class BVHLineGeometry;
|
class BVHLineGeometry;
|
||||||
|
class BVHMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FGGroundCache {
|
class FGGroundCache {
|
||||||
|
@ -89,11 +89,13 @@ public:
|
||||||
// 0 and 1 which can be used to model lower friction with wet runways.
|
// 0 and 1 which can be used to model lower friction with wet runways.
|
||||||
bool get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
|
bool get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
|
||||||
SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel,
|
SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel,
|
||||||
simgear::BVHNode::Id& id, const SGMaterial*& material);
|
simgear::BVHNode::Id& id,
|
||||||
|
const simgear::BVHMaterial*& material);
|
||||||
|
|
||||||
bool get_nearest(double t, const SGVec3d& pt, double maxDist,
|
bool get_nearest(double t, const SGVec3d& pt, double maxDist,
|
||||||
SGVec3d& contact, SGVec3d& linearVel, SGVec3d& angularVel,
|
SGVec3d& contact, SGVec3d& linearVel, SGVec3d& angularVel,
|
||||||
simgear::BVHNode::Id& id, const SGMaterial*& material);
|
simgear::BVHNode::Id& id,
|
||||||
|
const simgear::BVHMaterial*& material);
|
||||||
|
|
||||||
// Return 1 if the hook intersects with a wire.
|
// Return 1 if the hook intersects with a wire.
|
||||||
// That test is done by checking if the quad spanned by the points pt*
|
// That test is done by checking if the quad spanned by the points pt*
|
||||||
|
@ -120,7 +122,7 @@ private:
|
||||||
// In case the aircraft is too high above ground.
|
// In case the aircraft is too high above ground.
|
||||||
double _altitude;
|
double _altitude;
|
||||||
// the simgear material reference, contains friction coeficients ...
|
// the simgear material reference, contains friction coeficients ...
|
||||||
const SGMaterial* _material;
|
const simgear::BVHMaterial* _material;
|
||||||
// The time reference for later call to intersection test routines.
|
// The time reference for later call to intersection test routines.
|
||||||
// Is required since we will have moving triangles in carriers.
|
// Is required since we will have moving triangles in carriers.
|
||||||
double cache_ref_time;
|
double cache_ref_time;
|
||||||
|
|
|
@ -210,18 +210,19 @@ agRadar::setUserVec(double az, double el)
|
||||||
bool
|
bool
|
||||||
agRadar::getMaterial(){
|
agRadar::getMaterial(){
|
||||||
|
|
||||||
if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &_material)){
|
const SGMaterial* material = 0;
|
||||||
|
if (globals->get_scenery()->get_elevation_m(hitpos, _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 std::vector<std::string>& names = _material->get_names();
|
const std::vector<std::string>& names = material->get_names();
|
||||||
|
|
||||||
_solid = _material->get_solid();
|
_solid = material->get_solid();
|
||||||
_load_resistance = _material->get_load_resistance();
|
_load_resistance = material->get_load_resistance();
|
||||||
_frictionFactor =_material->get_friction_factor();
|
_frictionFactor = material->get_friction_factor();
|
||||||
_bumpinessFactor = _material->get_bumpiness();
|
_bumpinessFactor = material->get_bumpiness();
|
||||||
|
|
||||||
if (!names.empty())
|
if (!names.empty())
|
||||||
_mat_name = names[0].c_str();
|
_mat_name = names[0];
|
||||||
else
|
else
|
||||||
_mat_name = "";
|
_mat_name = "";
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,6 @@ public:
|
||||||
double _elevation_m; // ground elevation in meters
|
double _elevation_m; // ground elevation in meters
|
||||||
bool _solid; // if true ground is solid for FDMs
|
bool _solid; // if true ground is solid for FDMs
|
||||||
|
|
||||||
const SGMaterial* _material;
|
|
||||||
|
|
||||||
std::string _mat_name; // ground material
|
std::string _mat_name; // ground material
|
||||||
|
|
||||||
SGVec3d getCartUserPos() const;
|
SGVec3d getCartUserPos() const;
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
#include <simgear/scene/util/OsgMath.hxx>
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGSceneUserData.hxx>
|
#include <simgear/scene/util/SGSceneUserData.hxx>
|
||||||
#include <simgear/scene/model/CheckSceneryVisitor.hxx>
|
#include <simgear/scene/model/CheckSceneryVisitor.hxx>
|
||||||
#include <simgear/scene/bvh/BVHNode.hxx>
|
#include <simgear/bvh/BVHNode.hxx>
|
||||||
#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
|
#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
|
||||||
|
|
||||||
#include <Viewer/renderer.hxx>
|
#include <Viewer/renderer.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
@ -92,7 +92,7 @@ public:
|
||||||
{ return _haveHit; }
|
{ return _haveHit; }
|
||||||
const SGLineSegmentd& getLineSegment() const
|
const SGLineSegmentd& getLineSegment() const
|
||||||
{ return _lineSegment; }
|
{ return _lineSegment; }
|
||||||
const SGMaterial* getMaterial() const
|
const simgear::BVHMaterial* getMaterial() const
|
||||||
{ return _material; }
|
{ return _material; }
|
||||||
|
|
||||||
virtual void apply(osg::Node& node)
|
virtual void apply(osg::Node& node)
|
||||||
|
@ -152,7 +152,7 @@ private:
|
||||||
|
|
||||||
SGLineSegmentd lineSegment = _lineSegment;
|
SGLineSegmentd lineSegment = _lineSegment;
|
||||||
bool haveHit = _haveHit;
|
bool haveHit = _haveHit;
|
||||||
const SGMaterial* material = _material;
|
const simgear::BVHMaterial* material = _material;
|
||||||
|
|
||||||
_haveHit = false;
|
_haveHit = false;
|
||||||
_lineSegment = lineSegment.transform(SGMatrixd(inverseMatrix.ptr()));
|
_lineSegment = lineSegment.transform(SGMatrixd(inverseMatrix.ptr()));
|
||||||
|
@ -205,7 +205,7 @@ private:
|
||||||
SGLineSegmentd _lineSegment;
|
SGLineSegmentd _lineSegment;
|
||||||
const osg::Node* _skipNode;
|
const osg::Node* _skipNode;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
const simgear::BVHMaterial* _material;
|
||||||
bool _haveHit;
|
bool _haveHit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
|
||||||
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
|
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
|
||||||
alt = geodEnd.getElevationM();
|
alt = geodEnd.getElevationM();
|
||||||
if (material)
|
if (material)
|
||||||
*material = intersectVisitor.getMaterial();
|
*material = dynamic_cast<const SGMaterial*>(intersectVisitor.getMaterial());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
|
#include <simgear/scene/util/OsgMath.hxx>
|
||||||
#include <simgear/scene/util/SGNodeMasks.hxx>
|
#include <simgear/scene/util/SGNodeMasks.hxx>
|
||||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
|
@ -41,9 +42,8 @@
|
||||||
#include <simgear/scene/tgdb/userdata.hxx>
|
#include <simgear/scene/tgdb/userdata.hxx>
|
||||||
#include <simgear/scene/model/ModelRegistry.hxx>
|
#include <simgear/scene/model/ModelRegistry.hxx>
|
||||||
#include <simgear/misc/ResourceManager.hxx>
|
#include <simgear/misc/ResourceManager.hxx>
|
||||||
#include <simgear/scene/bvh/BVHNode.hxx>
|
#include <simgear/bvh/BVHNode.hxx>
|
||||||
#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
|
#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
|
||||||
#include <simgear/scene/util/OsgMath.hxx>
|
|
||||||
|
|
||||||
class FGSceneryIntersect : public osg::NodeVisitor {
|
class FGSceneryIntersect : public osg::NodeVisitor {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Reference in a new issue