Skip to content

Commit

Permalink
fix bounding volumes for hemisphere-size GroundPolylineGeometry
Browse files Browse the repository at this point in the history
  • Loading branch information
likangning93 committed Sep 20, 2018
1 parent 0ffd273 commit 98f6f5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Source/Core/GroundPolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ define([
var normalNudgeScratch = new Cartesian3();

var scratchBoundingSpheres = [new BoundingSphere(), new BoundingSphere()];
var boundingSphereCenterCartographicScratch = new Cartographic();

// Winding order is reversed so each segment's volume is inside-out
var REFERENCE_INDICES = [
Expand Down Expand Up @@ -1061,12 +1060,8 @@ define([
BoundingSphere.fromVertices(topPositionsArray, Cartesian3.ZERO, 3, boundingSpheres[1]);
var boundingSphere = BoundingSphere.fromBoundingSpheres(boundingSpheres);

// Adjust bounding sphere height and radius to cover whole volume
var midHeight = sumHeights / (segmentCount * 2.0);
var boundingSphereCenterCartographic = Cartographic.fromCartesian(boundingSphere.center, ellipsoid, boundingSphereCenterCartographicScratch);
boundingSphereCenterCartographic.height = midHeight;
boundingSphere.center = Cartographic.toCartesian(boundingSphereCenterCartographic, ellipsoid, boundingSphere.center);
boundingSphere.radius = Math.max(boundingSphere.radius, midHeight);
// Adjust bounding sphere height and radius to cover more of the volume
boundingSphere.radius += sumHeights / (segmentCount * 2.0);

var attributes = {
position : new GeometryAttribute({
Expand Down
1 change: 1 addition & 0 deletions Specs/Core/GroundPolylineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ defineSuite([
var pointsDistance = Cartesian3.distance(positions[0], positions[1]);

expect(boundingSphere.radius > pointsDistance).toBe(true);
expect(boundingSphere.radius > 1000.0).toBe(true); // starting top/bottom height
});

var packedInstance = [positions.length];
Expand Down

0 comments on commit 98f6f5a

Please sign in to comment.