Skip to content

Commit

Permalink
Merge branch 'master' into shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed May 13, 2016
2 parents 5240533 + a5de1e1 commit ccda0e0
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 66 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Change Log
* Deprecated
*
* Improved KML NetworkLink compatibility by supporting the `Url` tag. [#3895](https://github.com/AnalyticalGraphicsInc/cesium/pull/3895).
* Improve memory management for entity billboard/label/point/path visualization.
* 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)
* Fixed a bug that was causing errors to be thrown when picking and terrain was enabled. [#3779](https://github.com/AnalyticalGraphicsInc/cesium/issues/3779)
* Fixed issue where labels were disappearing. [3730](https://github.com/AnalyticalGraphicsInc/cesium/issues/3730)
* Added `CullingVolume.fromBoundingSphere`.

### 1.21 - 2016-05-02

Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/BillboardVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ define([
if (defined(billboard)) {
item.textureValue = undefined;
item.billboard = undefined;
billboard.id = undefined;
billboard.show = false;
billboard.image = undefined;
unusedIndexes.push(billboard._index);
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/LabelVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ define([
var label = item.label;
if (defined(label)) {
unusedIndexes.push(item.index);
label.id = undefined;
label.show = false;
item.label = undefined;
item.index = -1;
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/PathVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ define([
this._unusedIndexes.push(item.index);
item.polyline = undefined;
polyline.show = false;
polyline.id = undefined;
item.index = undefined;
}
};
Expand Down
1 change: 1 addition & 0 deletions Source/DataSources/PointVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ define([
var pointPrimitive = item.pointPrimitive;
if (defined(pointPrimitive)) {
item.pointPrimitive = undefined;
pointPrimitive.id = undefined;
pointPrimitive.show = false;
unusedIndexes.push(pointPrimitive._index);
}
Expand Down
75 changes: 74 additions & 1 deletion Source/Scene/CullingVolume.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/*global define*/
define([
'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/defaultValue',
'../Core/defined',
'../Core/DeveloperError',
'../Core/Intersect',
'../Core/Plane'
], function(
Cartesian3,
Cartesian4,
defaultValue,
defined,
DeveloperError,
Expand All @@ -21,7 +23,7 @@ define([
* @alias CullingVolume
* @constructor
*
* @param {Cartesian4[]} planes An array of clipping planes.
* @param {Cartesian4[]} [planes] An array of clipping planes.
*/
function CullingVolume(planes) {
/**
Expand All @@ -34,7 +36,78 @@ define([
this.planes = defaultValue(planes, []);
}

var faces = [new Cartesian3(), new Cartesian3(), new Cartesian3()];
Cartesian3.clone(Cartesian3.UNIT_X, faces[0]);
Cartesian3.clone(Cartesian3.UNIT_Y, faces[1]);
Cartesian3.clone(Cartesian3.UNIT_Z, faces[2]);

var scratchPlaneCenter = new Cartesian3();
var scratchPlaneNormal = new Cartesian3();
var scratchPlane = new Plane(new Cartesian3(), 0.0);

/**
* Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
* The planes are aligned to the x, y, and z axes in world coordinates.
*
* @param {BoundingSphere} boundingSphere The bounding sphere used to create the culling volume.
* @param {CullingVolume} [result] The object onto which to store the result.
* @returns {CullingVolume} The culling volume created from the bounding sphere.
*/
CullingVolume.fromBoundingSphere = function(boundingSphere, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(boundingSphere)) {
throw new DeveloperError('boundingSphere is required.');
}
//>>includeEnd('debug');

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

var length = faces.length;
var planes = result.planes;
planes.length = 2 * length;

var center = boundingSphere.center;
var radius = boundingSphere.radius;

var planeIndex = 0;

for (var i = 0; i < length; ++i) {
var faceNormal = faces[i];

var plane0 = planes[planeIndex];
var plane1 = planes[planeIndex + 1];

if (!defined(plane0)) {
plane0 = planes[planeIndex] = new Cartesian4();
}
if (!defined(plane1)) {
plane1 = planes[planeIndex + 1] = new Cartesian4();
}

Cartesian3.multiplyByScalar(faceNormal, -radius, scratchPlaneCenter);
Cartesian3.add(center, scratchPlaneCenter, scratchPlaneCenter);

plane0.x = faceNormal.x;
plane0.y = faceNormal.y;
plane0.z = faceNormal.z;
plane0.w = -Cartesian3.dot(faceNormal, scratchPlaneCenter);

Cartesian3.multiplyByScalar(faceNormal, radius, scratchPlaneCenter);
Cartesian3.add(center, scratchPlaneCenter, scratchPlaneCenter);

plane1.x = -faceNormal.x;
plane1.y = -faceNormal.y;
plane1.z = -faceNormal.z;
plane1.w = -Cartesian3.dot(Cartesian3.negate(faceNormal, scratchPlaneNormal), scratchPlaneCenter);

planeIndex += 2;
}

return result;
};

/**
* Determines whether a bounding volume intersects the culling volume.
*
Expand Down
1 change: 1 addition & 0 deletions Specs/DataSources/BillboardVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ defineSuite([
//internal cache used by the visualizer, instead it just hides it.
entityCollection.removeAll();
expect(bb.show).toEqual(false);
expect(bb.id).toBeUndefined();
});
});

Expand Down
1 change: 1 addition & 0 deletions Specs/DataSources/LabelVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ defineSuite([
entityCollection.removeAll();
visualizer.update(time);
expect(l.show).toEqual(false);
expect(l.id).toBeUndefined();
});

it('Visualizer sets entity property.', function() {
Expand Down
1 change: 1 addition & 0 deletions Specs/DataSources/PathVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ defineSuite([
//internal cache used by the visualizer, instead it just hides it.
entityCollection.removeAll();
expect(primitive.show).toEqual(false);
expect(primitive.id).toBeUndefined();
});

it('Visualizer sets entity property.', function() {
Expand Down
1 change: 1 addition & 0 deletions Specs/DataSources/PointVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ defineSuite([
//internal cache used by the visualizer, instead it just hides it.
entityCollection.removeAll();
expect(bb.show).toEqual(false);
expect(bb.id).toBeUndefined();
});

it('Visualizer sets entity property.', function() {
Expand Down
Loading

0 comments on commit ccda0e0

Please sign in to comment.