Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into exaggerated-normals
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed May 10, 2016
2 parents e25b2ce + c976592 commit e0b8800
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 97 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Change Log
* Deprecated
*
* Improved KML NetworkLink compatibility by supporting the `Url` tag. [#3895](https://github.com/AnalyticalGraphicsInc/cesium/pull/3895).
* Fixed exaggerated terrain tiles disappearing. [#3676](https://github.com/AnalyticalGraphicsInc/cesium/issues/3676)
* Fixed infinite horizontal 2D scrolling in IE/Edge. [#3893](https://github.com/AnalyticalGraphicsInc/cesium/issues/3893)
* Fixed a bug that could cause incorrect normals to be computed for exaggerated terrain, especially for low-detail tiles. [#3904](https://github.com/AnalyticalGraphicsInc/cesium/pull/3904)

### 1.21 - 2016-05-02
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
21 changes: 12 additions & 9 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1763,37 +1763,40 @@ define([
} else if (windowCoordinates.x > context.drawingBufferWidth * 0.5) {
viewport.width = windowCoordinates.x;

var right = camera.frustum.right;
camera.frustum.right = maxCoord.x - x;

executeCommandsInViewport(true, scene, passState, backgroundColor, picking);

viewport.x += windowCoordinates.x;
viewport.width = context.drawingBufferWidth - windowCoordinates.x;

camera.position.x = -camera.position.x;

var right = camera.frustum.right;
camera.frustum.right = -camera.frustum.left;
camera.frustum.left = -right;
camera.frustum.left = -camera.frustum.right;
camera.frustum.right = camera.frustum.left + (right - camera.frustum.right);

frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC);
context.uniformState.update(frameState);

executeCommandsInViewport(false, scene, passState, backgroundColor, picking);
} else {
viewport.x += windowCoordinates.x;
viewport.width -= windowCoordinates.x;
viewport.x = windowCoordinates.x;
viewport.width = context.drawingBufferWidth - windowCoordinates.x;

var left = camera.frustum.left;
camera.frustum.left = -maxCoord.x - x;

executeCommandsInViewport(true, scene, passState, backgroundColor, picking);

viewport.x = viewport.x - viewport.width;
viewport.x = 0;
viewport.width = windowCoordinates.x;

camera.position.x = -camera.position.x;

var left = camera.frustum.left;
camera.frustum.left = -camera.frustum.right;
camera.frustum.right = -left;
camera.frustum.right = -camera.frustum.left;
camera.frustum.left = camera.frustum.right + (left - camera.frustum.left);


frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC);
context.uniformState.update(frameState);
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Sun.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ define([
this._glowFactorDirty = false;

var size = Math.max(drawingBufferWidth, drawingBufferHeight);
size = Math.pow(2.0, Math.ceil(Math.log(size) / Math.log(2.0)) - 2.0);
size = Math.max(1.0, Math.pow(2.0, Math.ceil(Math.log(size) / Math.log(2.0)) - 2.0));

this._texture = new Texture({
context : context,
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/SunPostProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ define([

var downSampleWidth = Math.pow(2.0, Math.ceil(Math.log(width) / Math.log(2)) - 2.0);
var downSampleHeight = Math.pow(2.0, Math.ceil(Math.log(height) / Math.log(2)) - 2.0);
var downSampleSize = Math.max(downSampleWidth, downSampleHeight);
var downSampleSize = Math.max(1.0, Math.max(downSampleWidth, downSampleHeight));

var downSampleViewport = downSampleViewportBoundingRectangle;
downSampleViewport.width = downSampleSize;
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 e0b8800

Please sign in to comment.