environment
nasal
tsync
+ bvh
bucket
io
serial
tgdb
model
screen
- bvh
util
sound)
}
bool FGAIBallistic::getHtAGL(double start){
-
+ const SGMaterial* material = 0;
if (getGroundElevationM(SGGeod::fromGeodM(pos, start),
- _elevation_m, &_material)) {
+ _elevation_m, &material)) {
_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
- if (_material) {
- const vector<string>& names = _material->get_names();
- _solid = _material->get_solid();
- _load_resistance = _material->get_load_resistance();
- _frictionFactor =_material->get_friction_factor();
+ if (material) {
+ const vector<string>& names = material->get_names();
+ _solid = material->get_solid();
+ _load_resistance = material->get_load_resistance();
+ _frictionFactor = material->get_friction_factor();
if (!names.empty())
props->setStringValue("material/name", names[0].c_str());
string _force_path;
string _contents_path;
- const SGMaterial* _material;
-
void handle_collision();
void handle_expiry();
void handle_impact();
double FGAIBase::_getAltitudeAGL(SGGeod inpos, double start){
getGroundElevationM(SGGeod::fromGeodM(inpos, start),
- _elevation_m, &_material);
+ _elevation_m, NULL);
return inpos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
}
const SGMaterial** material) const;
double _elevation_m;
- const SGMaterial* _material;
double _getCartPosX() const;
double _getCartPosY() const;
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;
- if (_material) {
- const vector<string>& names = _material->get_names();
+ if (material) {
+ const vector<string>& names = material->get_names();
- _solid = _material->get_solid();
+ _solid = material->get_solid();
if (!names.empty())
props->setStringValue("material/name", names[0].c_str());
double _max_speed;
- const SGMaterial* _material;
-
bool _MPControl, _patrol, _stn_deg_true;
// std::string _parent;
//double max_alt = 10000;
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;
} else
return false;
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(geodRear, 3000),
- elev_rear, &_material, 0)){
+ elev_rear, NULL, 0)){
rear_elev_m = elev_rear;
} else
return false;
double _hitch_x_offset_m, _hitch_y_offset_m, _hitch_z_offset_m;
double _dt_count, _next_run, _break_count;
- const SGMaterial* _material;
-
};
#endif // FG_AIGROUNDVEHICLE_HXX
if (curr->getOn_ground()){
if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(wppos, 3000),
- elevation_m, &_material, 0)){
+ elevation_m, NULL, 0)){
wppos.setElevationM(elevation_m);
}
SGGeod wppos;
- const SGMaterial* _material;
-
double getRange(double lat, double lon, double lat2, double lon2) const;
double getCourse(double lat, double lon, double lat2, double lon2) const;
double getDaySeconds();
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/timing/timestamp.hxx>
+#include <simgear/scene/material/mat.hxx>
#include <Scenery/scenery.hxx>
#include <Main/globals.hxx>
{
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
SGVec3d _contact, _normal, _linearVel, _angularVel;
- material = 0;
+ const simgear::BVHMaterial* m = 0;
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
// 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;
}
SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
pt_m *= SG_FEET_TO_METER;
SGVec3d _contact, _normal, _linearVel, _angularVel;
- material = 0;
+ const simgear::BVHMaterial* m = 0;
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
// 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;
}
simgear::BVHNode::Id& id)
{
SGVec3d _contact, _linearVel, _angularVel;
+ const simgear::BVHMaterial* m = 0;
if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
- _angularVel, id, material))
+ _angularVel, id, m))
return false;
assign(contact, _contact);
assign(linearVel, _linearVel);
assign(angularVel, _angularVel);
+ material = dynamic_cast<const SGMaterial*>(m);
return true;
}
simgear::BVHNode::Id& id)
{
SGVec3d _contact, _linearVel, _angularVel;
+ const simgear::BVHMaterial* m = 0;
if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
SG_FEET_TO_METER*maxDist, _contact, _linearVel,
- _angularVel, id, material))
+ _angularVel, id, m))
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;
}
using std::vector;
using std::string;
+class SGMaterial;
+
/**
* A little helper class to update the track if
* the position has changed. In the constructor,
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/util/OsgMath.hxx>
-#include <simgear/scene/bvh/BVHNode.hxx>
-#include <simgear/scene/bvh/BVHGroup.hxx>
-#include <simgear/scene/bvh/BVHTransform.hxx>
-#include <simgear/scene/bvh/BVHMotionTransform.hxx>
-#include <simgear/scene/bvh/BVHLineGeometry.hxx>
-#include <simgear/scene/bvh/BVHStaticGeometry.hxx>
-#include <simgear/scene/bvh/BVHStaticData.hxx>
-#include <simgear/scene/bvh/BVHStaticNode.hxx>
-#include <simgear/scene/bvh/BVHStaticTriangle.hxx>
-#include <simgear/scene/bvh/BVHStaticBinary.hxx>
-#include <simgear/scene/bvh/BVHSubTreeCollector.hxx>
-#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
-#include <simgear/scene/bvh/BVHNearestPointVisitor.hxx>
+#include <simgear/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHGroup.hxx>
+#include <simgear/bvh/BVHTransform.hxx>
+#include <simgear/bvh/BVHMotionTransform.hxx>
+#include <simgear/bvh/BVHLineGeometry.hxx>
+#include <simgear/bvh/BVHStaticGeometry.hxx>
+#include <simgear/bvh/BVHStaticData.hxx>
+#include <simgear/bvh/BVHStaticNode.hxx>
+#include <simgear/bvh/BVHStaticTriangle.hxx>
+#include <simgear/bvh/BVHStaticBinary.hxx>
+#include <simgear/bvh/BVHSubTreeCollector.hxx>
+#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
+#include <simgear/bvh/BVHNearestPointVisitor.hxx>
#ifdef GROUNDCACHE_DEBUG
-#include <simgear/scene/bvh/BVHDebugCollectVisitor.hxx>
+#include <simgear/scene/model/BVHDebugCollectVisitor.hxx>
#include <Main/fg_props.hxx>
#endif
SGVec3d down = _down;
double radius = _radius;
bool haveHit = _haveHit;
- const SGMaterial* material = _material;
+ const simgear::BVHMaterial* material = _material;
_haveHit = false;
_center = toSG(inverseMatrix.preMult(toOsg(_center)));
{ return _haveHit; }
double getElevationBelowCache() const
{ return SGGeod::fromCart(_sceneryHit).getElevationM(); }
- const SGMaterial* getMaterialBelowCache() const
+ const simgear::BVHMaterial* getMaterialBelowCache() const
{ return _material; }
private:
simgear::BVHSubTreeCollector mSubTreeCollector;
SGVec3d _sceneryHit;
double _maxDown;
- const SGMaterial* _material;
+ const simgear::BVHMaterial* _material;
bool _haveHit;
};
if (!found_ground) {
// Ok, still nothing here?? Last resort ...
double alt = 0;
+ const SGMaterial* m = NULL;
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)
_altitude = alt;
}
return;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (_foundId)
+ return;
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (_foundId)
return;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (!intersects(_sphere, leaf.getBoundingSphere()))
+ return;
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (!intersects(_sphere, transform.getBoundingSphere()))
bool
FGGroundCache::get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel,
- simgear::BVHNode::Id& id, const SGMaterial*& material)
+ simgear::BVHNode::Id& id, const simgear::BVHMaterial*& material)
{
#ifdef GROUNDCACHE_DEBUG
SGTimeStamp t0 = SGTimeStamp::now();
FGGroundCache::get_nearest(double t, const SGVec3d& pt, double maxDist,
SGVec3d& contact, SGVec3d& linearVel,
SGVec3d& angularVel, simgear::BVHNode::Id& id,
- const SGMaterial*& material)
+ const simgear::BVHMaterial*& material)
{
if (!_localBvhTree)
return false;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (!_intersects(leaf.getBoundingSphere()))
+ return;
+
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (!_intersects(transform.getBoundingSphere()))
return;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (_haveLineSegment)
+ return;
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (_haveLineSegment)
#include <simgear/constants.h>
#include <simgear/math/SGMath.hxx>
#include <simgear/math/SGGeometry.hxx>
-#include <simgear/scene/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHNode.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
// #define GROUNDCACHE_DEBUG
#include <simgear/timing/timestamp.hxx>
#endif
-class SGMaterial;
namespace simgear {
class BVHLineGeometry;
+class BVHMaterial;
}
class FGGroundCache {
// 0 and 1 which can be used to model lower friction with wet runways.
bool get_agl(double t, const SGVec3d& pt, SGVec3d& contact,
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,
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.
// That test is done by checking if the quad spanned by the points pt*
// In case the aircraft is too high above ground.
double _altitude;
// the simgear material reference, contains friction coeficients ...
- const SGMaterial* _material;
+ const simgear::BVHMaterial* _material;
// The time reference for later call to intersection test routines.
// Is required since we will have moving triangles in carriers.
double cache_ref_time;
bool
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;
- if (_material) {
- const std::vector<std::string>& names = _material->get_names();
+ if (material) {
+ const std::vector<std::string>& names = material->get_names();
- _solid = _material->get_solid();
- _load_resistance = _material->get_load_resistance();
- _frictionFactor =_material->get_friction_factor();
- _bumpinessFactor = _material->get_bumpiness();
+ _solid = material->get_solid();
+ _load_resistance = material->get_load_resistance();
+ _frictionFactor = material->get_friction_factor();
+ _bumpinessFactor = material->get_bumpiness();
if (!names.empty())
- _mat_name = names[0].c_str();
+ _mat_name = names[0];
else
_mat_name = "";
double _elevation_m; // ground elevation in meters
bool _solid; // if true ground is solid for FDMs
- const SGMaterial* _material;
-
std::string _mat_name; // ground material
SGVec3d getCartUserPos() const;
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/model/CheckSceneryVisitor.hxx>
-#include <simgear/scene/bvh/BVHNode.hxx>
-#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
+#include <simgear/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
#include <Viewer/renderer.hxx>
#include <Main/fg_props.hxx>
{ return _haveHit; }
const SGLineSegmentd& getLineSegment() const
{ return _lineSegment; }
- const SGMaterial* getMaterial() const
+ const simgear::BVHMaterial* getMaterial() const
{ return _material; }
virtual void apply(osg::Node& node)
SGLineSegmentd lineSegment = _lineSegment;
bool haveHit = _haveHit;
- const SGMaterial* material = _material;
+ const simgear::BVHMaterial* material = _material;
_haveHit = false;
_lineSegment = lineSegment.transform(SGMatrixd(inverseMatrix.ptr()));
SGLineSegmentd _lineSegment;
const osg::Node* _skipNode;
- const SGMaterial* _material;
+ const simgear::BVHMaterial* _material;
bool _haveHit;
};
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
alt = geodEnd.getElevationM();
if (material)
- *material = intersectVisitor.getMaterial();
+ *material = dynamic_cast<const SGMaterial*>(intersectVisitor.getMaterial());
return true;
}
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/scene/material/matlib.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/SGSceneFeatures.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/scene/model/ModelRegistry.hxx>
#include <simgear/misc/ResourceManager.hxx>
-#include <simgear/scene/bvh/BVHNode.hxx>
-#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
-#include <simgear/scene/util/OsgMath.hxx>
+#include <simgear/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
class FGSceneryIntersect : public osg::NodeVisitor {
public: