From a5d7c07139c0152e86ccd18cea85b4be8a3119ef Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 18 Aug 2020 01:18:36 -0400 Subject: [PATCH 1/5] negate return by binarySearch when negative --- Source/Core/TileAvailability.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/TileAvailability.js b/Source/Core/TileAvailability.js index 64e72d48a81c..f5381886c0b2 100644 --- a/Source/Core/TileAvailability.js +++ b/Source/Core/TileAvailability.js @@ -361,7 +361,7 @@ function putRectangleInQuadtree(maxDepth, node, rectangle) { rectangle.level, rectangleLevelComparator ); - if (index <= 0) { + if (index < 0) { index = ~index; } node.rectangles.splice(index, 0, rectangle); From 12db947101524b3a7b6aa3246cf8d8407ea1f59e Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 18 Aug 2020 16:05:15 -0400 Subject: [PATCH 2/5] add test to check rectangle is sorted in TileAvailability --- Specs/Core/TileAvailabilitySpec.js | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Specs/Core/TileAvailabilitySpec.js b/Specs/Core/TileAvailabilitySpec.js index 1280f8825210..3ed4fc99cdaa 100644 --- a/Specs/Core/TileAvailabilitySpec.js +++ b/Specs/Core/TileAvailabilitySpec.js @@ -3,6 +3,7 @@ import { GeographicTilingScheme } from "../../Source/Cesium.js"; import { Rectangle } from "../../Source/Cesium.js"; import { TileAvailability } from "../../Source/Cesium.js"; import { WebMercatorTilingScheme } from "../../Source/Cesium.js"; +import { defined } from "../../Source/Cesium.js"; describe("Core/TileAvailability", function () { var webMercator = new WebMercatorTilingScheme(); @@ -190,6 +191,26 @@ describe("Core/TileAvailability", function () { }); describe("addAvailableTileRange", function () { + function checkNodeRectanglesSorted(node) { + if (!defined(node)) { + return; + } + + var levelRectangles = node.rectangles; + for (var i = 0; i < levelRectangles.length; ++i) { + for (var j = i; j < levelRectangles.length; ++j) { + expect(levelRectangles[i].level <= levelRectangles[j].level).toBe( + true + ); + } + } + + checkNodeRectanglesSorted(node._ne); + checkNodeRectanglesSorted(node._se); + checkNodeRectanglesSorted(node._nw); + checkNodeRectanglesSorted(node._sw); + } + it("keeps availability ranges sorted by rectangle", function () { var availability = createAvailability(geographic, 15); availability.addAvailableTileRange(0, 0, 0, 1, 0); @@ -210,5 +231,19 @@ describe("Core/TileAvailability", function () { ) ).toBe(1); }); + + it("ensure the boundary rectangle is sorted properly", function () { + var availability = new TileAvailability(geographic, 6); + availability.addAvailableTileRange(0, 0, 0, 1, 0); + availability.addAvailableTileRange(1, 0, 0, 2, 0); + availability.addAvailableTileRange(2, 0, 0, 4, 0); + availability.addAvailableTileRange(3, 0, 0, 8, 0); + availability.addAvailableTileRange(0, 0, 0, 1, 0); + + for (var i = 0; i < availability._rootNodes.length; ++i) { + var node = availability._rootNodes[i]; + checkNodeRectanglesSorted(node); + } + }); }); }); From c2aab7c7427277f9fa8abce1b1997e378c086e5d Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 18 Aug 2020 16:06:07 -0400 Subject: [PATCH 3/5] fix typo --- Specs/Core/TileAvailabilitySpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specs/Core/TileAvailabilitySpec.js b/Specs/Core/TileAvailabilitySpec.js index 3ed4fc99cdaa..5ba02b18b0d3 100644 --- a/Specs/Core/TileAvailabilitySpec.js +++ b/Specs/Core/TileAvailabilitySpec.js @@ -232,7 +232,7 @@ describe("Core/TileAvailability", function () { ).toBe(1); }); - it("ensure the boundary rectangle is sorted properly", function () { + it("ensure the boundary rectangles are sorted properly", function () { var availability = new TileAvailability(geographic, 6); availability.addAvailableTileRange(0, 0, 0, 1, 0); availability.addAvailableTileRange(1, 0, 0, 2, 0); From 55ba90ab13a1ee5ebc3cd46244c8d85b84a4cadd Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 18 Aug 2020 20:14:18 -0400 Subject: [PATCH 4/5] modify CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 995290f24245..f84dfd1d117a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - Fixed several artifcats on mobile devices caused by using insufficient precision. [#9064](https://github.com/CesiumGS/cesium/pull/9064) - Fixed handling of `data:` scheme for the Cesium ion logo URL. [#9085](https://github.com/CesiumGS/cesium/pull/9085) +- Fixed an issue where the boundary rectangles in TileAvailability are not sorted correctly. [#9098](https://github.com/CesiumGS/cesium/pull/9098) ### 1.72 - 2020-08-03 From 933e55ec3c90820f79b03eda466f719e48eddbc2 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 19 Aug 2020 11:51:57 +1000 Subject: [PATCH 5/5] Tweak CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f84dfd1d117a..0fee949a304e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,7 @@ - Fixed several artifcats on mobile devices caused by using insufficient precision. [#9064](https://github.com/CesiumGS/cesium/pull/9064) - Fixed handling of `data:` scheme for the Cesium ion logo URL. [#9085](https://github.com/CesiumGS/cesium/pull/9085) -- Fixed an issue where the boundary rectangles in TileAvailability are not sorted correctly. [#9098](https://github.com/CesiumGS/cesium/pull/9098) +- Fixed an issue where the boundary rectangles in `TileAvailability` are not sorted correctly, causing terrain to sometimes fail to achieve its maximum detail. [#9098](https://github.com/CesiumGS/cesium/pull/9098) ### 1.72 - 2020-08-03