Reduce warning log spam in NaN position.
Try to catch NaN SGGeod position before we pass them to the intersect visitor, so we don’t fill the console/logs with error messages: we catch NaNs in other places.
This commit is contained in:
parent
083d364f9c
commit
c404bb6b37
1 changed files with 19 additions and 13 deletions
|
@ -296,6 +296,9 @@ FGStgTerrain::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
SGGeod geod = SGGeod::fromCart(pos);
|
SGGeod geod = SGGeod::fromCart(pos);
|
||||||
|
if (!geod.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
geod.setElevationM(geod.getElevationM() + max_altoff);
|
geod.setElevationM(geod.getElevationM() + max_altoff);
|
||||||
|
|
||||||
ok = get_elevation_m(geod, alt, material, butNotFrom);
|
ok = get_elevation_m(geod, alt, material, butNotFrom);
|
||||||
|
@ -308,23 +311,26 @@ FGStgTerrain::get_elevation_m(const SGGeod& geod, double& alt,
|
||||||
const simgear::BVHMaterial** material,
|
const simgear::BVHMaterial** material,
|
||||||
const osg::Node* butNotFrom)
|
const osg::Node* butNotFrom)
|
||||||
{
|
{
|
||||||
SGVec3d start = SGVec3d::fromGeod(geod);
|
if (!geod.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
SGGeod geodEnd = geod;
|
SGVec3d start = SGVec3d::fromGeod(geod);
|
||||||
geodEnd.setElevationM(SGMiscd::min(geod.getElevationM() - 10, -10000));
|
|
||||||
SGVec3d end = SGVec3d::fromGeod(geodEnd);
|
|
||||||
|
|
||||||
FGSceneryIntersect intersectVisitor(SGLineSegmentd(start, end), butNotFrom);
|
SGGeod geodEnd = geod;
|
||||||
intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT);
|
geodEnd.setElevationM(SGMiscd::min(geod.getElevationM() - 10, -10000));
|
||||||
terrain_branch->accept(intersectVisitor);
|
SGVec3d end = SGVec3d::fromGeod(geodEnd);
|
||||||
|
|
||||||
if (!intersectVisitor.getHaveHit())
|
FGSceneryIntersect intersectVisitor(SGLineSegmentd(start, end), butNotFrom);
|
||||||
return false;
|
intersectVisitor.setTraversalMask(SG_NODEMASK_TERRAIN_BIT);
|
||||||
|
terrain_branch->accept(intersectVisitor);
|
||||||
|
|
||||||
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
|
if (!intersectVisitor.getHaveHit())
|
||||||
alt = geodEnd.getElevationM();
|
return false;
|
||||||
if (material) {
|
|
||||||
*material = intersectVisitor.getMaterial();
|
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
|
||||||
|
alt = geodEnd.getElevationM();
|
||||||
|
if (material) {
|
||||||
|
*material = intersectVisitor.getMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue