Skip to content

Commit

Permalink
Revert change to make distance to bounding sphere signed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed Apr 18, 2018
1 parent f5e7443 commit 0736999
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 1 addition & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ Change Log

### 1.45 - 2018-05-01

##### Breaking Changes :mega:
* `Camera.distanceToBoundingSphere` now returns the signed distance to the bounding sphere. Positive values indicate that the bounding sphere is in the positive half-plane of the camera position and view direction while a negative value indicates it is in the negative half-plane.

##### Additions :tada:
* Added option `logDepthBuffer` to `Viewer`. With this option there is typically a single frustum using logarithmic depth rendered. This increases performance by issuing less draw calls to the GPU and helps to avoid artifacts on the connection of two frustums. [#5851](https://github.com/AnalyticalGraphicsInc/cesium/pull/5851)
* When a log depth buffer is supported, the frustum near and far planes default to `0.1` and `1e10` respectively.
Expand All @@ -20,6 +17,7 @@ Change Log
* Fix Firefox WebGL console warnings. [#5912](https://github.com/AnalyticalGraphicsInc/cesium/issues/5912)
* Fix parsing Cesium.js in older browsers that do not support all TypedArray types. [#6396](https://github.com/AnalyticalGraphicsInc/cesium/pull/6396)
* Fix flicker when adding, removing, or modifiying entities. [#3945](https://github.com/AnalyticalGraphicsInc/cesium/issues/3945)

##### Additions :tada:
* Improved `MapboxImageryProvider` performance by 300% via `tiles.mapbox.com` subdomain switching. [#6426](https://github.com/AnalyticalGraphicsInc/cesium/issues/6426)

Expand Down
16 changes: 4 additions & 12 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -2574,13 +2574,10 @@ define([
var scratchProj = new Cartesian3();

/**
* Return the signed distance from the camera to the front of the bounding sphere.
* <p>
* Positive values indicate that the bounding sphere is in the positive half-plane of the camera position and view direction while a negative value indicates it is in the negative half-plane.
* </p>
* Return the distance from the camera to the front of the bounding sphere.
*
* @param {BoundingSphere} boundingSphere The bounding sphere in world coordinates.
* @returns {Number} The signed distance to the bounding sphere.
* @returns {Number} The distance to the bounding sphere.
*/
Camera.prototype.distanceToBoundingSphere = function(boundingSphere) {
//>>includeStart('debug', pragmas.debug);
Expand All @@ -2590,10 +2587,8 @@ define([
//>>includeEnd('debug');

var toCenter = Cartesian3.subtract(this.positionWC, boundingSphere.center, scratchToCenter);
var distance = -Cartesian3.dot(toCenter, this.directionWC);
var proj = Cartesian3.multiplyByScalar(this.directionWC, distance, scratchProj);
var unsignedDistance = Math.abs(Cartesian3.magnitude(proj) - boundingSphere.radius);
return distance < 0.0 ? -unsignedDistance : unsignedDistance;
var proj = Cartesian3.multiplyByScalar(this.directionWC, Cartesian3.dot(toCenter, this.directionWC), scratchProj);
return Math.max(0.0, Cartesian3.magnitude(proj) - boundingSphere.radius);
};

var scratchPixelSize = new Cartesian2();
Expand All @@ -2620,9 +2615,6 @@ define([
//>>includeEnd('debug');

var distance = this.distanceToBoundingSphere(boundingSphere);
if (distance < 0.0) {
return 0.0;
}
var pixelSize = this.frustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, scratchPixelSize);
return Math.max(pixelSize.x, pixelSize.y);
};
Expand Down

0 comments on commit 0736999

Please sign in to comment.