-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oriented bounding box & frustum culling optimizations #2782
Changes from all commits
dfebc12
2e81e95
f2800c4
4d686ee
33a16c2
0195ffa
69a9ab7
3e68548
09a847b
3f1a58e
931aa62
d46b526
4408e9f
bc1c9e6
c1c6a66
1c23c4b
fc0ab82
3604485
d908de2
58d06b9
6510aff
3da7263
e183089
8148cc1
2f520c6
fb64614
0a712f6
1cd0747
85fc36c
d6a7389
37ae29a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,11 @@ Change Log | |
========== | ||
|
||
### 1.11 - 2015-07-01 | ||
|
||
* Deprecated | ||
* The STK World Terrain url `cesiumjs.org/stk-terrain/world` has been deprecated, use `assets.agi.com/stk-terrain/world` instead. A redirect will be in place until 1.14. | ||
* Deprecated `AxisAlignedBoundingBox.intersect` and `BoundingSphere.intersect`. These will be removed in 1.13. Use `.intersectPlane` and, if necessary, `Plane.fromCartesian4`. | ||
* Deprecated the `ObjectOrientedBoundingBox` class. It will be removed in 1.12. Use `OrientedBoundingBox` instead. | ||
* Improved the algorithm that `Camera.viewRectangle` uses to select the position of the camera, so that the specified rectangle is now better centered on the screen [#2764](https://github.com/AnalyticalGraphicsInc/cesium/issues/2764). | ||
* The performance statistics displayed by setting `scene.debugShowFramesPerSecond` to `true` can now be styled using the `cesium-performanceDisplay` CSS classes in `shared.css` [#2779](https://github.com/AnalyticalGraphicsInc/cesium/issues/2779). | ||
* Fixed a crash when `viewer.zoomTo` or `viewer.flyTo` were called immediately before or during a scene morph [#2775](https://github.com/AnalyticalGraphicsInc/cesium/issues/2775). | ||
|
@@ -14,6 +17,17 @@ Change Log | |
* The camera now zooms to the point under the mouse cursor. | ||
* Fixed a bug in `ImageryLayer` that could cause an exception and the render loop to stop when the base layer did not cover the entire globe. | ||
* Fixed flash/streak rendering artifacts when picking [#2790](https://github.com/AnalyticalGraphicsInc/cesium/issues/2790), [#2811](https://github.com/AnalyticalGraphicsInc/cesium/issues/2811). | ||
* Added `Plane.fromCartesian4` to convert old `Cartesian4` plane representations to the new `Plane` format. | ||
* Added `Plane.ORIGIN_XY_PLANE`/`ORIGIN_YZ_PLANE`/`ORIGIN_ZX_PLANE` constants for commonly-used planes. | ||
* Added `Matrix2`/`Matrix3`/`Matrix4.ZERO` constants for zero matrices. | ||
* Added `Matrix2`/`Matrix3.multiplyByScale` for multiplying against non-uniform scales. | ||
* Added `projectPointToNearestOnPlane` and `projectPointsToNearestOnPlane` to `EllipsoidTangentPlane` to project 3D points to the nearest 2D point on an `EllipsoidTangentPlane`. | ||
* Added `OrientedBoundingBox` class. | ||
* Added `EllipsoidTangentPlane.plane` property to get the `Plane` for the tangent plane. | ||
* Added `EllipsoidTangentPlane.xAxis`/`yAxis`/`zAxis` properties to get the local coordinate system of the tangent plane. | ||
* Add `QuantizedMeshTerrainData` constructor argument `orientedBoundingBox`. | ||
* Add `TerrainMesh.orientedBoundingBox` which holds the `OrientedBoundingBox` for the mesh for a single terrain tile. | ||
* Use `OrientedBoundingBox` when rendering terrain and imagery to improve performance of rendering and loading (by up to 50% of terrain/imagery tiles, depending on camera view). | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it's new, add a line like "Added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for any other new functions or objects you added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I do that for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they are basically the same, (and you already mentioned it in the deprecated section) then it's probably just noise for less-used functions like this. If it were a popular part of the API, I would have said otherwise. |
||
### 1.10 - 2015-06-01 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,18 @@ define([ | |
'./Cartesian3', | ||
'./defaultValue', | ||
'./defined', | ||
'./deprecationWarning', | ||
'./DeveloperError', | ||
'./Intersect' | ||
'./Intersect', | ||
'./Plane' | ||
], function( | ||
Cartesian3, | ||
defaultValue, | ||
defined, | ||
deprecationWarning, | ||
DeveloperError, | ||
Intersect) { | ||
Intersect, | ||
Plane) { | ||
"use strict"; | ||
|
||
/** | ||
|
@@ -162,15 +166,13 @@ define([ | |
* Determines which side of a plane a box is located. | ||
* | ||
* @param {AxisAlignedBoundingBox} box The bounding box to test. | ||
* @param {Cartesian4} plane The coefficients of the plane in the form <code>ax + by + cz + d = 0</code> | ||
* where the coefficients a, b, c, and d are the components x, y, z, and w | ||
* of the {@link Cartesian4}, respectively. | ||
* @param {Plane} plane The plane to test against. | ||
* @returns {Intersect} {@link Intersect.INSIDE} if the entire box is on the side of the plane | ||
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire box is | ||
* on the opposite side, and {@link Intersect.INTERSECTING} if the box | ||
* intersects the plane. | ||
*/ | ||
AxisAlignedBoundingBox.intersect = function(box, plane) { | ||
AxisAlignedBoundingBox.intersectPlane = function(box, plane) { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(box)) { | ||
throw new DeveloperError('box is required.'); | ||
|
@@ -182,8 +184,9 @@ define([ | |
|
||
intersectScratch = Cartesian3.subtract(box.maximum, box.minimum, intersectScratch); | ||
var h = Cartesian3.multiplyByScalar(intersectScratch, 0.5, intersectScratch); //The positive half diagonal | ||
var e = h.x * Math.abs(plane.x) + h.y * Math.abs(plane.y) + h.z * Math.abs(plane.z); | ||
var s = Cartesian3.dot(box.center, plane) + plane.w; //signed distance from center | ||
var normal = plane.normal; | ||
var e = h.x * Math.abs(normal.x) + h.y * Math.abs(normal.y) + h.z * Math.abs(normal.z); | ||
var s = Cartesian3.dot(box.center, normal) + plane.distance; //signed distance from center | ||
|
||
if (s - e > 0) { | ||
return Intersect.INSIDE; | ||
|
@@ -197,6 +200,26 @@ define([ | |
return Intersect.INTERSECTING; | ||
}; | ||
|
||
var scratchPlane = new Plane(new Cartesian3(), 0.0); | ||
/** | ||
* Determines which side of a plane a box is located. | ||
* | ||
* @deprecated | ||
* @param {AxisAlignedBoundingBox} box The bounding box to test. | ||
* @param {Cartesian4} plane The coefficients of the plane in the form <code>ax + by + cz + d = 0</code> | ||
* where the coefficients a, b, c, and d are the components x, y, z, and w | ||
* of the {@link Cartesian4}, respectively. | ||
* @returns {Intersect} {@link Intersect.INSIDE} if the entire box is on the side of the plane | ||
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire box is | ||
* on the opposite side, and {@link Intersect.INTERSECTING} if the box | ||
* intersects the plane. | ||
*/ | ||
AxisAlignedBoundingBox.intersect = function(box, plane) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Same comment throughout for anything else that is deprecated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I forgot about that. Since AABB.prototype.intersect calls AABB.intersect, should I only add it in AABB.intersect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is fine for this case. |
||
deprecationWarning('AxisAlignedBoundingBox.intersect', 'AxisAlignedBoundingBox.intersect() was deprecated in Cesium 1.11. It will be removed in 1.12. Use AxisAlignedBoundingBox.intersectPlane() instead.'); | ||
var p = Plane.fromCartesian4(plane, scratchPlane); | ||
return AxisAlignedBoundingBox.intersectPlane(box, p); | ||
}; | ||
|
||
/** | ||
* Duplicates this AxisAlignedBoundingBox instance. | ||
* | ||
|
@@ -210,6 +233,20 @@ define([ | |
/** | ||
* Determines which side of a plane this box is located. | ||
* | ||
* @param {Plane} plane The plane to test against. | ||
* @returns {Intersect} {@link Intersect.INSIDE} if the entire box is on the side of the plane | ||
* the normal is pointing, {@link Intersect.OUTSIDE} if the entire box is | ||
* on the opposite side, and {@link Intersect.INTERSECTING} if the box | ||
* intersects the plane. | ||
*/ | ||
AxisAlignedBoundingBox.prototype.intersectPlane = function(plane) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On core math types, we usually only have prototype versions of functions for things like Do we need this? Is this because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, intersectPlane is being used polymorphically in the frustum plane tests. |
||
return AxisAlignedBoundingBox.intersectPlane(this, plane); | ||
}; | ||
|
||
/** | ||
* Determines which side of a plane this box is located. | ||
* | ||
* @deprecated | ||
* @param {Cartesian4} plane The coefficients of the plane in the form <code>ax + by + cz + d = 0</code> | ||
* where the coefficients a, b, c, and d are the components x, y, z, and w | ||
* of the {@link Cartesian4}, respectively. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please submit an issue for this and another for the OOBB class (for example, see #2724).