From 59fb96edf2f5e110f0fe2f7ca71e071af358ccf3 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Tue, 16 May 2017 10:32:05 -0400 Subject: [PATCH 1/2] Clone polyline collection model matrix on update --- Source/Scene/Polyline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/Polyline.js b/Source/Scene/Polyline.js index f73352d37eca..9572cd0e8152 100644 --- a/Source/Scene/Polyline.js +++ b/Source/Scene/Polyline.js @@ -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 From 5afc8a3d8ab2155b94e7a0fe862bd6447dbd1614 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Tue, 16 May 2017 15:05:18 -0400 Subject: [PATCH 2/2] specs --- CHANGES.md | 1 + Source/Core/PolylinePipeline.js | 4 ++-- Specs/Scene/PolylineCollectionSpec.js | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fca485899fcb..ca04edd999a9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js index 01b9dab3a85c..96574e817fdb 100644 --- a/Source/Core/PolylinePipeline.js +++ b/Source/Core/PolylinePipeline.js @@ -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; diff --git a/Specs/Scene/PolylineCollectionSpec.js b/Specs/Scene/PolylineCollectionSpec.js index 5540b0e6a7fa..0daf02c53669 100644 --- a/Specs/Scene/PolylineCollectionSpec.js +++ b/Specs/Scene/PolylineCollectionSpec.js @@ -7,6 +7,7 @@ defineSuite([ 'Core/DistanceDisplayCondition', 'Core/HeadingPitchRange', 'Core/Math', + 'Core/Matrix4', 'Scene/Camera', 'Scene/Material', 'Scene/SceneMode', @@ -19,6 +20,7 @@ defineSuite([ DistanceDisplayCondition, HeadingPitchRange, CesiumMath, + Matrix4, Camera, Material, SceneMode, @@ -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 : [{