From 21474ca0c16122dc752172195fcbb919c2b35de1 Mon Sep 17 00:00:00 2001 From: slozier Date: Wed, 11 Nov 2015 13:41:06 -0500 Subject: [PATCH 1/2] Resolve issue #3170 --- CHANGES.md | 1 + Source/Core/EllipsoidalOccluder.js | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7fd323d2d70a..f8cbd94b685e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Change Log * Added support for fog near the horizon, which improves performance by rendering less terrain tiles and reduces terrain tile requests. This is enabled by default. See `Scene.fog` for options. [#3154](https://github.com/AnalyticalGraphicsInc/cesium/pull/3154) * Added `Queue.peek` to return the item at the front of a Queue. * Added `Camera.distanceToBoundingSphere` function. +* 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; }; From 3be42017ca8cf3ca9380b6435be5f9dd37c672fd Mon Sep 17 00:00:00 2001 From: slozier Date: Wed, 11 Nov 2015 16:12:16 -0500 Subject: [PATCH 2/2] Add test for issue #3170 --- Specs/Core/EllipsoidalOccluderSpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Specs/Core/EllipsoidalOccluderSpec.js b/Specs/Core/EllipsoidalOccluderSpec.js index 000f4f643cef..b4c7e6fedf62 100644 --- a/Specs/Core/EllipsoidalOccluderSpec.js +++ b/Specs/Core/EllipsoidalOccluderSpec.js @@ -59,6 +59,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);