Skip to content

Commit

Permalink
Merge pull request #4907 from AnalyticalGraphicsInc/better-bounding-s…
Browse files Browse the repository at this point in the history
…pheres

Fix busted ellipsoid bounding spheres
  • Loading branch information
pjcozzi authored Jan 23, 2017
2 parents 0219b31 + 3df7dea commit 6b844e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions Source/DataSources/dynamicGeometryGetBoundingSphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,20 @@ define([
//>>includeEnd('debug');

var attributes;
var modelMatrix;

//Outline and Fill geometries have the same bounding sphere, so just use whichever one is defined and ready
if (defined(primitive) && primitive.show && primitive.ready) {
attributes = primitive.getGeometryInstanceAttributes(entity);
if (defined(attributes) && defined(attributes.boundingSphere)) {
modelMatrix = defaultValue(primitive.modelMatrix, Matrix4.IDENTITY);
BoundingSphere.transform(attributes.boundingSphere, modelMatrix, result);
BoundingSphere.clone(attributes.boundingSphere, result);
return BoundingSphereState.DONE;
}
}

if (defined(outlinePrimitive) && outlinePrimitive.show && outlinePrimitive.ready) {
attributes = outlinePrimitive.getGeometryInstanceAttributes(entity);
if (defined(attributes) && defined(attributes.boundingSphere)) {
modelMatrix = defaultValue(outlinePrimitive.modelMatrix, Matrix4.IDENTITY);
BoundingSphere.transform(attributes.boundingSphere, modelMatrix, result);
BoundingSphere.clone(attributes.boundingSphere, result);
return BoundingSphereState.DONE;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Specs/createDynamicGeometryBoundingSphereSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ define([
var primitive = scene.primitives.get(0);
expect(state).toBe(BoundingSphereState.DONE);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(result).toEqualEpsilon(BoundingSphere.transform(attributes.boundingSphere, primitive.modelMatrix, new BoundingSphere()), CesiumMath.EPSILON6);
expect(result).toEqualEpsilon(attributes.boundingSphere, CesiumMath.EPSILON6);

updater.destroy();
scene.primitives.removeAll();
Expand All @@ -62,7 +62,7 @@ define([
var primitive = scene.primitives.get(0);
expect(state).toBe(BoundingSphereState.DONE);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(result).toEqualEpsilon(BoundingSphere.transform(attributes.boundingSphere, primitive.modelMatrix, new BoundingSphere()), CesiumMath.EPSILON6);
expect(result).toEqualEpsilon(attributes.boundingSphere, CesiumMath.EPSILON6);

updater.destroy();
scene.primitives.removeAll();
Expand Down

0 comments on commit 6b844e1

Please sign in to comment.