diff --git a/CHANGES.md b/CHANGES.md index 17e20466fe44..d73f00e02aee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/Source/Core/EllipsoidalOccluder.js b/Source/Core/EllipsoidalOccluder.js index e561ab05fafa..352142a880f7 100644 --- a/Source/Core/EllipsoidalOccluder.js +++ b/Source/Core/EllipsoidalOccluder.js @@ -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; }; diff --git a/Specs/Core/EllipsoidalOccluderSpec.js b/Specs/Core/EllipsoidalOccluderSpec.js index f7a3524ffde8..4c0e8f2b1adc 100644 --- a/Specs/Core/EllipsoidalOccluderSpec.js +++ b/Specs/Core/EllipsoidalOccluderSpec.js @@ -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);