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

Fix the wrong order of the boundary rectangles in TileAvailability #9098

Merged
merged 5 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, causing terrain to sometimes fail to achieve its maximum detail. [#9098](https://github.com/CesiumGS/cesium/pull/9098)

### 1.72 - 2020-08-03

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/TileAvailability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions Specs/Core/TileAvailabilitySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -210,5 +231,19 @@ describe("Core/TileAvailability", function () {
)
).toBe(1);
});

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);
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);
}
});
});
});