Skip to content

Commit b8ccf80

Browse files
committed
optimizations
1 parent 1326d5b commit b8ccf80

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Source/Scene/Cesium3DTilesetTraversal.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ define([
304304
};
305305

306306
BaseTraversal.prototype.getChildren = function(tile) {
307-
if (this.updateAndCheckChildren(tile)) {
307+
if (baseUpdateAndCheckChildren(this.tileset, tile, this.baseScreenSpaceError, this.frameState)) {
308308
var children = tile.children;
309309
var childrenLength = children.length;
310310
var allReady = true;
@@ -331,14 +331,12 @@ define([
331331
return emptyArray;
332332
};
333333

334-
BaseTraversal.prototype.updateAndCheckChildren = function(tile) {
335-
var tileset = this.tileset;
336-
334+
function baseUpdateAndCheckChildren(tileset, tile, baseScreenSpaceError, frameState) {
337335
if (tile.hasTilesetContent) {
338336
// load any tilesets of tilesets now because at this point we still have not achieved a base level of content
339-
loadTile(tile, this.frameState);
337+
loadTile(tile, frameState);
340338
if (tile.contentReady) {
341-
updateChildren(tileset, tile, this.frameState);
339+
updateChildren(tileset, tile, frameState);
342340
}
343341
return true;
344342
}
@@ -348,13 +346,13 @@ define([
348346
}
349347

350348
// stop traversal when we've attained the desired level of error
351-
if (tile._screenSpaceError <= this.baseScreenSpaceError) {
349+
if (tile._screenSpaceError <= baseScreenSpaceError) {
352350
// When skipping LODs, require an existing base level of content first
353-
updateChildren(tileset, tile, this.frameState);
351+
updateChildren(tileset, tile, frameState);
354352
return false;
355353
}
356354

357-
var childrenVisibility = updateChildren(tileset, tile, this.frameState);
355+
var childrenVisibility = updateChildren(tileset, tile, frameState);
358356
var showAdditive = tile.refine === Cesium3DTileRefine.ADD;
359357
var showReplacement = tile.refine === Cesium3DTileRefine.REPLACE && (childrenVisibility & Cesium3DTileChildrenVisibility.VISIBLE_IN_REQUEST_VOLUME) !== 0;
360358

@@ -407,7 +405,7 @@ define([
407405
};
408406

409407
InternalBaseTraversal.prototype.getChildren = function(tile) {
410-
if (this.updateAndCheckChildren(tile, this.baseScreenSpaceError)) {
408+
if (baseUpdateAndCheckChildren(this.tileset, tile, this.baseScreenSpaceError, this.frameState)) {
411409
var children = tile.children;
412410
var childrenLength = children.length;
413411
for (var i = 0; i < childrenLength; ++i) {
@@ -580,12 +578,16 @@ define([
580578
};
581579

582580
function updateChildren(tileset, tile, frameState) {
581+
if (tile._lastVisitedFrame === frameState.frameNumber) {
582+
return tile.childrenVisibility;
583+
}
584+
583585
var children = tile.children;
584586

585587
updateTransforms(children, tile.computedTransform);
586588
computeDistanceToCamera(children, frameState);
587589

588-
return computeChildrenVisibility(tile, frameState, true);
590+
return computeChildrenVisibility(tile, frameState);
589591
}
590592

591593
function visitTile(tileset, tile, frameState, outOfCore) {
@@ -630,7 +632,7 @@ define([
630632
}
631633
}
632634

633-
function computeChildrenVisibility(tile, frameState, checkViewerRequestVolume) {
635+
function computeChildrenVisibility(tile, frameState) {
634636
var flag = Cesium3DTileChildrenVisibility.NONE;
635637
var children = tile.children;
636638
var childrenLength = children.length;
@@ -644,17 +646,15 @@ define([
644646
flag |= Cesium3DTileChildrenVisibility.VISIBLE;
645647
}
646648

647-
if (checkViewerRequestVolume) {
648-
if (!child.insideViewerRequestVolume(frameState)) {
649-
if (isVisible(visibilityMask)) {
650-
flag |= Cesium3DTileChildrenVisibility.VISIBLE_NOT_IN_REQUEST_VOLUME;
651-
}
652-
visibilityMask = CullingVolume.MASK_OUTSIDE;
653-
} else {
654-
flag |= Cesium3DTileChildrenVisibility.IN_REQUEST_VOLUME;
655-
if (isVisible(visibilityMask)) {
656-
flag |= Cesium3DTileChildrenVisibility.VISIBLE_IN_REQUEST_VOLUME;
657-
}
649+
if (!child.insideViewerRequestVolume(frameState)) {
650+
if (isVisible(visibilityMask)) {
651+
flag |= Cesium3DTileChildrenVisibility.VISIBLE_NOT_IN_REQUEST_VOLUME;
652+
}
653+
visibilityMask = CullingVolume.MASK_OUTSIDE;
654+
} else {
655+
flag |= Cesium3DTileChildrenVisibility.IN_REQUEST_VOLUME;
656+
if (isVisible(visibilityMask)) {
657+
flag |= Cesium3DTileChildrenVisibility.VISIBLE_IN_REQUEST_VOLUME;
658658
}
659659
}
660660

0 commit comments

Comments
 (0)