Correct logic to determine if we really have a hit.
Modified Files: src/Scenery/scenery.cxx
This commit is contained in:
parent
cb10d714fd
commit
93d2f8a963
1 changed files with 6 additions and 4 deletions
|
@ -146,8 +146,8 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
|
||||||
lineSegment = new osg::LineSegment(start.osg(), end.osg());
|
lineSegment = new osg::LineSegment(start.osg(), end.osg());
|
||||||
intersectVisitor.addLineSegment(lineSegment.get());
|
intersectVisitor.addLineSegment(lineSegment.get());
|
||||||
get_scene_graph()->accept(intersectVisitor);
|
get_scene_graph()->accept(intersectVisitor);
|
||||||
bool hits = intersectVisitor.hits();
|
bool hits = false;
|
||||||
if (hits) {
|
if (intersectVisitor.hits()) {
|
||||||
int nHits = intersectVisitor.getNumHits(lineSegment.get());
|
int nHits = intersectVisitor.getNumHits(lineSegment.get());
|
||||||
alt = -SGLimitsd::max();
|
alt = -SGLimitsd::max();
|
||||||
for (int i = 0; i < nHits; ++i) {
|
for (int i = 0; i < nHits; ++i) {
|
||||||
|
@ -163,6 +163,7 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
|
||||||
double elevation = geod.getElevationM();
|
double elevation = geod.getElevationM();
|
||||||
if (alt < elevation) {
|
if (alt < elevation) {
|
||||||
alt = elevation;
|
alt = elevation;
|
||||||
|
hits = true;
|
||||||
if (material) {
|
if (material) {
|
||||||
*material = 0;
|
*material = 0;
|
||||||
const EffectGeode* eg
|
const EffectGeode* eg
|
||||||
|
@ -197,8 +198,8 @@ FGScenery::get_cart_ground_intersection(const SGVec3d& pos, const SGVec3d& dir,
|
||||||
lineSegment = new osg::LineSegment(start.osg(), end.osg());
|
lineSegment = new osg::LineSegment(start.osg(), end.osg());
|
||||||
intersectVisitor.addLineSegment(lineSegment.get());
|
intersectVisitor.addLineSegment(lineSegment.get());
|
||||||
get_scene_graph()->accept(intersectVisitor);
|
get_scene_graph()->accept(intersectVisitor);
|
||||||
bool hits = intersectVisitor.hits();
|
bool hits = false;
|
||||||
if (hits) {
|
if (intersectVisitor.hits()) {
|
||||||
int nHits = intersectVisitor.getNumHits(lineSegment.get());
|
int nHits = intersectVisitor.getNumHits(lineSegment.get());
|
||||||
double dist = SGLimitsd::max();
|
double dist = SGLimitsd::max();
|
||||||
for (int i = 0; i < nHits; ++i) {
|
for (int i = 0; i < nHits; ++i) {
|
||||||
|
@ -214,6 +215,7 @@ FGScenery::get_cart_ground_intersection(const SGVec3d& pos, const SGVec3d& dir,
|
||||||
if (newdist < dist) {
|
if (newdist < dist) {
|
||||||
dist = newdist;
|
dist = newdist;
|
||||||
nearestHit = point;
|
nearestHit = point;
|
||||||
|
hits = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue