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 missing wall segments for some extruded polygons #8035

Closed
wants to merge 4 commits into from
Closed
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 @@ -18,6 +18,7 @@ Change Log
* Reduces size of approximateTerrainHeights.json by rounding the numbers [#7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959)
* Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/AnalyticalGraphicsInc/cesium/pull/8011)
* Fixed triangulation bug in polygons using `ArcType.RHUMB`. [#8042](https://github.com/AnalyticalGraphicsInc/cesium/issues/8042)
* Fixed a bug where extruded polygons would sometimes be missing segments. [#8035](https://github.com/AnalyticalGraphicsInc/cesium/pull/8035)

### 1.61 - 2019-09-03

Expand Down
8 changes: 7 additions & 1 deletion Source/Core/PolygonGeometryLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ define([
}

length = edgePositions.length;
var indices = IndexDatatype.createTypedArray(length / 3, length - positions.length * 6);
var vertexCount = length / 3;
var indices = IndexDatatype.createTypedArray(vertexCount, vertexCount * 3); // Assuming no vertices drop, each segment takes 6 indices and there are vertexCount / 2 walls

var edgeIndex = 0;
length /= 6;

Expand All @@ -603,6 +605,10 @@ define([
indices[edgeIndex++] = LR;
}

if (edgeIndex !== indices.length) {
indices = indices.slice(0, edgeIndex);
}

return new Geometry({
attributes : new GeometryAttributes({
position : new GeometryAttribute({
Expand Down
38 changes: 38 additions & 0 deletions Specs/Core/PolygonGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,44 @@ describe('Core/PolygonGeometry', function() {
expect(p.indices.length).toEqual(numTriangles * 3);
});

it('does not include indices for extruded walls that are too small', function() {
var positions = Cartesian3.fromDegreesArray([
7.757161063097392, 48.568676799636634,
7.753968290229146, 48.571796467099077,
7.755340073906587, 48.571948854067948,
7.756263393414589, 48.571947951609708,
7.756894446412183, 48.569396703043992
]);

var pRhumb = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({
vertexFormat : VertexFormat.POSITION_ONLY,
positions : positions,
extrudedHeight: 1000,
closeTop: false,
closeBottom: false,
arcType: ArcType.RHUMB
}));

var numVertices = 20;
var numTriangles = 12;
expect(pRhumb.attributes.position.values.length).toEqual(numVertices * 3);
expect(pRhumb.indices.length).toEqual(numTriangles * 3);

var pGeodesic = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({
vertexFormat : VertexFormat.POSITION_ONLY,
positions : positions,
extrudedHeight: 1000,
closeTop: false,
closeBottom: false,
arcType: ArcType.GEODESIC
}));

numVertices = 20;
numTriangles = 10;
expect(pGeodesic.attributes.position.values.length).toEqual(numVertices * 3);
expect(pGeodesic.indices.length).toEqual(numTriangles * 3);
});

it('computes offset attribute', function() {
var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({
vertexFormat : VertexFormat.POSITION_ONLY,
Expand Down