Skip to content

Commit

Permalink
Merge pull request #3896 from AnalyticalGraphicsInc/terrain-exaggeration
Browse files Browse the repository at this point in the history
Fix terrain exaggeration bug
  • Loading branch information
mramato committed May 9, 2016
2 parents 5c23913 + 7f7d8e0 commit 0dbb960
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Change Log
* Fixed issue causing the fog to go dark and the atmosphere to flicker when the camera clips the globe. [#3178](https://github.com/AnalyticalGraphicsInc/cesium/issues/3178)
* Fixed a bug that caused an exception and rendering to stop when using `ArcGisMapServerImageryProvider` to connect to a MapServer specifying the Web Mercator projection and a fullExtent bigger than the valid extent of the projection. [#3854](https://github.com/AnalyticalGraphicsInc/cesium/pull/3854)
* Fixed issue causing an exception when switching scene modes with an active KML network link. [#3865](https://github.com/AnalyticalGraphicsInc/cesium/issues/3865)
* Fixed exaggerated terrain tiles disappearing. [#3676](https://github.com/AnalyticalGraphicsInc/cesium/issues/3676)

### 1.20 - 2016-04-01

Expand Down
42 changes: 0 additions & 42 deletions Source/Core/EllipsoidalOccluder.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,48 +238,6 @@ define([
return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
};

/**
* Computes a point that can be used for horizon culling from a list of positions. If the point is below
* the horizon, all of the positions are guaranteed to be below the horizon as well. The returned point
* is expressed in the ellipsoid-scaled space and is suitable for use with
* {@link EllipsoidalOccluder#isScaledSpacePointVisible}.
*
* @param {Cartesian3} directionToPoint The direction that the computed point will lie along.
* A reasonable direction to use is the direction from the center of the ellipsoid to
* the center of the bounding sphere computed from the positions. The direction need not
* be normalized.
* @param {Cartesian3[]} points The vertices from which to compute the horizon culling point. The positions
* must be expressed in a reference frame centered at the ellipsoid and aligned with the
* ellipsoid's axes.
* @param {Cartesian3} [result] The instance on which to store the result instead of allocating a new instance.
* @returns {Cartesian3} The computed horizon culling point, expressed in the ellipsoid-scaled space.
*/
EllipsoidalOccluder.prototype.computeHorizonCullingPointFromPoints = function(directionToPoint, points, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(directionToPoint)) {
throw new DeveloperError('directionToPoint is required');
}
if (!defined(points)) {
throw new DeveloperError('points is required');
}
//>>includeEnd('debug');

if (!defined(result)) {
result = new Cartesian3();
}

var ellipsoid = this._ellipsoid;
var scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(ellipsoid, directionToPoint);
var resultMagnitude = 0.0;

for (var i = 0, len = points.length; i < len; ++i) {
var candidateMagnitude = computeMagnitude(ellipsoid, points[i], scaledSpaceDirectionToPoint);
resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
}

return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
};

var subsampleScratch = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/HeightmapTessellator.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ define([
var center = options.relativetoCenter;
if (defined(center)) {
var occluder = new EllipsoidalOccluder(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromPoints(center, positions);
occludeePointInScaledSpace = occluder.computeHorizonCullingPoint(center, positions);
}

var aaBox = new AxisAlignedBoundingBox(minimum, maximum, relativeToCenter);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/QuantizedMeshTerrainData.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ define([
var maximumHeight = result.maximumHeight;
var boundingSphere = defaultValue(result.boundingSphere, that._boundingSphere);
var obb = defaultValue(result.orientedBoundingBox, that._orientedBoundingBox);
var occlusionPoint = defaultValue(result.occludeePointInScaledSpace, that._horizonOcclusionPoint);
var occlusionPoint = that._horizonOcclusionPoint;
var stride = result.vertexStride;
var terrainEncoding = TerrainEncoding.clone(result.encoding);

Expand Down
7 changes: 0 additions & 7 deletions Source/Workers/createVerticesFromQuantizedTerrainMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ define([
'../Core/Cartographic',
'../Core/defined',
'../Core/Ellipsoid',
'../Core/EllipsoidalOccluder',
'../Core/IndexDatatype',
'../Core/Math',
'../Core/Matrix3',
Expand All @@ -26,7 +25,6 @@ define([
Cartographic,
defined,
Ellipsoid,
EllipsoidalOccluder,
IndexDatatype,
CesiumMath,
Matrix3,
Expand Down Expand Up @@ -111,17 +109,13 @@ define([
Cartesian3.maximumByComponent(cartesian3Scratch, maximum, maximum);
}

var occludeePointInScaledSpace;
var orientedBoundingBox;
var boundingSphere;

if (exaggeration !== 1.0) {
// Bounding volumes and horizon culling point need to be recomputed since the tile payload assumes no exaggeration.
boundingSphere = BoundingSphere.fromPoints(positions);
orientedBoundingBox = OrientedBoundingBox.fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid);

var occluder = new EllipsoidalOccluder(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromPoints(center, positions);
}

var hMin = minimumHeight;
Expand Down Expand Up @@ -189,7 +183,6 @@ define([
maximumHeight : maximumHeight,
boundingSphere : boundingSphere,
orientedBoundingBox : orientedBoundingBox,
occludeePointInScaledSpace : occludeePointInScaledSpace,
encoding : encoding,
skirtIndex : parameters.indices.length
};
Expand Down
35 changes: 0 additions & 35 deletions Specs/Core/EllipsoidalOccluderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,41 +255,6 @@ defineSuite([
});
});

describe('computeHorizonCullingPointFromPoints', function() {
it('requires directionToPointand points', function() {
var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0);
var ellipsoidalOccluder = new EllipsoidalOccluder(ellipsoid);

var positions = [new Cartesian3(-12345.0, 12345.0, 12345.0), new Cartesian3(-12346.0, 12345.0, 12345.0), new Cartesian3(-12446.0, 12445.0, 12445.0)];
var boundingSphere = BoundingSphere.fromPoints(positions);

ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, positions);

expect(function() {
ellipsoidalOccluder.computeHorizonCullingPointFromPoints(undefined, positions);
}).toThrowDeveloperError();

expect(function() {
ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, undefined);
}).toThrowDeveloperError();
});

it('produces same answers as computeHorizonCullingPoint', function() {
var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0);
var ellipsoidalOccluder = new EllipsoidalOccluder(ellipsoid);

var positions = [new Cartesian3(-12345.0, 12345.0, 12345.0), new Cartesian3(-12346.0, 12345.0, 12345.0), new Cartesian3(-12446.0, 12445.0, 12445.0)];
var boundingSphere = BoundingSphere.fromPoints(positions);

var result1 = ellipsoidalOccluder.computeHorizonCullingPoint(boundingSphere.center, positions);
var result2 = ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, positions);

expect(result1.x).toEqualEpsilon(result2.x, CesiumMath.EPSILON14);
expect(result1.y).toEqualEpsilon(result2.y, CesiumMath.EPSILON14);
expect(result1.z).toEqualEpsilon(result2.z, CesiumMath.EPSILON14);
});
});

describe('computeHorizonCullingPointFromRectangle', function() {
it('returns undefined for global rectangle', function() {
var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0);
Expand Down

0 comments on commit 0dbb960

Please sign in to comment.