Skip to content

Skip LODs #5128

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

Merged
merged 78 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d999610
updates
austinEng Feb 20, 2017
45913ac
Merge remote-tracking branch 'agi/3d-tiles' into skip-levels
austinEng Feb 20, 2017
c2ad8b0
initial work to skip LODs
austinEng Feb 22, 2017
f464eb1
queue loading of child tilesets
austinEng Feb 22, 2017
ac03884
keep descendants loaded and selected if tile not ready
austinEng Feb 22, 2017
aa50e12
keep descendants loaded and selected if tile not ready
austinEng Feb 22, 2017
0674041
limit jump in geometric error
austinEng Feb 22, 2017
f5c113e
Merge branch 'skip-levels' of github.com:austinEng/cesium into skip-l…
austinEng Feb 22, 2017
28f41e9
undefined ancestor if not within geometric error requirements
austinEng Feb 22, 2017
096c573
add level skipping factor
austinEng Feb 23, 2017
448803e
improve tile loading visual quality
austinEng Feb 23, 2017
cb4fc4a
working level skipping; messy
austinEng Feb 27, 2017
fba48f0
don't stencil out final-res tiles
austinEng Feb 28, 2017
d1b1ae8
cleanup and bugfixes
austinEng Mar 1, 2017
dbb01f9
mark all render-leaf tiles as final
austinEng Mar 1, 2017
a676c6d
optimize application of stencil test
austinEng Mar 2, 2017
be544d5
put queued load tiles in heap
austinEng Mar 2, 2017
a2c3392
bugfixes
austinEng Mar 2, 2017
2231dbc
improve render order sorting
austinEng Mar 2, 2017
6970362
offset distance by geometric error
austinEng Mar 7, 2017
82106de
sort tiles by z-depth; cull behind ancestor center
austinEng Mar 8, 2017
85708d2
selection for additive refinement
austinEng Mar 8, 2017
bc67e97
cleanup and add constant level skip
austinEng Mar 9, 2017
d0fa347
add geometric factor; fix for when camera is inside ancestor bounds
austinEng Mar 9, 2017
8e522f3
cleaner render state modification; lay down Z of unresolved backfaces
austinEng Mar 9, 2017
e8d8d9e
manually manage queue sizes
austinEng Mar 9, 2017
7b1d584
performance improvements; remove duplicate visits and decrease distan…
austinEng Mar 10, 2017
39f51db
fix load order bug
austinEng Mar 10, 2017
6dd4001
support multi-level refinement with stencil buffer
austinEng Mar 10, 2017
13062a5
add stencil clear command to tileset
austinEng Mar 10, 2017
05b4ac4
fix tree overtraversal
austinEng Mar 10, 2017
e1b614b
sort by center z depth for tiles overlapping camera
austinEng Mar 10, 2017
6a64a37
add comments and initial tests
austinEng Mar 15, 2017
7cf0c24
fix 3DTileset tests
austinEng Mar 16, 2017
f4c81b5
cleanup test creation
austinEng Mar 16, 2017
fcf34b2
styling fixes
austinEng Mar 16, 2017
d7783ad
add unit tests
austinEng Mar 16, 2017
a1bd576
add test
austinEng Mar 17, 2017
5cf1fcf
cleanup
austinEng Mar 17, 2017
77482c0
remove mixLOD option and geometric skipping factor
austinEng Mar 20, 2017
3152070
Merge branch '3d-tiles' into skip-levels
austinEng Mar 20, 2017
77ee9ee
styling fixes
austinEng Mar 20, 2017
a3fb482
attempt to fix backface culling
austinEng Mar 21, 2017
f61bbee
revert
austinEng Mar 21, 2017
4b67949
create stencil clear command once
austinEng Mar 21, 2017
cfb7bdd
backface hack only for tiles writing depth; inherit model depth and c…
austinEng Mar 21, 2017
8815a39
support translucent objects
austinEng Mar 21, 2017
7922fb7
add documentation
austinEng Mar 22, 2017
0c7e216
make LOD skipping default
austinEng Mar 23, 2017
67ea821
update tests; remove option for old selection method
austinEng Mar 23, 2017
0e14df7
remove old code
austinEng Mar 23, 2017
3da8d0f
updates; default to Cesium3DTileRefine.REPLACE
austinEng Apr 3, 2017
30d8b0d
remove unused numberOfChildrenWithoutContent property
austinEng Apr 4, 2017
591ee4f
rename _refining to _hasMixedContent
austinEng Apr 4, 2017
2d1089c
reuse DrawCommands for backfaces
austinEng Apr 4, 2017
de402ba
add function distanceToTileCenter
austinEng Apr 4, 2017
0c85ebf
reorder function arguments
austinEng Apr 4, 2017
1cf00aa
fix failing test
austinEng Apr 4, 2017
4e6bcad
fix usage of tile.selected
austinEng Apr 5, 2017
5bdfbe1
add depth-only fragment shader for backfaces
austinEng Apr 5, 2017
2dcd2a5
ManagedArray tests
austinEng Apr 5, 2017
f092cd7
heap fixes and tests
austinEng Apr 6, 2017
26ae8e8
remove depth-only pass; causes holes
austinEng Apr 6, 2017
6978101
Merge remote-tracking branch 'agi/3d-tiles' into skip-levels
austinEng Apr 6, 2017
849bf46
limit travesal of all descendants
austinEng Apr 7, 2017
3285f4a
updates
austinEng Apr 11, 2017
2923d84
Typos
lilleyse Apr 11, 2017
6b04a59
updates
austinEng Apr 11, 2017
2fa1588
Merge commit '2923d84ec38e1f48218d4d7c422f7ae01bc7b8ed' into skip-levels
austinEng Apr 11, 2017
dbe10de
updates; fix tests
austinEng Apr 11, 2017
fd6f891
jsHint updates
austinEng Apr 11, 2017
07cd0ea
updates
austinEng Apr 11, 2017
143188c
optimize stencil and backface commands
austinEng Apr 12, 2017
6322fc4
rename properties
austinEng Apr 12, 2017
8b45f77
fix external tileset traversal
austinEng Apr 12, 2017
a7e34c1
Merge remote-tracking branch 'agi/3d-tiles' into skip-levels
austinEng Apr 12, 2017
8501979
add CESIUM_3D_TILE pass to clear command
austinEng Apr 12, 2017
273fb43
updates
austinEng Apr 12, 2017
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
214 changes: 214 additions & 0 deletions Source/Core/Heap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/*global define*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This and ManagedArray should have tests.

define([
'./Check',
'./defaultValue',
'./defined',
'./defineProperties'
], function(
Check,
defaultValue,
defined,
defineProperties) {
'use strict';

/**
* @alias Heap
* @constructor
* @private
*
* @param {Function} comparator The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.
*/
function Heap(comparator) {
//>>includeStart('debug', pragmas.debug);
Check.defined('comparator', comparator);
//>>includeEnd('debug');

this._comparator = comparator;
this._data = [];
this._length = 0;
this._maximumSize = 0;
}

defineProperties(Heap.prototype, {
/**
* Gets the internal data in the heap.
*
* @memberof Heap.prototype
*
* @type {Array}
* @readonly
*/
data : {
get : function() {
return this._data;
}
},

/**
* Gets the length of the heap.
*
* @memberof Heap.prototype
*
* @type {Number}
* @readonly
*/
length : {
get : function() {
return this._length;
}
},

/**
* Gets and sets the maximum size of the heap.
*
* @memberof Heap.prototype
*
* @type {Number}
*/
maximumSize : {
get: function() {
return this._maximumSize;
},

set: function(value) {
this._maximumSize = value;
if (this._length > this._maximumSize && this._maximumSize > 0) {
this._length = this._maximumSize;
this._data.length = this._maximumSize;
}
}
}
});

function swap(data, a, b) {
var temp = data[a];
data[a] = data[b];
data[b] = temp;
}

/**
* Resizes the internal array of the heap.
*
* @param {Number} [length] The length to resize internal array to. Defaults to the current size of the heap.
*/
Heap.prototype.reserve = function(length) {
length = defaultValue(length, this._length);
this._data.length = length;
};

/**
* Heapify. Update the heap so that index and all descendants satisfy the heap property.
*
* @param {Number} index The starting index to heapify from.
*/
Heap.prototype.heapify = function(index) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
//>>includeEnd('debug');

var length = this._length;
var comparator = this._comparator;
var data = this._data;
var candidate = -1;

while (true) {
var right = 2 * (index + 1);
var left = right - 1;

if (left < length && comparator(data[left], data[index]) < 0) {
candidate = left;
} else {
candidate = index;
}

if (right < length && comparator(data[right], data[candidate]) < 0) {
candidate = right;
}
if (candidate !== index) {
swap(data, candidate, index);

index = candidate;
} else {
break;
}
}

if (this._length > this._maximumSize && this._maximumSize > 0) {
this._length = this._maximumSize;
this._data.length = this._maximumSize;
}
};

/**
* Create a heap from an existing array. This will modify the original array.
*
* @param {Array} data The array to convert to a heap.
*/
Heap.prototype.buildHeap = function(data) {
//>>includeStart('debug', pragmas.debug);
Check.defined('data', data);
//>>includeEnd('debug');

var length = data.length;
this._data = data;
this._length = length;

for (var i = Math.ceil(length / 2); i >= 0; --i) {
this.heapify(i);
}
};

/**
* Insert an element into the heap. If the length would grow greater than maximumSize
* of the heap, extra elements are removed.
*
* @param {*} value The element to insert
*/
Heap.prototype.insert = function(value) {
//>>includeStart('debug', pragmas.debug);
Check.defined('value', value);
//>>includeEnd('debug');

var data = this._data;
var comparator = this._comparator;

var index = this._length++;
if (index < data.length) {
data[index] = value;
} else {
data.push(value);
}

while (index !== 0) {
var parent = Math.floor((index - 1) / 2);
if (comparator(data[index], data[parent]) < 0) {
swap(data, index, parent);
index = parent;
} else {
break;
}
}

if (this._length > this._maximumSize && this._maximumSize > 0) {
this._length = this._maximumSize;
}
};

/**
* Remove the top element from the heap and return it.
*
* @returns {*} The top element of the heap.
*/
Heap.prototype.pop = function() {
if (this._length === 0) {
return undefined;
}
var data = this._data;
var root = data[0];
swap(data, 0, --this._length);
this.heapify(0);
return root;
};

return Heap;
});
149 changes: 149 additions & 0 deletions Source/Core/ManagedArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*global define*/
define([
'./defaultValue',
'./defined',
'./defineProperties',
'./Check'
], function(
defaultValue,
defined,
defineProperties,
Check) {
'use strict';

/**
* A wrapper around arrays so that the internal length of the array can be manually managed.
*
* @alias ManagedArray
* @constructor
* @private
*
* @param {Number} [length=0] The initial length of the array.
*/
function ManagedArray(length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though this is private, I'm still not sure about this name.

I haven't looked at all the uses, but can this be replaced with Queue or named something higher level?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't plan on reviewing this PR, but I also don't see the point of this class. How is this any different than a raw array with a tracking index or the Queue that we already have? Not trying to bikeshed, but every new class we add the Cesium needs to be maintained.

Copy link
Contributor Author

@austinEng austinEng Apr 12, 2017

Choose a reason for hiding this comment

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

It's not. It's just an array that manually tracks its length internally. I thought this would be cleaner than having a new tracking index every time we want to manually manage the size of a raw array. Do you think this is unnecessary?

length = defaultValue(length, 0);
this._array = new Array(length);
this._length = length;
}

defineProperties(ManagedArray.prototype, {

/**
* Gets or sets the length of the array.
* If the set length is greater than the length of the internal array, the internal array is resized.
*
* @type Number
*/
length : {
get : function() {
return this._length;
},

set : function(length) {
this._length = length;
if (length > this._array.length) {
this._array.length = length;
}
}
},

/**
* Gets the internal array.
*
* @type Array
* @readonly
*/
internalArray : {
get : function() {
return this._array;
}
}
});

/**
* Gets the element at an index.
*
* @param {Number} index The index to get.
*/
ManagedArray.prototype.get = function(index) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.lessThan('index', index, this._array.length);
//>>includeEnd('debug');

return this._array[index];
};

/**
* 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.
*/
ManagedArray.prototype.set = function(index, value) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number('index', index);
//>>includeEnd('debug');

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

/**
* Push an element into the array.
*/
ManagedArray.prototype.push = function(element) {
var index = this.length++;
this._array[index] = element;
};

/**
* Pop an element from the array.
*
* @returns {*} The last element in the array.
*/
ManagedArray.prototype.pop = function() {
return this._array[--this.length];
};

/**
* Resize the internal array if length > _array.length.
*
* @param {Number} length The length.
*/
ManagedArray.prototype.reserve = function(length) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals('length', length, 0);
//>>includeEnd('debug');

if (length > this._array.length) {
this._array.length = length;
}
};

/**
* Resize the array.
*
* @param {Number} length The length.
*/
ManagedArray.prototype.resize = function(length) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number.greaterThanOrEquals('length', length, 0);
//>>includeEnd('debug');

this.length = length;
};

/**
* Trim the internal array to the specified length. Defaults to the current length.
*
* @param {Number} [length] The length.
*/
ManagedArray.prototype.trim = function(length) {
length = defaultValue(length, this.length);
this._array.length = length;
};

return ManagedArray;
});
9 changes: 9 additions & 0 deletions Source/Renderer/ClearCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ define([
* @see Scene#debugCommandFilter
*/
this.owner = options.owner;

/**
* The pass in which to run this command.
*
* @type {Pass}
*
* @default undefined
*/
this.pass = options.pass;
}

/**
Expand Down
Loading