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

Availability from bvh #7196

Merged
merged 26 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ffbc723
Initial cut of using the bvh terrain extension as the replacement for…
Oct 8, 2018
a464633
Tweaks to where it mostly works for non-cutout terrain.
Oct 9, 2018
2bec071
Started cutout terrain work.
Oct 9, 2018
9ccfa64
Work on cutout terrain.
Oct 10, 2018
f91ddab
Merge remote-tracking branch 'origin/master' into availability-from-bvh
Oct 16, 2018
76b1f0b
Fixes for BVH availability.
Oct 16, 2018
49b94d2
sampleTerrainMostDetailed now works correctly.
Oct 16, 2018
689b886
Doc fix.
Oct 22, 2018
3d32849
Tweaks to get cutout terrain almost working.
Oct 23, 2018
fe2eeb8
Fixed availability issue.
Oct 23, 2018
163d3be
Got cutout terrain working with BVH availability.
Oct 24, 2018
041c744
Got availability to work from metadata extension
Nov 5, 2018
4e19231
Merge remote-tracking branch 'origin/master' into availability-from-bvh
Nov 8, 2018
d55b88b
Final tweaks for cutout terrain.
Nov 9, 2018
710d227
Cached promises when trying to load tiles.
Nov 10, 2018
a9da5b4
Update CHANGES.md
Nov 10, 2018
40e028c
Added tests for metadata availability.
Nov 12, 2018
8420019
Handle throttled requests better.
Nov 13, 2018
6ce6a92
Doc fix
Nov 15, 2018
dc43ebf
Tweaks to sampleTerrainMostDetailed to simplify and speed up. Also us…
Nov 16, 2018
41577bb
Simplified the logic for getTileDataAvailable
Nov 19, 2018
bfa6c8c
Fixed test.
Nov 19, 2018
eb74652
Fixed sample terrain most detailed.
Nov 19, 2018
c2aa7ac
Merge branch 'master' into availability-from-bvh
mramato Nov 19, 2018
b08bb23
Tweaked changes.md
Nov 19, 2018
a169f54
Update CHANGES.md
mramato Nov 19, 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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ Change Log

### 1.52 - 2018-12-03

##### Breaking Changes :mega:
* `TerrainProviders` that implement `availability` must now also implement the `loadTileDataAvailability` method.

##### Additions :tada:
* Added functions to get the most detailed height of 3D Tiles on-screen or off-screen. [#7115](https://github.com/AnalyticalGraphicsInc/cesium/pull/7115)
* Added `Scene.sampleHeightMostDetailed`, an asynchronous version of `Scene.sampleHeight` that uses the maximum level of detail for 3D Tiles.
* Added `Scene.clampToHeightMostDetailed`, an asynchronous version of `Scene.clampToHeight` that uses the maximum level of detail for 3D Tiles.
* Added support for high dynamic range rendering. It is enabled by default when supported, but can be disabled with `Scene.highDynamicRange`. [#7017](https://github.com/AnalyticalGraphicsInc/cesium/pull/7017)
* Added `Scene.invertClassificationSupported` for checking if invert classification is supported.
* Added `computeLineSegmentLineSegmentIntersection` to `Intersections2D`. [#7228](https://github.com/AnalyticalGraphicsInc/Cesium/pull/7228)
* Added ability to load availability progressively from a quantized mesh extension instead of upfront. This will speed up load time and reduce memory usage. [#7196](https://github.com/AnalyticalGraphicsInc/cesium/pull/7196)
* Added the ability to apply styles to 3D Tilesets that don't contain features. [#7255](https://github.com/AnalyticalGraphicsInc/Cesium/pull/7255)

##### Fixes :wrench:
Expand Down
326 changes: 283 additions & 43 deletions Source/Core/CesiumTerrainProvider.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Source/Core/EllipsoidTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,17 @@ define([
return undefined;
};

/**
* Makes sure we load availability data for a tile
*
* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
* @param {Number} level The level of the tile for which to request geometry.
* @returns {undefined|Promise} Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
*/
EllipsoidTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return undefined;
};

return EllipsoidTerrainProvider;
});
12 changes: 12 additions & 0 deletions Source/Core/GoogleEarthEnterpriseTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,18 @@ define([
return false;
};

/**
* Makes sure we load availability data for a tile
*
* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
* @param {Number} level The level of the tile for which to request geometry.
* @returns {undefined|Promise} Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
*/
GoogleEarthEnterpriseTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return undefined;
};

//
// Functions to handle imagery packets
//
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/TerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,15 @@ define([
*/
TerrainProvider.prototype.getTileDataAvailable = DeveloperError.throwInstantiationError;

/**
* Makes sure we load availability data for a tile
*
* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
* @param {Number} level The level of the tile for which to request geometry.
* @returns {undefined|Promise} Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
*/
TerrainProvider.prototype.loadTileDataAvailability = DeveloperError.throwInstantiationError;
mramato marked this conversation as resolved.
Show resolved Hide resolved

return TerrainProvider;
});
12 changes: 12 additions & 0 deletions Source/Core/VRTheWorldTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,5 +355,17 @@ define([
return undefined;
};

/**
* Makes sure we load availability data for a tile
*
* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
* @param {Number} level The level of the tile for which to request geometry.
* @returns {undefined|Promise} Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
*/
VRTheWorldTerrainProvider.prototype.loadTileDataAvailability = function(x, y, level) {
return undefined;
};

return VRTheWorldTerrainProvider;
});
84 changes: 61 additions & 23 deletions Source/Core/sampleTerrainMostDetailed.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
define([
'../ThirdParty/when',
'./Cartesian2',
'./defined',
'./DeveloperError',
'./sampleTerrain'
], function(
when,
Cartesian2,
defined,
DeveloperError,
sampleTerrain) {
'use strict';

var scratchCartesian2 = new Cartesian2();

/**
* Initiates a sampleTerrain() request at the maximum available tile level for a terrain dataset.
*
Expand Down Expand Up @@ -43,36 +47,70 @@ define([
}
//>>includeEnd('debug');

return terrainProvider.readyPromise.then(function() {
var byLevel = [];
return terrainProvider.readyPromise
.then(function() {
var byLevel = [];
var maxLevels = [];

var availability = terrainProvider.availability;
var availability = terrainProvider.availability;

//>>includeStart('debug', pragmas.debug);
if (!defined(availability)) {
throw new DeveloperError('sampleTerrainMostDetailed requires a terrain provider that has tile availability.');
}
//>>includeEnd('debug');
//>>includeStart('debug', pragmas.debug);
if (!defined(availability)) {
throw new DeveloperError('sampleTerrainMostDetailed requires a terrain provider that has tile availability.');
}
//>>includeEnd('debug');

for (var i = 0; i < positions.length; ++i) {
var position = positions[i];
var maxLevel = availability.computeMaximumLevelAtPosition(position);
var promises = [];
for (var i = 0; i < positions.length; ++i) {
var position = positions[i];
var maxLevel = availability.computeMaximumLevelAtPosition(position);
maxLevels[i] = maxLevel;
if (maxLevel === 0) {
// This is a special case where we have a parent terrain and we are requesting
// heights from an area that isn't covered by the top level terrain at all.
// This will essentially trigger the loading of the parent terrains root tile
terrainProvider.tilingScheme.positionToTileXY(position, 1, scratchCartesian2);
var promise = terrainProvider.loadTileDataAvailability(scratchCartesian2.x, scratchCartesian2.y, 1);
if (defined(promise)) {
promises.push(promise);
}
}

var atLevel = byLevel[maxLevel];
if (!defined(atLevel)) {
byLevel[maxLevel] = atLevel = [];
var atLevel = byLevel[maxLevel];
if (!defined(atLevel)) {
byLevel[maxLevel] = atLevel = [];
}
atLevel.push(position);
}
atLevel.push(position);
}

return when.all(byLevel.map(function(positionsAtLevel, index) {
if (defined(positionsAtLevel)) {
return sampleTerrain(terrainProvider, index, positionsAtLevel);
}
})).then(function() {
return positions;
return when.all(promises)
.then(function() {
return when.all(byLevel.map(function(positionsAtLevel, index) {
if (defined(positionsAtLevel)) {
return sampleTerrain(terrainProvider, index, positionsAtLevel);
}
}));
})
.then(function() {
var changedPositions = [];
for (var i = 0; i < positions.length; ++i) {
var position = positions[i];
var maxLevel = availability.computeMaximumLevelAtPosition(position);

if (maxLevel !== maxLevels[i]) {
// Now that we loaded the max availability, a higher level has become available
changedPositions.push(position);
}
}

if (changedPositions.length > 0) {
return sampleTerrainMostDetailed(terrainProvider, changedPositions);
}
})
.then(function() {
return positions;
});
});
});
}

return sampleTerrainMostDetailed;
Expand Down
54 changes: 54 additions & 0 deletions Specs/Core/CesiumTerrainProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ defineSuite([
};
}

function returnMetadataAvailabilityTileJson() {
return returnTileJson('Data/CesiumTerrainTileJson/MetadataAvailability.tile.json');
}

function waitForTile(level, x, y, requestNormals, requestWaterMask, f) {
var terrainProvider = new CesiumTerrainProvider({
url : 'made/up/url',
Expand Down Expand Up @@ -652,6 +656,33 @@ defineSuite([
});
});

it('provides QuantizedMeshTerrainData with Metadata availability', function() {
Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) {
Resource._DefaultImplementations.loadWithXhr('Data/CesiumTerrainTileJson/tile.metadataavailability.terrain', responseType, method, data, headers, deferred);
};

returnMetadataAvailabilityTileJson();

var terrainProvider = new CesiumTerrainProvider({
url : 'made/up/url'
});

return pollToPromise(function() {
return terrainProvider.ready;
}).then(function() {
expect(terrainProvider.hasMetadata).toBe(true);
expect(terrainProvider._layers[0].availabilityLevels).toBe(10);
expect(terrainProvider.availability.isTileAvailable(0,0,0)).toBe(true);
expect(terrainProvider.availability.isTileAvailable(0,1,0)).toBe(true);
expect(terrainProvider.availability.isTileAvailable(1,0,0)).toBe(false);

return terrainProvider.requestTileGeometry(0, 0, 0);
}).then(function(loadedData) {
expect(loadedData).toBeInstanceOf(QuantizedMeshTerrainData);
expect(terrainProvider.availability.isTileAvailable(1,0,0)).toBe(true);
});
});

it('returns undefined if too many requests are already in progress', function() {
var baseUrl = 'made/up/url';

Expand Down Expand Up @@ -726,6 +757,29 @@ defineSuite([
});
});

it('getTileDataAvailable() with Metadata availability', function() {
Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) {
Resource._DefaultImplementations.loadWithXhr('Data/CesiumTerrainTileJson/tile.metadataavailability.terrain', responseType, method, data, headers, deferred);
};

returnMetadataAvailabilityTileJson();

var terrainProvider = new CesiumTerrainProvider({
url : 'made/up/url'
});

return pollToPromise(function() {
return terrainProvider.ready;
}).then(function() {
expect(terrainProvider.getTileDataAvailable(0,0,0)).toBe(true);
expect(terrainProvider.getTileDataAvailable(0,0,1)).toBeUndefined();

return terrainProvider.requestTileGeometry(0, 0, 0);
}).then(function() {
expect(terrainProvider.getTileDataAvailable(0,0,1)).toBe(true);
});
});

it('supports a query string in the base URL', function() {
Resource._Implementations.loadWithXhr = function(url, responseType, method, data, headers, deferred, overrideMimeType) {
// Just return any old file, as long as its big enough
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"attribution":"","bounds":[-180,-90,180,90],"bvhlevels":6,"description":"","extensions":["bvh","metadata","octvertexnormals"],"format":"quantized-mesh-1.0","maxzoom":8,"metadataAvailability":10,"minzoom":0,"name":"","projection":"EPSG:4326","scheme":"tms","tiles":["{z}/{x}/{y}.terrain?v={version}"],"version":"1.33.0"}
Binary file not shown.