Skip to content

Commit

Permalink
Consistent height/extrudedHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
hpinkos committed Apr 10, 2018
1 parent 8e7f485 commit cd60c47
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 140 deletions.
17 changes: 9 additions & 8 deletions Source/Core/CorridorGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,15 @@ define([
}
//>>includeEnd('debug');

var height = defaultValue(options.height, 0.0);
var extrudedHeight = defaultValue(options.extrudedHeight, height);

this._positions = positions;
this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84));
this._vertexFormat = VertexFormat.clone(defaultValue(options.vertexFormat, VertexFormat.DEFAULT));
this._width = width;
this._height = defaultValue(options.height, 0);
this._extrudedHeight = defaultValue(options.extrudedHeight, this._height);
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
this._shadowVolume = defaultValue(options.shadowVolume, false);
Expand Down Expand Up @@ -960,10 +963,7 @@ define([
*/
CorridorGeometry.createGeometry = function(corridorGeometry) {
var positions = corridorGeometry._positions;
var height = corridorGeometry._height;
var width = corridorGeometry._width;
var extrudedHeight = corridorGeometry._extrudedHeight;
var extrude = (height !== extrudedHeight);
var ellipsoid = corridorGeometry._ellipsoid;

positions = scaleToSurface(positions, ellipsoid);
Expand All @@ -973,6 +973,10 @@ define([
return;
}

var height = corridorGeometry._height;
var extrudedHeight = corridorGeometry._extrudedHeight;
var extrude = !CesiumMath.equalsEpsilon(height, extrudedHeight, CesiumMath.EPSILON2);

var vertexFormat = corridorGeometry._vertexFormat;
var params = {
ellipsoid : ellipsoid,
Expand All @@ -984,9 +988,6 @@ define([
};
var attr;
if (extrude) {
var h = Math.max(height, extrudedHeight);
extrudedHeight = Math.min(height, extrudedHeight);
height = h;
params.height = height;
params.extrudedHeight = extrudedHeight;
params.shadowVolume = corridorGeometry._shadowVolume;
Expand Down
19 changes: 10 additions & 9 deletions Source/Core/CorridorOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,14 @@ define([
Check.typeOf.number('options.width', width);
//>>includeEnd('debug');

var height = defaultValue(options.height, 0.0);
var extrudedHeight = defaultValue(options.extrudedHeight, height);

this._positions = positions;
this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84));
this._width = width;
this._height = defaultValue(options.height, 0);
this._extrudedHeight = defaultValue(options.extrudedHeight, this._height);
this._height = Math.max(height, extrudedHeight);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
this._workerName = 'createCorridorOutlineGeometry';
Expand Down Expand Up @@ -389,7 +392,7 @@ define([
array[startingIndex++] = value._height;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._cornerType;
array[startingIndex] = value._granularity;
array[startingIndex] = value._granularity;

return array;
};
Expand Down Expand Up @@ -465,10 +468,7 @@ define([
*/
CorridorOutlineGeometry.createGeometry = function(corridorOutlineGeometry) {
var positions = corridorOutlineGeometry._positions;
var height = corridorOutlineGeometry._height;
var width = corridorOutlineGeometry._width;
var extrudedHeight = corridorOutlineGeometry._extrudedHeight;
var extrude = (height !== extrudedHeight);
var ellipsoid = corridorOutlineGeometry._ellipsoid;

positions = scaleToSurface(positions, ellipsoid);
Expand All @@ -478,6 +478,10 @@ define([
return;
}

var height = corridorOutlineGeometry._height;
var extrudedHeight = corridorOutlineGeometry._extrudedHeight;
var extrude = !CesiumMath.equalsEpsilon(height, extrudedHeight, CesiumMath.EPSILON2);

var params = {
ellipsoid : ellipsoid,
positions : cleanPositions,
Expand All @@ -488,9 +492,6 @@ define([
};
var attr;
if (extrude) {
var h = Math.max(height, extrudedHeight);
extrudedHeight = Math.min(height, extrudedHeight);
height = h;
params.height = height;
params.extrudedHeight = extrudedHeight;
attr = computePositionsExtruded(params);
Expand Down
28 changes: 13 additions & 15 deletions Source/Core/EllipseGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,6 @@ define([
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
var height = defaultValue(options.height, 0.0);
var extrudedHeight = options.extrudedHeight;
var extrude = (defined(extrudedHeight) && Math.abs(height - extrudedHeight) > 1.0);
var vertexFormat = defaultValue(options.vertexFormat, VertexFormat.DEFAULT);

//>>includeStart('debug', pragmas.debug);
Expand All @@ -745,17 +742,19 @@ define([
}
//>>includeEnd('debug');

var height = defaultValue(options.height, 0.0);
var extrudedHeight = defaultValue(options.extrudedHeight, height);

this._center = Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid.clone(ellipsoid);
this._rotation = defaultValue(options.rotation, 0.0);
this._stRotation = defaultValue(options.stRotation, 0.0);
this._height = height;
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._vertexFormat = VertexFormat.clone(vertexFormat);
this._extrudedHeight = defaultValue(extrudedHeight, height);
this._extrude = extrude;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._shadowVolume = defaultValue(options.shadowVolume, false);
this._workerName = 'createEllipseGeometry';

Expand All @@ -766,7 +765,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + 9;
EllipseGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + VertexFormat.packedLength + 8;

/**
* Stores the provided instance into the provided array.
Expand Down Expand Up @@ -805,7 +804,6 @@ define([
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._extrude ? 1.0 : 0.0;
array[startingIndex] = value._shadowVolume ? 1.0 : 0.0;

return array;
Expand Down Expand Up @@ -861,7 +859,6 @@ define([
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var extrude = array[startingIndex++] === 1.0;
var shadowVolume = array[startingIndex] === 1.0;

if (!defined(result)) {
Expand All @@ -886,7 +883,6 @@ define([
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._extrude = extrude;
result._shadowVolume = shadowVolume;

return result;
Expand All @@ -903,23 +899,25 @@ define([
return;
}

var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !CesiumMath.equalsEpsilon(height, extrudedHeight, CesiumMath.EPSILON2);

ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : ellipseGeometry._height,
extrudedHeight : ellipseGeometry._extrudedHeight,
height : height,
granularity : ellipseGeometry._granularity,
vertexFormat : ellipseGeometry._vertexFormat,
stRotation : ellipseGeometry._stRotation
};
var geometry;
if (ellipseGeometry._extrude) {
options.extrudedHeight = Math.min(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
options.height = Math.max(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.shadowVolume = ellipseGeometry._shadowVolume;
geometry = computeExtrudedEllipse(options);
} else {
Expand Down
36 changes: 16 additions & 20 deletions Source/Core/EllipseOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ define([
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
var height = defaultValue(options.height, 0.0);
var extrudedHeight = options.extrudedHeight;
var extrude = (defined(extrudedHeight) && Math.abs(height - extrudedHeight) > 1.0);

//>>includeStart('debug', pragmas.debug);
if (!defined(center)) {
Expand All @@ -185,15 +182,17 @@ define([
}
//>>includeEnd('debug');

var height = defaultValue(options.height, 0.0);
var extrudedHeight = defaultValue(options.extrudedHeight, height);

this._center = Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Ellipsoid.clone(ellipsoid);
this._rotation = defaultValue(options.rotation, 0.0);
this._height = height;
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = extrudedHeight;
this._extrude = extrude;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(defaultValue(options.numberOfVerticalLines, 16), 0);
this._workerName = 'createEllipseOutlineGeometry';
}
Expand All @@ -202,7 +201,7 @@ define([
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseOutlineGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + 9;
EllipseOutlineGeometry.packedLength = Cartesian3.packedLength + Ellipsoid.packedLength + 7;

/**
* Stores the provided instance into the provided array.
Expand Down Expand Up @@ -236,9 +235,7 @@ define([
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = defined(value._extrudedHeight) ? 1.0 : 0.0;
array[startingIndex++] = defaultValue(value._extrudedHeight, 0.0);
array[startingIndex++] = value._extrude ? 1.0 : 0.0;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex] = value._numberOfVerticalLines;

return array;
Expand Down Expand Up @@ -286,14 +283,12 @@ define([
var rotation = array[startingIndex++];
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var hasExtrudedHeight = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var extrude = array[startingIndex++] === 1.0;
var numberOfVerticalLines = array[startingIndex];

if (!defined(result)) {
scratchOptions.height = height;
scratchOptions.extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.granularity = granularity;
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
Expand All @@ -309,8 +304,7 @@ define([
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = hasExtrudedHeight ? extrudedHeight : undefined;
result._extrude = extrude;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;

return result;
Expand All @@ -327,22 +321,24 @@ define([
return;
}

var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !CesiumMath.equalsEpsilon(height, extrudedHeight, CesiumMath.EPSILON2);

ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : ellipseGeometry._height,
extrudedHeight : ellipseGeometry._extrudedHeight,
height : height,
granularity : ellipseGeometry._granularity,
numberOfVerticalLines : ellipseGeometry._numberOfVerticalLines
};
var geometry;
if (ellipseGeometry._extrude) {
options.extrudedHeight = Math.min(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
options.height = Math.max(ellipseGeometry._extrudedHeight, ellipseGeometry._height);
if (extrude) {
options.extrudedHeight = extrudedHeight;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
Expand Down
Loading

0 comments on commit cd60c47

Please sign in to comment.