-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Increase max clipping planes using textures #6201
Changes from 1 commit
0317622
44a2662
3f40dc2
4b7b0ea
15e3a1e
a0a9706
a5e6ff4
a42261a
5d3165e
e2fb890
cf1b6da
f7d078e
8ba4a65
d484bb3
c917871
b61f98f
c699d4b
2ccd989
fb69f6a
f5512d1
c0a71de
e19299a
ff3f4a5
ea2d45a
5d953b5
2ec99dc
828a9d1
fdca291
f9293e4
e20d1ec
c3c10f0
bc8b313
983585e
a05c225
4e705de
5185523
0f04e46
31c548b
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 |
---|---|---|
|
@@ -3,6 +3,9 @@ Change Log | |
|
||
### 1.43 - 2018-03-01 | ||
|
||
##### Deprecated :hourglass_flowing_sand: | ||
* `ClippingPlaneCollection` is now supported in Internet Explorer, so `ClippingPlaneCollection.isSupported` always returns `true`. [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201) | ||
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. Mention that the deprecated function will be removed in 1.43. |
||
|
||
##### Additions :tada: | ||
* Added support for a promise to a resource for `CesiumTerrainProvider`, `createTileMapServiceImageryProvider` and `Cesium3DTileset` [#6204](https://github.com/AnalyticalGraphicsInc/cesium/pull/6204) | ||
|
||
|
@@ -15,7 +18,7 @@ Change Log | |
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198) | ||
|
||
##### Additions :tada: | ||
* Increased maximum number of clipping planes from 6 to 2048, added support for Internet Explorer, and removed `ClippingPlaneCollection.isSupported`. [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201) | ||
* Increased maximum number of clipping planes from 6 to 2048, added support for Internet Explorer. [#6201](https://github.com/AnalyticalGraphicsInc/cesium/pull/6201) | ||
|
||
### 1.42.1 - 2018-02-01 | ||
_This is an npm-only release to fix an issue with using Cesium in Node.js.__ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ define([ | |
|
||
/** | ||
* Specifies a set of clipping planes. Clipping planes selectively disable rendering in a region on the | ||
* outside of the specified list of {@link Plane} objects. | ||
* outside of the specified list of {@link Plane} objects for a single gltf model, 3D Tileset, or the globe. | ||
* | ||
* @alias ClippingPlaneCollection | ||
* @constructor | ||
|
@@ -107,20 +107,21 @@ define([ | |
this.edgeWidth = defaultValue(options.edgeWidth, 0.0); | ||
|
||
/** | ||
* If this ClippingPlaneCollection has an owner, only its owner can destroy it using checkDestroy(object) | ||
* If this ClippingPlaneCollection has an owner, only its owner should update or destroy it. | ||
* This is because in a Cesium3DTileset multiple models may reference the tileset's ClippingPlaneCollection. | ||
* @private | ||
* | ||
* @type {Object} | ||
* @default undefined | ||
*/ | ||
this.owner = undefined; | ||
this._owner = undefined; | ||
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 an underscored variable you can remove the doc but leave the comment. 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. The indentation of the comment is slightly off. |
||
|
||
this._testIntersection = undefined; | ||
this._unionClippingRegions = undefined; | ||
this.unionClippingRegions = defaultValue(options.unionClippingRegions, false); | ||
|
||
// Avoid wastefully re-uploading textures when the clipping planes don't change between frames | ||
var previousTextureBytes = new ArrayBuffer(ClippingPlaneCollection.TEXTURE_WIDTH * ClippingPlaneCollection.TEXTURE_WIDTH * 4); | ||
previousTextureBytes[0] = 1; | ||
var currentTextureBytes = new ArrayBuffer(ClippingPlaneCollection.TEXTURE_WIDTH * ClippingPlaneCollection.TEXTURE_WIDTH * 4); | ||
|
||
this._textureBytes = new Uint8Array(currentTextureBytes); | ||
|
@@ -129,9 +130,6 @@ define([ | |
this._previousUint32View = new Uint32Array(previousTextureBytes); | ||
this._currentUint32View = new Uint32Array(currentTextureBytes); | ||
|
||
// Avoid wasteful re-upload checks within a frame when a ClippingPlaneCollection is shared by many Models in a Cesium3DTileset | ||
this._planeTextureDirty = true; | ||
|
||
this._clippingPlanesTexture = undefined; | ||
|
||
// Packed uniform for plane count, denormalization parameters, and clipping union (0 false, 1 true) | ||
|
@@ -353,9 +351,10 @@ define([ | |
} | ||
|
||
var octEncodeScratch = new Cartesian2(); | ||
var rightShift = 1.0 / 256; | ||
var rightShift = 1.0 / 256.0; | ||
/** | ||
* Encodes a normalized vector into 4 SNORM values in the range [0-255] following the 'oct' encoding. | ||
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 the comment be [0-65535]? 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. It's two 16-bit values spread out over 4 8-bit values. I was following the convention in
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. It's storing 4 values for precision purposes right? You might want to note that in the comment. |
||
* oct32 precision is higher than the default oct16, hence the additional 2 uint16 values. | ||
*/ | ||
function oct32EncodeNormal(vector, result) { | ||
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. Is this specific to the clipping plane? Or should this be a utility function? Maybe a static function in 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 makes a lot of sense, but it seems like we'd also want to rename a bunch of stuff in @lilleyse what do you think? I guess we could also deprecate the current functions over time? 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. Maybe the new function could be called |
||
AttributeCompression.octEncodeInRange(vector, 65535, octEncodeScratch); | ||
|
@@ -373,7 +372,7 @@ define([ | |
var textureBytes = clippingPlaneCollection._textureBytes; | ||
var planes = clippingPlaneCollection._planes; | ||
var length = planes.length; | ||
var unchanged = true; | ||
var dirty = false; | ||
var byteIndex, uint32Index; | ||
|
||
var lengthRangeUnion = clippingPlaneCollection._lengthRangeUnion; | ||
|
@@ -396,9 +395,9 @@ define([ | |
textureBytes[byteIndex + 2] = oct32Normal.z; | ||
textureBytes[byteIndex + 3] = oct32Normal.w; | ||
|
||
uint32Index = i + i; | ||
unchanged = unchanged && previousUint32View[uint32Index] === currentUint32View[uint32Index]; | ||
if (!unchanged) { | ||
uint32Index = i * 2; | ||
dirty = dirty || previousUint32View[uint32Index] !== currentUint32View[uint32Index]; | ||
if (dirty) { | ||
previousUint32View[uint32Index] = currentUint32View[uint32Index]; | ||
} | ||
|
||
|
@@ -420,17 +419,17 @@ define([ | |
byteIndex = i * 8 + 4; | ||
insertFloat(textureBytes, normalizedDistance, byteIndex); | ||
|
||
uint32Index = i + i + 1; | ||
unchanged = unchanged && previousUint32View[uint32Index] === currentUint32View[uint32Index]; | ||
if (!unchanged) { | ||
uint32Index = i * 2 + 1; | ||
dirty = dirty || previousUint32View[uint32Index] !== currentUint32View[uint32Index]; | ||
if (dirty) { | ||
previousUint32View[uint32Index] = currentUint32View[uint32Index]; | ||
} | ||
} | ||
var lengthRange = clippingPlaneCollection._lengthRange; | ||
lengthRange.x = lengthRangeUnion.x; | ||
lengthRange.y = lengthRangeUnion.y; | ||
lengthRange.z = lengthRangeUnion.z; | ||
return !unchanged; | ||
return dirty; | ||
} | ||
|
||
/** | ||
|
@@ -458,9 +457,6 @@ define([ | |
}); | ||
this._clippingPlanesTexture = clippingPlanesTexture; | ||
} | ||
if (!this._planeTextureDirty) { | ||
return; | ||
} | ||
// pack planes to currentTextureBytes, do a texture update if anything changed. | ||
if (packAndReturnChanged(this)) { | ||
clippingPlanesTexture.copyFrom({ | ||
|
@@ -556,12 +552,12 @@ define([ | |
|
||
/** | ||
* The maximum number of supported clipping planes. | ||
* @private | ||
* | ||
* @see maxClippingPlanes.glsl | ||
* @type {number} | ||
* @constant | ||
*/ | ||
ClippingPlaneCollection.MAX_CLIPPING_PLANES = 2048; | ||
ClippingPlaneCollection.MAX_CLIPPING_PLANES = 2048; // See maxClippingPlanes.glsl | ||
|
||
/** | ||
* The pixel width of a square, power-of-two RGBA UNSIGNED_BYTE texture | ||
|
@@ -574,27 +570,62 @@ define([ | |
*/ | ||
ClippingPlaneCollection.TEXTURE_WIDTH = CesiumMath.nextPowerOfTwo(Math.ceil(Math.sqrt(ClippingPlaneCollection.MAX_CLIPPING_PLANES * 2))); | ||
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. This should probably be marked 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. Bump. Edit: add 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. I wonder if it would make more sense to make this a 1D texture, at least it would simplify some shader code. I can't seem to load https://webglstats.com/webgl right now but we can check what % of devices support 2048 pixel textures. 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. It might still be better to keep it as a POT though. I think I remember something about those being more efficient for GPU memory or something, although I also vaguely remember someone saying something about how that's not necessarily true anymore... 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. We try to use 1D textures for the 3D Tiles batch table, so there is some precedent there. But it doesn't matter much in the end. |
||
|
||
/** | ||
* Returns true if this object was destroyed; otherwise, false. | ||
* <br /><br /> | ||
* If this object was destroyed, it should not be used; calling any function other than | ||
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. | ||
* | ||
* @returns {Boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>. | ||
* | ||
* @see ClippingPlaneCollection#destroy | ||
*/ | ||
ClippingPlaneCollection.prototype.isDestroyed = function() { | ||
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. Add the usual doc above this:
|
||
return false; | ||
}; | ||
|
||
/** | ||
* Destroys this ClippingPlaneCollection if it either has no owner or a reference to the owner is passed in. | ||
* We only expect an owner to be defined if this collection is shared by one Cesium3DTileset | ||
* and a series of Cesium3DTiles with Model content. | ||
* Destroys this ClippingPlaneCollectionand its WebGL resources. | ||
* @private | ||
*/ | ||
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. This doc indentation is slightly misaligned. |
||
ClippingPlaneCollection.prototype.destroy = function() { | ||
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. Round out the doc for this. For example:
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. Also remove |
||
this._clippingPlanesTexture = this._clippingPlanesTexture && this._clippingPlanesTexture.destroy(); | ||
return destroyObject(this); | ||
}; | ||
|
||
/** | ||
* Sets the owner for the input ClippingPlaneCollection if there wasn't another owner. | ||
* Destroys the owner's previous ClippingPlaneCollection if setting is successful. | ||
* | ||
* @param {Object} owner An object to check against this ClippingPlaneCollection's owner object | ||
* @param {ClippingPlaneCollection} [clippingPlaneCollection] A ClippingPlaneCollection (or undefined) being attached to an object | ||
* @param {Object} newOwner An Object that should receive the new ClippingPlaneCollection | ||
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. Just |
||
* @param {String} key The Key for the Object to reference the ClippingPlaneCollection | ||
* @private | ||
*/ | ||
ClippingPlaneCollection.prototype.checkDestroy = function(owner) { | ||
if (defined(this.owner) && owner !== this.owner) { | ||
return this; | ||
ClippingPlaneCollection.setOwnership = function(clippingPlaneCollection, newOwner, key) { | ||
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. Place |
||
// Don't destroy the ClippingPlaneCollection if it is already owned by newOwner | ||
if (clippingPlaneCollection === newOwner[key]) { | ||
return; | ||
} | ||
|
||
if (defined(this._clippingPlanesTexture)) { | ||
this._clippingPlanesTexture.destroy(); | ||
// Destroy the existing ClippingPlaneCollection, if any | ||
newOwner[key] = newOwner[key] && newOwner[key].destroy(); | ||
if (defined(clippingPlaneCollection)) { | ||
if (defined(clippingPlaneCollection._owner)) { | ||
throw new DeveloperError('ClippingPlaneCollection should only be assigned to one object'); | ||
} | ||
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. Wrap the developer error:
|
||
clippingPlaneCollection._owner = newOwner; | ||
newOwner[key] = clippingPlaneCollection; | ||
} | ||
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. We often simplify this type of destroy code to |
||
return destroyObject(this); | ||
}; | ||
|
||
/** | ||
* Determines if rendering with clipping planes is supported. | ||
* | ||
* @returns {Boolean} <code>true</code> if ClippingPlaneCollections are supported | ||
* @deprecated | ||
*/ | ||
ClippingPlaneCollection.isSupported = function() { | ||
return true; | ||
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. This should have a 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. @likangning93 did you add the deprecation warning here? |
||
}; | ||
|
||
return ClippingPlaneCollection; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,8 +398,7 @@ define([ | |
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), | ||
pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), | ||
addBatchIdToGeneratedShaders : (batchLength > 0), // If the batch table has values in it, generated shaders will need a batchId attribute | ||
pickObject : pickObject, | ||
clippingPlanes : tileset.clippingPlanes | ||
pickObject : pickObject | ||
}); | ||
} else { | ||
// This transcodes glTF to an internal representation for geometry so we can take advantage of the re-batching of vector data. | ||
|
@@ -494,7 +493,8 @@ define([ | |
var tilesetClippingPlanes = this._tileset.clippingPlanes; | ||
if (defined(tilesetClippingPlanes)) { | ||
// Dereference the clipping planes from the model if they are irrelevant - saves on shading | ||
this._model.clippingPlanes = tilesetClippingPlanes.enabled && this._tile._isClipped ? tilesetClippingPlanes : undefined; | ||
// Link/Dereference directly to avoid ownership checks. | ||
this._model._clippingPlanes = (tilesetClippingPlanes.enabled && this._tile._isClipped) ? tilesetClippingPlanes : undefined; | ||
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. Ultimately I don't think we will need this block. Same note for It should just be: That plus any of the 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. Slight problem, I think a 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. Clarified offline, we can have 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. Another chat offline: consensus is that the method where b3dm and i3dm handle more state stuff for |
||
} | ||
|
||
this._model.update(frameState); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ define([ | |
'../Core/Cartesian3', | ||
'../Core/Cartographic', | ||
'../Core/Check', | ||
'../Core/ClippingPlaneCollection', | ||
'../Core/defaultValue', | ||
'../Core/defined', | ||
'../Core/defineProperties', | ||
|
@@ -46,6 +47,7 @@ define([ | |
Cartesian3, | ||
Cartographic, | ||
Check, | ||
ClippingPlaneCollection, | ||
defaultValue, | ||
defined, | ||
defineProperties, | ||
|
@@ -547,12 +549,8 @@ define([ | |
*/ | ||
this.loadSiblings = defaultValue(options.loadSiblings, false); | ||
|
||
this._clippingPlanes = options.clippingPlanes; | ||
|
||
// Set ownership so no Models created as content will try to delete it | ||
if (defined(options.clippingPlanes)) { | ||
options.clippingPlanes.owner = this; | ||
} | ||
this._clippingPlanes = undefined; | ||
ClippingPlaneCollection.setOwnership(options.clippingPlanes, this, '_clippingPlanes'); | ||
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. Better to call the setter: |
||
|
||
/** | ||
* This property is for debugging only; it is not optimized for production use. | ||
|
@@ -810,7 +808,7 @@ define([ | |
} | ||
}, | ||
/** | ||
* The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset. Clipping planes are not currently supported in Internet Explorer. | ||
* The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset. | ||
* | ||
* @type {ClippingPlaneCollection} | ||
*/ | ||
|
@@ -819,12 +817,7 @@ define([ | |
return this._clippingPlanes; | ||
}, | ||
set : function(value) { | ||
var oldClippingPlanes = this._clippingPlanes; | ||
if (defined(oldClippingPlanes)) { | ||
oldClippingPlanes.checkDestroy(this); | ||
} | ||
this._clippingPlanes = value; | ||
value.owner = this; | ||
ClippingPlaneCollection.setOwnership(value, this, '_clippingPlanes'); | ||
} | ||
}, | ||
|
||
|
@@ -1861,10 +1854,8 @@ define([ | |
|
||
// Update clipping planes and set them as clean to avoid re-updating the same information from each tile | ||
var clippingPlanes = this._clippingPlanes; | ||
if (defined(clippingPlanes)) { | ||
clippingPlanes._planeTextureDirty = true; | ||
if (defined(clippingPlanes) && clippingPlanes.enabled) { | ||
clippingPlanes.update(frameState); | ||
clippingPlanes._planeTextureDirty = false; | ||
} | ||
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. Maybe it would be cleaner if |
||
|
||
this._timeSinceLoad = Math.max(JulianDate.secondsDifference(frameState.time, this._loadTimestamp) * 1000, 0.0); | ||
|
@@ -1941,11 +1932,8 @@ define([ | |
// Destroy debug labels | ||
this._tileDebugLabels = this._tileDebugLabels && this._tileDebugLabels.destroy(); | ||
|
||
// Destroy clipping plane collection, setting ownership first. | ||
var clippingPlaneCollection = this._clippingPlanes; | ||
if (defined(clippingPlaneCollection)) { | ||
clippingPlaneCollection.checkDestroy(this); | ||
} | ||
// Destroy clipping plane collection | ||
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. This comment and Just like |
||
this._clippingPlanes = this._clippingPlanes && this._clippingPlanes.destroy(); | ||
|
||
// Traverse the tree and destroy all tiles | ||
if (defined(this._root)) { | ||
|
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.
Usually in Cesium code we condense this to: