Skip to content

Commit

Permalink
Merge pull request #5327 from AnalyticalGraphicsInc/polyline-model-ma…
Browse files Browse the repository at this point in the history
…trix

Fix polyline collection update when model matrix changes
  • Loading branch information
bagnell authored May 16, 2017
2 parents f511524 + 5afc8a3 commit 41ba0b0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Change Log
* Fixed bug in conversion formula in `Matrix3.fromHeadingPitchRoll`. [#5195](https://github.com/AnalyticalGraphicsInc/cesium/issues/5195)
* Upgrade FXAA to version 3.11. [#5200](https://github.com/AnalyticalGraphicsInc/cesium/pull/5200)
* `Scene.pickPosition` now caches results per frame to increase performance. [#5117](https://github.com/AnalyticalGraphicsInc/cesium/issues/5117)
* Fixed bug where polylines would not update when `PolylineCollection` model matrix was updated [#5327](https://github.com/AnalyticalGraphicsInc/cesium/pull/5327)

### 1.32 - 2017-04-03

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/PolylinePipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ define([
var inverseModelMatrix = Matrix4.inverseTransformation(modelMatrix, wrapLongitudeInversMatrix);

var origin = Matrix4.multiplyByPoint(inverseModelMatrix, Cartesian3.ZERO, wrapLongitudeOrigin);
var xzNormal = Matrix4.multiplyByPointAsVector(inverseModelMatrix, Cartesian3.UNIT_Y, wrapLongitudeXZNormal);
var xzNormal = Cartesian3.normalize(Matrix4.multiplyByPointAsVector(inverseModelMatrix, Cartesian3.UNIT_Y, wrapLongitudeXZNormal), wrapLongitudeXZNormal);
var xzPlane = Plane.fromPointNormal(origin, xzNormal, wrapLongitudeXZPlane);
var yzNormal = Matrix4.multiplyByPointAsVector(inverseModelMatrix, Cartesian3.UNIT_X, wrapLongitudeYZNormal);
var yzNormal = Cartesian3.normalize(Matrix4.multiplyByPointAsVector(inverseModelMatrix, Cartesian3.UNIT_X, wrapLongitudeYZNormal), wrapLongitudeYZNormal);
var yzPlane = Plane.fromPointNormal(origin, yzNormal, wrapLongitudeYZPlane);

var count = 1;
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ define([
this._boundingVolumeWC = BoundingSphere.transform(this._boundingVolume, modelMatrix, this._boundingVolumeWC);
}

this._modelMatrix = modelMatrix;
this._modelMatrix = Matrix4.clone(modelMatrix, this._modelMatrix);

if (this._segments.positions.length !== segmentPositionsLength) {
// number of positions changed
Expand Down
22 changes: 22 additions & 0 deletions Specs/Scene/PolylineCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defineSuite([
'Core/DistanceDisplayCondition',
'Core/HeadingPitchRange',
'Core/Math',
'Core/Matrix4',
'Scene/Camera',
'Scene/Material',
'Scene/SceneMode',
Expand All @@ -19,6 +20,7 @@ defineSuite([
DistanceDisplayCondition,
HeadingPitchRange,
CesiumMath,
Matrix4,
Camera,
Material,
SceneMode,
Expand Down Expand Up @@ -1371,6 +1373,26 @@ defineSuite([

});

it('renders with model matrix', function() {
polylines.add({
positions : [{
x : 0.0,
y : 0.0,
z : 0.0
}, {
x : 0.0,
y : 1.0,
z : 0.0
}]
});

expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
expect(scene).toRender([0, 0, 0, 255]);
polylines.modelMatrix = Matrix4.fromUniformScale(1000000.0, polylines.modelMatrix);
expect(scene).notToRender([0, 0, 0, 255]);
});

it('is picked', function() {
var p = polylines.add({
positions : [{
Expand Down

0 comments on commit 41ba0b0

Please sign in to comment.