Skip to content

Commit

Permalink
Merge pull request #711 from AnalyticalGraphicsInc/polylines
Browse files Browse the repository at this point in the history
Polyline Fixes
  • Loading branch information
mramato committed Apr 30, 2013
2 parents 200d332 + b0233d1 commit 4bcf1b8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/Scene/PolylineCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ define([
};

var emptyArray = [];
var scracthBoundingSphere = new BoundingSphere();

/**
* @private
Expand Down Expand Up @@ -449,10 +450,13 @@ define([
if (frameState.mode === SceneMode.SCENE3D) {
boundingVolume = this._boundingVolume;
modelMatrix = this.modelMatrix;
} else if (frameState.mode === SceneMode.COLUMBUS_VIEW || frameState.mode === SceneMode.SCENE2D) {
} else if (frameState.mode === SceneMode.COLUMBUS_VIEW) {
boundingVolume = this._boundingVolume2D;
} else {
boundingVolume = this._boundingVolume && this._boundingVolume2D && this._boundingVolume.union(this._boundingVolume2D);
} else if (frameState.mode === SceneMode.SCENE2D) {
boundingVolume = BoundingSphere.clone(this._boundingVolume2D, scracthBoundingSphere);
boundingVolume.center.x = 0.0;
} else if (typeof this._boundingVolume !== 'undefined' && typeof this._boundingVolume2D !== 'undefined') {
boundingVolume = BoundingSphere.union(this._boundingVolume, this._boundingVolume2D, scracthBoundingSphere);
}

var pass = frameState.passes;
Expand Down Expand Up @@ -1071,7 +1075,7 @@ define([
for ( var i = 0; i < length; ++i) {
var polyline = polylines[i];
var width = polyline.getWidth();
var show = polyline.getShow();
var show = polyline.getShow() && width > 0.0;
var segments = this.getSegments(polyline);
var positions = segments.positions;
var lengths = segments.lengths;
Expand Down Expand Up @@ -1395,7 +1399,7 @@ define([
var position;

var width = polyline.getWidth();
var show = polyline.getShow();
var show = polyline.getShow() && width > 0.0;

positionsLength = positions.length;
for ( var i = 0; i < positionsLength; ++i) {
Expand Down
29 changes: 29 additions & 0 deletions Specs/Scene/PolylineCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,35 @@ defineSuite([
expect(context.readPixels()).toNotEqual([0, 0, 0, 0]);
});

it('does not render with width 0.0', function() {
var positions = [
{
x : -1.0,
y : 1.0,
z : 0.0
},{
x : -1.0,
y : -1.0,
z : 0.0
}];
var line = polylines.add({
positions : positions
});

ClearCommand.ALL.execute(context);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);

render(context, frameState, polylines);
expect(context.readPixels()).toNotEqual([0, 0, 0, 0]);

ClearCommand.ALL.execute(context);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);

line.setWidth(0.0);
render(context, frameState, polylines);
expect(context.readPixels()).toEqual([0, 0, 0, 0]);
});

it('changes polyline position size recreates vertex arrays', function() {
var positions = [];
for(var i = 0; i < 20; ++i){
Expand Down

0 comments on commit 4bcf1b8

Please sign in to comment.