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

Correct removing duplicate positions from WallGeometry #8952

Merged
merged 2 commits into from
Jun 13, 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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### 1.71 - 2020-07-01

##### Fixes :wrench:

- Fixed error with `WallGeoemtry` when there were adjacent positions with very close values [#8952](https://github.com/CesiumGS/cesium/pull/8952)

### 1.70.1 - 2020-06-10

##### Additions :tada:
Expand Down
8 changes: 6 additions & 2 deletions Source/Core/WallGeometryLibrary.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import arrayRemoveDuplicates from "./arrayRemoveDuplicates.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import defined from "./defined.js";
import EllipsoidTangentPlane from "./EllipsoidTangentPlane.js";
Expand All @@ -13,14 +15,16 @@ var WallGeometryLibrary = {};

function latLonEquals(c0, c1) {
return (
CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON14) &&
CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON14)
CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON10) &&
CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON10)
);
}

var scratchCartographic1 = new Cartographic();
var scratchCartographic2 = new Cartographic();
function removeDuplicates(ellipsoid, positions, topHeights, bottomHeights) {
positions = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon, true);

var length = positions.length;
if (length < 2) {
return;
Expand Down
40 changes: 38 additions & 2 deletions Specs/Core/WallGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,44 @@ describe("Core/WallGeometry", function () {
expect(cartographic.height).toEqualEpsilon(2000.0, CesiumMath.EPSILON8);
});

it("does not clean positions that add up past EPSILON14", function () {
var eightyPercentOfEpsilon14 = 0.8 * CesiumMath.EPSILON14;
it("removes duplicates with very small difference", function () {
var w = WallGeometry.createGeometry(
new WallGeometry({
vertexFormat: VertexFormat.POSITION_ONLY,
positions: [
new Cartesian3(
4347090.215457887,
1061403.4237998386,
4538066.036525028
),
new Cartesian3(
4348147.589624987,
1043897.8776143644,
4541092.234751661
),
new Cartesian3(
4348147.589882754,
1043897.8776762491,
4541092.234492364
),
new Cartesian3(
4335659.882947743,
1047571.602084736,
4552098.654605664
),
],
})
);

var numPositions = 8;
var numTriangles = 4;
var positions = w.attributes.position.values;
expect(positions.length).toEqual(numPositions * 3);
expect(w.indices.length).toEqual(numTriangles * 3);
});

it("does not clean positions that add up past EPSILON10", function () {
var eightyPercentOfEpsilon14 = 0.8 * CesiumMath.EPSILON10;
var inputPositions = Cartesian3.fromRadiansArrayHeights([
1.0,
1.0,
Expand Down