Skip to content
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

3D Tiles Traversal cleanup #6390

Merged
merged 64 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d683e4d
Change request queue from a heap to a sorted array
lilleyse Feb 20, 2018
366a1d2
Set highest priority for globe tiles that you are inside
lilleyse Feb 21, 2018
3f09e0c
Move tileset cache to its own class
lilleyse Feb 22, 2018
15700e4
Temp
lilleyse Feb 27, 2018
7500d7d
Stable
lilleyse Mar 20, 2018
b285439
Optimizations
lilleyse Mar 21, 2018
b44933d
Fix bug with skipping. Solid
lilleyse Mar 21, 2018
b975f1e
Combine base and skip traversal together
lilleyse Mar 22, 2018
5a36e0b
Remove touched frame checks
lilleyse Mar 22, 2018
66f977d
Remove desiredTiles
lilleyse Mar 22, 2018
e0a2a86
Better handling of processing tiles
lilleyse Mar 23, 2018
dbdd7ef
Sort children by distance in main traversal
lilleyse Mar 26, 2018
2894551
Select empty tiles so their debug bounding volumes get drawn
lilleyse Mar 26, 2018
b9219db
Limit selection traversal by SSE and visibility
lilleyse Mar 26, 2018
5e7e764
Update tile outline properly
lilleyse Mar 26, 2018
63ad7c3
Cleanup
lilleyse Mar 26, 2018
c804dd3
Fix for outlines
lilleyse Mar 26, 2018
a6aad57
Fixing tests
lilleyse Mar 27, 2018
4bbacf8
Cleanup
lilleyse Mar 28, 2018
248c443
Better handling of request volume
lilleyse Mar 28, 2018
db216c1
Include additive tiles in final selection
lilleyse Mar 28, 2018
1f51e9b
Add empty tiles to a different selection list
lilleyse Mar 28, 2018
978f9f6
Reorganization of checking refinement
lilleyse Mar 28, 2018
582a51f
Fix geometric errors on TilesetOfTilesets
lilleyse Mar 28, 2018
49c005b
Add back loadSiblings and fix more tests
lilleyse Mar 28, 2018
4509017
Fix 2 tests
lilleyse Mar 29, 2018
7d21281
Fix expiration
lilleyse Mar 29, 2018
ca07240
Remove unneeeded scene.renderForSpecs
lilleyse Mar 29, 2018
fae93f7
Fix remaining tests and starting to reorg for pick pass
lilleyse Mar 29, 2018
72ec719
Fix picking statistics
lilleyse Mar 29, 2018
e558f2f
Fix refine for skip-lods off
lilleyse Mar 29, 2018
0cb8dcd
Always include root tile in base traversal
lilleyse Mar 29, 2018
6d29c37
Move tileset cache to its own class
lilleyse Feb 22, 2018
5c97c9b
Rename file
lilleyse Mar 27, 2018
15921c2
Rename file back to lowercase
lilleyse Mar 27, 2018
bc9c55a
Fix eslint error
lilleyse Mar 29, 2018
ee36a46
Temp CHANGES.md
lilleyse Mar 29, 2018
059d2b0
Merge branch 'master' into tileset-cache
lilleyse Apr 2, 2018
7254492
Removed hasTilesetContent check when loading because it will always b…
lilleyse Apr 3, 2018
9046570
Merge branch 'master' into request-performance
lilleyse Apr 4, 2018
593826f
Merge branch 'request-performance' into tileset-cache
lilleyse Apr 4, 2018
8e58835
Add back comment about expired tiles
lilleyse Apr 4, 2018
57627f4
Merge pull request #6391 from AnalyticalGraphicsInc/tileset-cache
pjcozzi Apr 11, 2018
ac0cf76
Merge branch 'master' into traversal-cleanup
lilleyse Jun 13, 2018
3f6714b
Add and update comments
lilleyse Jun 13, 2018
fc65396
Merge branch 'master' into request-performance
lilleyse Jun 29, 2018
5e57ca2
Merge branch 'request-performance' into traversal-cleanup
lilleyse Jun 29, 2018
5856714
Simplify update visibility checking
lilleyse Jul 4, 2018
6bda10e
Simplify visibility code and tweak comments
lilleyse Jul 4, 2018
79e77c7
Tweak and fix tests to get better code coverage
lilleyse Jul 4, 2018
716c6a4
Draw empty bounding volumes as a different color (green)
lilleyse Jul 4, 2018
a0d5c5c
Comments and .peek
lilleyse Jul 5, 2018
6a8fcfa
Updated CHANGES.md
lilleyse Jul 5, 2018
2705996
Remove RequestQueue code
lilleyse Jul 5, 2018
c8c981e
Added visited frame to tile
lilleyse Jul 6, 2018
1dd5e68
Fix update visibility code again
lilleyse Jul 6, 2018
8df3ddb
Merge branch 'master' into traversal-cleanup
lilleyse Jul 6, 2018
6e84390
Remove TODO
lilleyse Jul 6, 2018
e95a9a2
Merge branch 'master' into traversal-cleanup
lilleyse Jul 25, 2018
8d85e60
Updates
lilleyse Jul 28, 2018
4fc6f7e
More concise handling of finalResolution
lilleyse Jul 28, 2018
6991103
Remove tile.renderableContent
lilleyse Jul 28, 2018
30c0459
Merge branch 'master' into traversal-cleanup
lilleyse Aug 9, 2018
b527503
Merge branch 'master' into traversal-cleanup
lilleyse Aug 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ Change Log

### 1.48 - 2018-08-01

#### Deprecated :hourglass_flowing_sand:
##### Deprecated :hourglass_flowing_sand:
* Support for 3D Tiles `content.url` is deprecated to reflect updates to the [3D Tiles spec](https://github.com/AnalyticalGraphicsInc/3d-tiles/pull/301). Use `content.uri instead`. Support for `content.url` will remain for backwards compatibility. [#6744](https://github.com/AnalyticalGraphicsInc/cesium/pull/6744)

#### Fixes :wrench:
##### Fixes :wrench:
* Several performance improvements and fixes to the 3D Tiles traversal code. [#6390](https://github.com/AnalyticalGraphicsInc/cesium/pull/6390)
* Improved load performance when `skipLevelOfDetail` is false.
* Fixed a bug that caused some skipped tiles to load when `skipLevelOfDetail` is true.
* Fixed pick statistics in the 3D Tiles Inspector.
* Fixed drawing of debug labels for external tilesets.
* Fixed drawing of debug outlines for empty tiles.
* Fixed bug causing billboards and labels to appear the wrong size when switching scene modes [#6745](https://github.com/AnalyticalGraphicsInc/cesium/issues/6745)

### 1.47 - 2018-07-02
Expand Down
17 changes: 14 additions & 3 deletions Source/Core/ManagedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,32 @@ define([
* Sets the element at an index. Resizes the array if index is greater than the length of the array.
*
* @param {Number} index The index to set.
* @param {*} value The value to set at index.
* @param {*} element The element to set at index.
*/
ManagedArray.prototype.set = function(index, value) {
ManagedArray.prototype.set = function(index, element) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number('index', index);
//>>includeEnd('debug');

if (index >= this.length) {
this.length = index + 1;
}
this._array[index] = value;
this._array[index] = element;
};

/**
* Returns the last element in the array without modifying the array.
*
* @returns {*} The last element in the array.
*/
ManagedArray.prototype.peek = function() {
return this._array[this._length - 1];
};

/**
* Push an element into the array.
*
* @param {*} element The element to push.
*/
ManagedArray.prototype.push = function(element) {
var index = this.length++;
Expand Down
72 changes: 40 additions & 32 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define([
'../Core/BoundingSphere',
'../Core/Cartesian3',
'../Core/Color',
'../Core/ColorGeometryInstanceAttribute',
'../Core/CullingVolume',
'../Core/defaultValue',
'../Core/defined',
Expand All @@ -21,7 +22,6 @@ define([
'../Core/Resource',
'../Core/RuntimeError',
'../ThirdParty/when',
'./Cesium3DTileChildrenVisibility',
'./Cesium3DTileContentFactory',
'./Cesium3DTileContentState',
'./Cesium3DTileOptimizationHint',
Expand All @@ -35,6 +35,7 @@ define([
BoundingSphere,
Cartesian3,
Color,
ColorGeometryInstanceAttribute,
CullingVolume,
defaultValue,
defined,
Expand All @@ -54,7 +55,6 @@ define([
Resource,
RuntimeError,
when,
Cesium3DTileChildrenVisibility,
Cesium3DTileContentFactory,
Cesium3DTileContentState,
Cesium3DTileOptimizationHint,
Expand Down Expand Up @@ -253,14 +253,16 @@ define([
this.hasTilesetContent = false;

/**
* The corresponding node in the cache replacement list.
* The corresponding node in the cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would briefly mention what the cache is used for here.

*
* See {@link Cesium3DTilesetCache}
*
* @type {DoublyLinkedListNode}
* @readonly
*
* @private
*/
this.replacementNode = undefined;
this.cacheNode = undefined;

var expire = header.expire;
var expireDuration;
Expand All @@ -286,15 +288,6 @@ define([
*/
this.expireDate = expireDate;

/**
* Marks if the tile is selected this frame.
*
* @type {Boolean}
*
* @private
*/
this.selected = false;

/**
* The time when a style was last applied to this tile.
*
Expand Down Expand Up @@ -325,22 +318,27 @@ define([

// Members that are updated every frame for tree traversal and rendering optimizations:
this._distanceToCamera = 0;
this._visibilityPlaneMask = 0;
this._childrenVisibility = Cesium3DTileChildrenVisibility.VISIBLE;
this._lastSelectedFrameNumber = -1;
this._centerZDepth = 0;
this._screenSpaceError = 0;
this._screenSpaceErrorComputedFrame = -1;
this._visibilityPlaneMask = 0;
this._visible = false;
this._inRequestVolume = false;

this._finalResolution = true;
this._depth = 0;
this._centerZDepth = 0;
this._stackLength = 0;
this._selectedFrame = -1;
this._selectionDepth = 0;
this._lastSelectionDepth = undefined;
this._requestedFrame = undefined;
this._lastVisitedFrame = undefined;

this._updatedVisibilityFrame = 0;
this._touchedFrame = 0;
this._visitedFrame = 0;
this._selectedFrame = 0;
this._requestedFrame = 0;
this._ancestorWithContent = undefined;
this._ancestorWithLoadedContent = undefined;
this._ancestorWithContentAvailable = undefined;
this._refines = false;
this._shouldSelect = false;
this._priority = 0.0;
this._isClipped = true;
this._clippingPlanesState = 0; // encapsulates (_isClipped, clippingPlanes.enabled) and number/function

Expand Down Expand Up @@ -458,13 +456,13 @@ define([
*/
contentAvailable : {
get : function() {
return this.contentReady || (defined(this._expiredContent) && this._contentState !== Cesium3DTileContentState.FAILED);
return (this.contentReady && this.hasRenderableContent) || (defined(this._expiredContent) && this._contentState !== Cesium3DTileContentState.FAILED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't contentReady determine if the content is renderable? Would it make more sence to make sure it's non-empty and also if the content is ready?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it seems like there is a mix of setting variables like hasRenderableContent explicitly, along with using states like this._contentState === Cesium3DTileContentState.READY. hadRenderableContent can be a getter that checks the state, but I think we should only be setting one or the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this was confusing, I removed this.hasRenderableContent and instead check hasEmptyContent or hasTilesetContent as needed.

}
},

/**
* Determines if the tile is ready to render. <code>true</code> if the tile
* is ready to render; otherwise, <code>false</code>.
* Determines if the tile's content is ready. This is automatically <code>true</code> for
* tile's with empty content.
*
* @memberof Cesium3DTile.prototype
*
Expand Down Expand Up @@ -609,7 +607,7 @@ define([

function createPriorityFunction(tile) {
return function() {
return tile._distanceToCamera;
return tile._priority;
};
}

Expand Down Expand Up @@ -701,7 +699,7 @@ define([
updateExpireDate(that);

// Refresh style for expired content
that.lastStyleTime = 0;
that._selectedFrame = 0;

that._contentState = Cesium3DTileContentState.READY;
that._contentReadyPromise.resolve(content);
Expand Down Expand Up @@ -735,8 +733,6 @@ define([
this._contentReadyToProcessPromise = undefined;
this._contentReadyPromise = undefined;

this.replacementNode = undefined;

this.lastStyleTime = 0;
this.clippingPlanesDirty = (this._clippingPlanesState === 0);
this._clippingPlanesState = 0;
Expand Down Expand Up @@ -850,7 +846,7 @@ define([
* Computes the distance from the center of the tile's bounding volume to the camera.
*
* @param {FrameState} frameState The frame state.
* @returns {Number} The distance, in meters, or zero if the camera is inside the bounding volume.
* @returns {Number} The distance, in meters.
*
* @private
*/
Expand Down Expand Up @@ -994,14 +990,26 @@ define([

function applyDebugSettings(tile, tileset, frameState) {
var hasContentBoundingVolume = defined(tile._header.content) && defined(tile._header.content.boundingVolume);
var empty = tile.hasEmptyContent || tile.hasTilesetContent;

var showVolume = tileset.debugShowBoundingVolume || (tileset.debugShowContentBoundingVolume && !hasContentBoundingVolume);
if (showVolume) {
var color;
if (!tile._finalResolution) {
color = Color.YELLOW;
} else if (hasContentBoundingVolume) {
color = Color.WHITE;
} else if (empty) {
color = Color.GREEN;
} else {
color = Color.RED;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little picky, but since red usually means "bad" and green usually mean "good" or "go", I would mark the colors something like so:

!finalResolution -> Yellow
empty -> gray
hasContentBoundingVolume -> green
otherwise -> blue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up going with:

!finalResolution -> yellow
empty -> gray
boundingVolume -> white
contentBoundingVolume -> blue (the code for drawing content bounding volumes is further down)

I like white as the "base" color because it's really neutral.

if (!defined(tile._debugBoundingVolume)) {
var color = tile._finalResolution ? (hasContentBoundingVolume ? Color.WHITE : Color.RED) : Color.YELLOW;
tile._debugBoundingVolume = tile._boundingVolume.createDebugVolume(color);
}
tile._debugBoundingVolume.update(frameState);
var attributes = tile._debugBoundingVolume.getGeometryInstanceAttributes('outline');
attributes.color = ColorGeometryInstanceAttribute.toValue(color, attributes.color);
} else if (!showVolume && defined(tile._debugBoundingVolume)) {
tile._debugBoundingVolume = tile._debugBoundingVolume.destroy();
}
Expand Down
7 changes: 5 additions & 2 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,8 @@ define([
}
tileset._backfaceCommands.push(derivedCommands.zback);
}
if (!defined(derivedCommands.stencil) || tile._selectionDepth !== tile._lastSelectionDepth) {
if (!defined(derivedCommands.stencil) || tile._selectionDepth !== getLastSelectionDepth(derivedCommands.stencil)) {
derivedCommands.stencil = deriveStencilCommand(derivedCommands.originalCommand, tile._selectionDepth);
tile._lastSelectionDepth = tile._selectionDepth;
}
updateDerivedCommand(derivedCommands.stencil, command);
}
Expand Down Expand Up @@ -1372,6 +1371,10 @@ define([
return derivedCommand;
}

function getLastSelectionDepth(stencilCommand) {
return stencilCommand.renderState.stencilTest.reference >>> 4;
}

function getTranslucentRenderState(renderState) {
var rs = clone(renderState, true);
rs.cull.enabled = false;
Expand Down
19 changes: 0 additions & 19 deletions Source/Scene/Cesium3DTileChildrenVisibility.js

This file was deleted.

2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTileStyleEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
var length = tiles.length;
for (var i = 0; i < length; ++i) {
var tile = tiles[i];
if (tile.selected && (tile.lastStyleTime !== lastStyleTime)) {
if (tile.lastStyleTime !== lastStyleTime) {
// Apply the style to this tile if it wasn't already applied because:
// 1) the user assigned a new style to the tileset
// 2) this tile is now visible, but it wasn't visible when the style was first assigned
Expand Down
Loading