Skip to content

Commit

Permalink
Merge pull request #8952 from CesiumGS/remove-duplicates-wall
Browse files Browse the repository at this point in the history
Correct removing duplicate positions from WallGeometry
  • Loading branch information
mramato authored Jun 13, 2020
2 parents 09f2088 + 63c55bd commit e59a8a9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
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

0 comments on commit e59a8a9

Please sign in to comment.