Skip to content

Commit

Permalink
Merge pull request #8598 from AnalyticalGraphicsInc/dont-cull-when-mo…
Browse files Browse the repository at this point in the history
…ving

Don't apply cullRequestsWhileMoving optimization when tileset is moving
  • Loading branch information
Omar Shehata authored Feb 6, 2020
2 parents 1a84f21 + c6011bd commit 6b35dc6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

### 1.67.0 - 2020-03-02

##### Fixes :wrench:

* Fixed a bug where tiles would not load if the camera was tracking a moving tileset. [#8598](https://github.com/AnalyticalGraphicsInc/cesium/pull/8598)

### 1.66.0 - 2020-02-03

##### Deprecated :hourglass_flowing_sand:
Expand Down
21 changes: 18 additions & 3 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
* @param {Number} [options.maximumScreenSpaceError=16] The maximum screen space error used to drive level of detail refinement.
* @param {Number} [options.maximumMemoryUsage=512] The maximum amount of memory in MB that can be used by the tileset.
* @param {Boolean} [options.cullWithChildrenBounds=true] Optimization option. Whether to cull tiles using the union of their children bounding volumes.
* @param {Boolean} [options.cullRequestsWhileMoving=true] Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement.
* @param {Boolean} [options.cullRequestsWhileMoving=true] Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
* @param {Number} [options.cullRequestsWhileMovingMultiplier=60.0] Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
* @param {Boolean} [options.preloadWhenHidden=false] Preload tiles when <code>tileset.show</code> is <code>false</code>. Loads tiles as if the tileset is visible but does not render them.
* @param {Boolean} [options.preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
Expand Down Expand Up @@ -158,6 +158,9 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
this._loadTimestamp = undefined;
this._timeSinceLoad = 0.0;
this._updatedVisibilityFrame = 0;
this._updatedModelMatrixFrame = 0;
this._modelMatrixChanged = false;
this._previousModelMatrix = undefined;
this._extras = undefined;
this._credits = undefined;

Expand Down Expand Up @@ -191,12 +194,13 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
this._heatmap = new Cesium3DTilesetHeatmap(options.debugHeatmapTilePropertyName);

/**
* Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement.
* Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
*
* @type {Boolean}
* @default true
*/
this.cullRequestsWhileMoving = defaultValue(options.cullRequestsWhileMoving, true);
this._cullRequestsWhileMoving = false;

/**
* Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
Expand Down Expand Up @@ -2159,6 +2163,14 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
tileset._maximumPriority.reverseScreenSpaceError = -Number.MAX_VALUE;
}

function detectModelMatrixChanged(tileset, frameState) {
if (frameState.frameNumber !== tileset._updatedModelMatrixFrame || !defined(tileset._previousModelMatrix)) {
tileset._updatedModelMatrixFrame = frameState.frameNumber;
tileset._modelMatrixChanged = !Matrix4.equals(tileset.modelMatrix, tileset._previousModelMatrix);
tileset._previousModelMatrix = Matrix4.clone(tileset.modelMatrix, tileset._previousModelMatrix);
}
}

///////////////////////////////////////////////////////////////////////////

function update(tileset, frameState, passStatistics, passOptions) {
Expand All @@ -2181,6 +2193,9 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
// Update any tracked min max values
resetMinimumMaximum(tileset);

detectModelMatrixChanged(tileset, frameState);
tileset._cullRequestsWhileMoving = tileset.cullRequestsWhileMoving && !tileset._modelMatrixChanged;

var ready = passOptions.traversal.selectTiles(tileset, frameState);

if (passOptions.requestTiles) {
Expand Down Expand Up @@ -2224,7 +2239,7 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
var pass = tilesetPassState.pass;
if ((pass === Cesium3DTilePass.PRELOAD && (!this.preloadWhenHidden || this.show)) ||
(pass === Cesium3DTilePass.PRELOAD_FLIGHT && (!this.preloadFlightDestinations || (!this.show && !this.preloadWhenHidden))) ||
(pass === Cesium3DTilePass.REQUEST_RENDER_MODE_DEFER_CHECK && ((!this.cullRequestsWhileMoving && this.foveatedTimeDelay <= 0) || !this.show))) {
(pass === Cesium3DTilePass.REQUEST_RENDER_MODE_DEFER_CHECK && ((!this._cullRequestsWhileMoving && this.foveatedTimeDelay <= 0) || !this.show))) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTilesetTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ import Cesium3DTileRefine from './Cesium3DTileRefine.js';

function isOnScreenLongEnough(tileset, tile, frameState) {
// Prevent unnecessary loads while camera is moving by getting the ratio of travel distance to tile size.
if (!tileset.cullRequestsWhileMoving) {
if (!tileset._cullRequestsWhileMoving) {
return true;
}

Expand Down
11 changes: 11 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3668,6 +3668,17 @@ describe('Scene/Cesium3DTileset', function() {
});
});

it('does not apply cullRequestWhileMoving optimization if tileset is moving', function() {
viewNothing();
return Cesium3DTilesTester.loadTileset(scene, tilesetUniform).then(function(tileset) {
tileset.cullRequestsWhileMoving = true;
tileset.modelMatrix[12] += 1.0;
viewAllTiles();
scene.renderForSpecs();
expect(tileset._requestedTilesInFlight.length).toEqual(2);
});
});

it('loads tiles when preloadWhenHidden is true', function() {
var options = {
show : false,
Expand Down

0 comments on commit 6b35dc6

Please sign in to comment.