FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BasicDragger terrain regression fix by mbudk · Pull Request #20 · NASAWorldWind/WorldWindJava · GitHub

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
31 changes: 25 additions & 6 deletions src/gov/nasa/worldwind/util/BasicDragger.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ else if (dragObject instanceof Movable)
if (refPos == null)
return;

Vec4 refPoint = globe.computePointFromPosition(refPos);
Vec4 refPoint = null;
if (this.isUseTerrain() && refPos.getElevation() < globe.getMaxElevation())
refPoint = wwd.getSceneController().getTerrain().getSurfacePoint(refPos);
if (refPoint == null)
refPoint = globe.computePointFromPosition(refPos);

if (!this.isDragging()) // Dragging started
{
Expand All @@ -122,10 +126,25 @@ else if (dragObject instanceof Movable)
double y = event.getMouseEvent().getComponent().getSize().height - this.dragRefObjectPoint.y + dy - 1;
Line ray = view.computeRayFromScreenPoint(x, y);
Position pickPos = null;
// Use intersection with sphere at reference altitude.
Intersection inters[] = globe.intersect(ray, this.dragRefAltitude);
if (inters != null)
pickPos = globe.computePositionFromPoint(inters[0].getIntersectionPoint());
if (this.isUseTerrain() && view.getEyePosition().getElevation() < globe.getMaxElevation() * 10)
{
// Use ray casting below some altitude
// Try ray intersection with current terrain geometry
Intersection[] intersections = wwd.getSceneController().getTerrain().intersect(ray);
if (intersections != null && intersections.length > 0)
pickPos = globe.computePositionFromPoint(intersections[0].getIntersectionPoint());
else
// Fallback on raycasting using elevation data
pickPos = RayCastingSupport.intersectRayWithTerrain(globe, ray.getOrigin(), ray.getDirection(),
200, 20);
}
if (pickPos == null)
{
// Use intersection with sphere at reference altitude.
Intersection inters[] = globe.intersect(ray, this.dragRefAltitude);
if (inters != null)
pickPos = globe.computePositionFromPoint(inters[0].getIntersectionPoint());
}

if (pickPos != null)
{
Expand All @@ -141,4 +160,4 @@ else if (dragObject instanceof Movable)
event.consume();
}
}
}
}

Back | FazBrowse Home | New Git URL