Skip to content

Commit

Permalink
Fix RectangleOutlineGeometry at height
Browse files Browse the repository at this point in the history
While working on #2526, I found the same problem with RectangleOutline.

I checked Polygon and Corridor, and they both work as expected, so I
think this is the last of this particular type of issue.
  • Loading branch information
mramato committed Mar 1, 2015
1 parent 8677e31 commit a33f559
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Source/Core/RectangleOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ define([
var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
var surfaceHeight = defaultValue(options.height, 0.0);
var rotation = defaultValue(options.rotation, 0.0);
var extrudedHeight = defaultValue(options.extrudedHeight, surfaceHeight);
var extrudedHeight = options.extrudedHeight;

//>>includeStart('debug', pragmas.debug);
if (!defined(rectangle)) {
Expand All @@ -226,7 +226,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
RectangleOutlineGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + 4;
RectangleOutlineGeometry.packedLength = Rectangle.packedLength + Ellipsoid.packedLength + 5;

/**
* Stores the provided instance into the provided array.
Expand Down Expand Up @@ -257,7 +257,8 @@ define([
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._surfaceHeight;
array[startingIndex++] = value._rotation;
array[startingIndex] = value._extrudedHeight;
array[startingIndex++] = defined(value._extrudedHeight) ? 1.0 : 0.0;
array[startingIndex] = defaultValue(value._extrudedHeight, 0.0);
};

var scratchRectangle = new Rectangle();
Expand Down Expand Up @@ -296,21 +297,22 @@ define([
var granularity = array[startingIndex++];
var height = array[startingIndex++];
var rotation = array[startingIndex++];
var hasExtrudedHeight = array[startingIndex++];
var extrudedHeight = array[startingIndex];

if (!defined(result)) {
scratchOptions.granularity = granularity;
scratchOptions.height = height;
scratchOptions.rotation = rotation;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined;
return new RectangleOutlineGeometry(scratchOptions);
}

result._rectangle = Rectangle.clone(rectangle, result._rectangle);
result._ellipsoid = Ellipsoid.clone(ellipsoid, result._ellipsoid);
result._surfaceHeight = height;
result._rotation = rotation;
result._extrudedHeight = extrudedHeight;
result._extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined;

return result;
};
Expand Down
23 changes: 18 additions & 5 deletions Specs/Core/RectangleOutlineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,24 @@ defineSuite([
});

var rectangle = new RectangleOutlineGeometry({
rectangle : new Rectangle(-2.0, -1.0, 0.0, 1.0),
granularity : 1.0,
ellipsoid : Ellipsoid.UNIT_SPHERE
rectangle : new Rectangle(0.1, 0.2, 0.3, 0.4),
ellipsoid : new Ellipsoid(5, 6, 7),
granularity : 8,
height : 9,
rotation : 10,
extrudedHeight : 11
});
var packedInstance = [-2.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0];
createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance);
var packedInstance = [0.1, 0.2, 0.3, 0.4, 5, 6, 7, 8, 9, 10, 1, 11];
createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance, 'extruded');

rectangle = new RectangleOutlineGeometry({
rectangle : new Rectangle(0.1, 0.2, 0.3, 0.4),
ellipsoid : new Ellipsoid(5, 6, 7),
granularity : 8,
height : 9,
rotation : 10
});
packedInstance = [0.1, 0.2, 0.3, 0.4, 5, 6, 7, 8, 9, 10, 0, 0];
createPackableSpecs(RectangleOutlineGeometry, rectangle, packedInstance, 'at height');

});

0 comments on commit a33f559

Please sign in to comment.