Skip to content

Commit

Permalink
Merge pull request #9098 from CesiumGS/wrong-boundary-rectangle
Browse files Browse the repository at this point in the history
Fix the wrong order of the boundary rectangles in TileAvailability
  • Loading branch information
kring authored Aug 19, 2020
2 parents 13b40ad + 933e55e commit d33cff0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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);
}
});
});
});

0 comments on commit d33cff0

Please sign in to comment.