Skip to content

Commit

Permalink
Merge pull request #7458 from AnalyticalGraphicsInc/fix-entity-show-i…
Browse files Browse the repository at this point in the history
…nterval

Fix entities when geometry show interval is out of range
  • Loading branch information
mramato authored Jan 3, 2019
2 parents a0f00dc + 103dfa4 commit c7b1fe6
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Change Log
* Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287)

##### Fixes :wrench:
* Fixed crash when entity geometry show value is an interval that only covered part of the entity availability range [#7458](https://github.com/AnalyticalGraphicsInc/cesium/pull/7458)
* Fixed image size issue when using multiple particle systems [#7412](https://github.com/AnalyticalGraphicsInc/cesium/pull/7412)

### 1.53 - 2019-01-02
Expand Down
6 changes: 4 additions & 2 deletions Source/DataSources/GeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ define([
*/
GeometryUpdater.prototype.isOutlineVisible = function(time) {
var entity = this._entity;
return this._outlineEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time);
var visible = this._outlineEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time);
return defaultValue(visible, false);
};

/**
Expand All @@ -317,7 +318,8 @@ define([
*/
GeometryUpdater.prototype.isFilled = function(time) {
var entity = this._entity;
return this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time);
var visible = this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time);
return defaultValue(visible, false);
};

/**
Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/PolylineGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ define([
*/
PolylineGeometryUpdater.prototype.isFilled = function(time) {
var entity = this._entity;
return this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time);
var visible = this._fillEnabled && entity.isAvailable(time) && this._showProperty.getValue(time);
return defaultValue(visible, false);
};

/**
Expand Down
56 changes: 52 additions & 4 deletions Specs/DataSources/StaticGeometryColorBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ defineSuite([

it('updates with sampled color out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var color = new TimeIntervalCollectionProperty();
color.intervals.addInterval(TimeInterval.fromIso8601({
iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
Expand Down Expand Up @@ -133,8 +134,8 @@ defineSuite([
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.color).toEqual([255, 0, 0, 255]);

batch.update(time);
scene.render(time);
batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
Expand All @@ -146,6 +147,7 @@ defineSuite([

it('updates with sampled distance display condition out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var ddc = new TimeIntervalCollectionProperty();
ddc.intervals.addInterval(TimeInterval.fromIso8601({
iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
Expand Down Expand Up @@ -179,8 +181,8 @@ defineSuite([
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6);

batch.update(time);
scene.render(time);
batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
Expand All @@ -190,6 +192,52 @@ defineSuite([
});
});

it('updates with sampled show out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var show = new TimeIntervalCollectionProperty();
show.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
data: true
}));
var entity = new Entity({
availability : new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601 : '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]),
position : new Cartesian3(1234, 5678, 9101112),
ellipse : {
semiMajorAxis : 2,
semiMinorAxis : 1,
extrudedHeight : 20,
show: show
}
});

var batch = new StaticGeometryColorBatch(scene.primitives, PerInstanceColorAppearance, undefined, false, ShadowMode.DISABLED);

var updater = new EllipseGeometryUpdater(entity, scene);
batch.add(validTime, updater);

return pollToPromise(function() {
scene.initializeFrame();
var isUpdated = batch.update(validTime);
scene.render(validTime);
return isUpdated;
}).then(function() {
expect(scene.primitives.length).toEqual(1);
var primitive = scene.primitives.get(0);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([1]);

batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([0]);

batch.removeAllPrimitives();
});
});

it('updates color attribute after rebuilding polyline primitive', function() {
var batch = new StaticGeometryColorBatch(scene.primitives, PolylineColorAppearance, undefined, false, ShadowMode.DISABLED);

Expand Down
52 changes: 50 additions & 2 deletions Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ defineSuite([

it('updates with sampled distance display condition out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var ddc = new TimeIntervalCollectionProperty();
ddc.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
Expand Down Expand Up @@ -152,8 +153,8 @@ defineSuite([
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6);

batch.update(time);
scene.render(time);
batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
Expand All @@ -163,6 +164,53 @@ defineSuite([
});
});

it('updates with sampled show out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var show = new TimeIntervalCollectionProperty();
show.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
data: true
}));
var entity = new Entity({
availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]),
position : new Cartesian3(1234, 5678, 9101112),
ellipse: {
semiMajorAxis : 2,
semiMinorAxis : 1,
extrudedHeight: 20,
material : new GridMaterialProperty(),
show: show
}
});

var batch = new StaticGeometryPerMaterialBatch(scene.primitives, MaterialAppearance, undefined, false, ShadowMode.DISABLED);

var updater = new EllipseGeometryUpdater(entity, scene);
batch.add(validTime, updater);

return pollToPromise(function() {
scene.initializeFrame();
var isUpdated = batch.update(validTime);
scene.render(validTime);
return isUpdated;
}).then(function() {
expect(scene.primitives.length).toEqual(1);
var primitive = scene.primitives.get(0);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([1]);

batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([0]);

batch.removeAllPrimitives();
});
});

it('handles shared material being invalidated for polyline', function() {
var batch = new StaticGeometryPerMaterialBatch(scene.primitives, PolylineMaterialAppearance, undefined, false, ShadowMode.DISABLED);

Expand Down
51 changes: 49 additions & 2 deletions Specs/DataSources/StaticGroundGeometryColorBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ defineSuite([

it('updates with sampled distance display condition out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var ddc = new TimeIntervalCollectionProperty();
ddc.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
Expand Down Expand Up @@ -165,8 +166,8 @@ defineSuite([
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6);

batch.update(time);
scene.render(time);
batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.groundPrimitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
Expand All @@ -176,6 +177,52 @@ defineSuite([
});
});

it('updates with sampled show out of range', function() {
var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var show = new TimeIntervalCollectionProperty();
show.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
data: true
}));
var entity = new Entity({
availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]),
position : new Cartesian3(1234, 5678, 9101112),
ellipse: {
semiMajorAxis : 2,
semiMinorAxis : 1,
material: Color.RED,
show: show
}
});

var batch = new StaticGroundGeometryColorBatch(scene.groundPrimitives, ClassificationType.BOTH);

var updater = new EllipseGeometryUpdater(entity, scene);
batch.add(validTime, updater);

return pollToPromise(function() {
scene.initializeFrame();
var isUpdated = batch.update(validTime);
scene.render(validTime);
return isUpdated;
}).then(function() {
expect(scene.groundPrimitives.length).toEqual(1);
var primitive = scene.groundPrimitives.get(0);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([1]);

batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.groundPrimitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([0]);

batch.removeAllPrimitives();
});
});

it('shows only one primitive while rebuilding primitive', function() {
if (!GroundPrimitive.isSupported(scene)) {
return;
Expand Down
56 changes: 54 additions & 2 deletions Specs/DataSources/StaticGroundGeometryPerMaterialBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ defineSuite([
}

var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var ddc = new TimeIntervalCollectionProperty();
ddc.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
Expand Down Expand Up @@ -167,8 +168,8 @@ defineSuite([
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.distanceDisplayCondition).toEqualEpsilon([1.0, 2.0], CesiumMath.EPSILON6);

batch.update(time);
scene.render(time);
batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
Expand All @@ -178,6 +179,57 @@ defineSuite([
});
});

it('updates with sampled show out of range', function() {
if (!GroundPrimitive.isSupported(scene) || !GroundPrimitive.supportsMaterials(scene)) {
// Don't fail if materials on GroundPrimitive not supported
return;
}

var validTime = JulianDate.fromIso8601('2018-02-14T04:10:00+1100');
var outOfRangeTime = JulianDate.fromIso8601('2018-02-14T04:20:00+1100');
var show = new TimeIntervalCollectionProperty();
show.intervals.addInterval(TimeInterval.fromIso8601({
iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:15:00+1100',
data: true
}));
var entity = new Entity({
availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]),
position : new Cartesian3(1234, 5678, 9101112),
ellipse: {
semiMajorAxis : 2,
semiMinorAxis : 1,
material : new GridMaterialProperty(),
show: show
}
});

var batch = new StaticGroundGeometryPerMaterialBatch(scene.primitives, MaterialAppearance);

var updater = new EllipseGeometryUpdater(entity, scene);
batch.add(validTime, updater);

return pollToPromise(function() {
scene.initializeFrame();
var isUpdated = batch.update(validTime);
scene.render(validTime);
return isUpdated;
}).then(function() {
expect(scene.primitives.length).toEqual(1);
var primitive = scene.primitives.get(0);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([1]);

batch.update(outOfRangeTime);
scene.render(outOfRangeTime);

primitive = scene.primitives.get(0);
attributes = primitive.getGeometryInstanceAttributes(entity);
expect(attributes.show).toEqual([0]);

batch.removeAllPrimitives();
});
});

it('shows only one primitive while rebuilding primitive', function() {
if (!GroundPrimitive.isSupported(scene) || !GroundPrimitive.supportsMaterials(scene)) {
// Don't fail if materials on GroundPrimitive not supported
Expand Down
Loading

0 comments on commit c7b1fe6

Please sign in to comment.