Skip to content

Commit

Permalink
Merge pull request #2626 from AnalyticalGraphicsInc/zig-zag-corridors
Browse files Browse the repository at this point in the history
Fix Corridor Geometry for sharp corners
  • Loading branch information
bagnell committed Apr 10, 2015
2 parents 831e467 + 887a573 commit fca05a7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/Core/CorridorGeometryLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ define([
Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartesian3.normalize(backwardProjection, backwardProjection);

var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON1);
var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON7);

if (doCorner) {
cornerDirection = Cartesian3.cross(cornerDirection, normal, cornerDirection);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/PolylineVolumeGeometryLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ define([
Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartesian3.normalize(backwardProjection, backwardProjection);

var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON1);
var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON7);

if (doCorner) {
cornerDirection = Cartesian3.cross(cornerDirection, surfaceNormal, cornerDirection);
Expand Down
18 changes: 18 additions & 0 deletions Specs/Core/CorridorGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,24 @@ defineSuite([
expect(m.indices.length).toEqual(3 * 8);
});

it('computes sharp turns', function() {
var m = CorridorGeometry.createGeometry(new CorridorGeometry({
vertexFormat : VertexFormat.POSITION_ONLY,
positions : Cartesian3.fromDegreesArray([
2.00571672577652,52.7781459942399,
1.99188457974115,52.7764958852886,
2.01325961458495,52.7674170680511,
1.98708058340534,52.7733979856253,
2.00634853946644,52.7650460748473
]),
cornerType: CornerType.BEVELED,
width : 100
}));

expect(m.attributes.position.values.length).toEqual(3 * 13);
expect(m.indices.length).toEqual(3 * 11);
});

it('computes straight corridors', function() {
var m = CorridorGeometry.createGeometry(new CorridorGeometry({
vertexFormat : VertexFormat.POSITION_ONLY,
Expand Down
18 changes: 18 additions & 0 deletions Specs/Core/PolylineVolumeGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ defineSuite([
expect(m.indices.length).toEqual(3 * (8 * 2 + 4 * 7 * 2 + 4));
});

it('computes sharp turns', function() {
var m = PolylineVolumeGeometry.createGeometry(new PolylineVolumeGeometry({
vertexFormat : VertexFormat.POSITION_ONLY,
polylinePositions : Cartesian3.fromDegreesArrayHeights([
2.00571672577652, 52.7781459942399, 500,
1.99188457974115, 52.7764958852886, 500,
2.01325961458495, 52.7674170680511, 500,
1.98708058340534, 52.7733979856253, 500,
2.00634853946644, 52.7650460748473, 500
]),
cornerType: CornerType.BEVELED,
shapePositions: shape
}));

expect(m.attributes.position.values.length).toEqual(360);
expect(m.indices.length).toEqual(324);
});

it('computes straight volume', function() {
var m = PolylineVolumeGeometry.createGeometry(new PolylineVolumeGeometry({
vertexFormat : VertexFormat.POSITION_ONLY,
Expand Down

0 comments on commit fca05a7

Please sign in to comment.