Skip to content

Commit

Permalink
Merge pull request #3223 from AnalyticalGraphicsInc/issue3170
Browse files Browse the repository at this point in the history
Resolve issue #3170
  • Loading branch information
bagnell committed Nov 19, 2015
2 parents 2dbd51e + 57f6cd7 commit 80db8d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Change Log
* Added `VideoSynchronizer` helper object for keeping an `HTMLVideoElement` in sync with a scene's clock.
* Added 'Video' Sandcastle showcase to demonstrate video materials.
* Added `createOpenStreetMapImageryProvider` function to replace the `OpenStreetMapImageryProvider` class. This function returns a constructed `UrlTemplateImageryProvider`.
* Fixed an issue with tile selection when below the surface of the ellipsoid. [#3170](https://github.com/AnalyticalGraphicsInc/cesium/issues/3170)

### 1.15 - 2015-11-02

Expand Down
11 changes: 4 additions & 7 deletions Source/Core/EllipsoidalOccluder.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,15 @@ define([
* occluder.isScaledSpacePointVisible(scaledSpacePoint); //returns true
*/
EllipsoidalOccluder.prototype.isScaledSpacePointVisible = function(occludeeScaledSpacePosition) {
// Disable occlusion culling when the viewer is under the ellipsoid to avoid false occulsion.
if (this._distanceToLimbInScaledSpaceSquared < 0.0) {
return true;
}

// See http://cesiumjs.org/2013/04/25/Horizon-culling/
var cv = this._cameraPositionInScaledSpace;
var vhMagnitudeSquared = this._distanceToLimbInScaledSpaceSquared;
var vt = Cartesian3.subtract(occludeeScaledSpacePosition, cv, scratchCartesian);
var vtDotVc = -Cartesian3.dot(vt, cv);
var isOccluded = vtDotVc > vhMagnitudeSquared &&
vtDotVc * vtDotVc / Cartesian3.magnitudeSquared(vt) > vhMagnitudeSquared;
// If vhMagnitudeSquared < 0 then we are below the surface of the ellipsoid and
// in this case, set the culling plane to be on V.
var isOccluded = vhMagnitudeSquared < 0 ? vtDotVc > 0 : (vtDotVc > vhMagnitudeSquared &&
vtDotVc * vtDotVc / Cartesian3.magnitudeSquared(vt) > vhMagnitudeSquared);
return !isOccluded;
};

Expand Down
9 changes: 9 additions & 0 deletions Specs/Core/EllipsoidalOccluderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ defineSuite([
expect(occluder.isPointVisible(point)).toEqual(false);
});

it('reports not visible when point is directly behind ellipsoid and camera is inside the ellispoid', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
occluder.cameraPosition = new Cartesian3(ellipsoid.minimumRadius - 100, 0.0, 0.0);

var point = new Cartesian3(-7000000, 0.0, 0.0);
expect(occluder.isPointVisible(point)).toEqual(false);
});

it('reports visible when point is in front of ellipsoid', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
Expand Down

0 comments on commit 80db8d7

Please sign in to comment.