Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance display conditions #4309

Merged
merged 39 commits into from
Sep 29, 2016
Merged

Distance display conditions #4309

merged 39 commits into from
Sep 29, 2016

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Sep 9, 2016

Adds distance display conditions to primitives.

For billboards, points and models, there is a new distanceDisplayCondition property. For Primitives, there is a new distanceDisplayCondition per-instance geometry attribute.

TODO:

  • Add support to PolylineCollection.
  • Add support for line and path entities.
  • Add entity support.
  • Add tests for primitives.
  • Add tests for entities.
  • Add doc.
  • Update CHANGES.md.

@mramato
Copy link
Contributor

mramato commented Sep 9, 2016

I haven't really looked at this yet, but to go along with translucencyByDistance and scaleByDistance should this be called showByDistance?

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 9, 2016

JSHint warnings: https://travis-ci.org/AnalyticalGraphicsInc/cesium/builds/158843026

Specs/Core/DistanceDisplayConditionSpec.js
line 2 col 1 'defineSuite' is not defined.
line 1 col 1 'definedSuite' is defined but never used.
⚠ 2 warnings

@@ -3719,7 +3721,8 @@ define([
}
}

var show = this.show && (this.scale !== 0.0);
var displayConditionPassed = defined(this.distanceDisplayCondition) ? this.distanceDisplayCondition.isVisible(this, frameState) : true;
var show = this.show && (this.scale !== 0.0) && displayConditionPassed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps slightly faster in the reject case (and the same speed in the accept) to do

this.show  && displayConditionPassed && (this.scale !== 0.0)

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 9, 2016

I haven't really looked at this yet, but to go along with translucencyByDistance and scaleByDistance should this be called showByDistance?

We could if we were sure we'll never add another display condition like pixel size, viewer altitude, etc. since those would want to be named showByPixelSize, etc. In practice, distance should get us 95% of the cases so up to @bagnell.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 9, 2016

Just those comments. This is looking good despite all the vertex data required.

'void main() \n' +
'{ \n' +
' czm_non_distanceDisplayCondition_main(); \n' +
' vec4 centerRTE = czm_computeBoundingSphereCenter(); \n' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this function? Did you forget to submit a file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, its generated just like czm_computePosition for all other geometries and the functions for getting adjacent points for polylines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it in a repo search or this diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, thanks!

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 9, 2016

Part of #758. Perhaps even close that and let the KML region support stay as part of the KML roadmap.

@bagnell bagnell mentioned this pull request Sep 16, 2016
@bagnell
Copy link
Contributor Author

bagnell commented Sep 19, 2016

This requires the batch table from #4328, so please review and merge that PR before this one.

@bagnell
Copy link
Contributor Author

bagnell commented Sep 27, 2016

@pjcozzi The reference doc is ready.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 27, 2016

Are you sure that we don't want distanceDisplayCondition to be part of the Model constructor (and billboard/label add just like scaleByDistance)?

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 27, 2016

Just those comments.

@bagnell
Copy link
Contributor Author

bagnell commented Sep 27, 2016

Are you sure that we don't want distanceDisplayCondition to be part of the Model constructor (and billboard/label add just like scaleByDistance)?

It is part of the constructors. The doc was missing for Model, but there is no doc for billboard/label options either on the constructor or on add.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 27, 2016

All good with me. @mramato please merge when ready. The changes to the entity layer are minor.

},
set : function(value) {
this._near = value;
this._near2 = value * value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicky, but as a generate practice, we would normally call this nearSquared.

* @param {DistanceDisplayCondition} [result] The result onto which to store the result.
* @return {DistanceDisplayCondition} The duplicated instance.
*/
DistanceDisplayCondition.clone = function(value, result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is used directly by the Entity api as well, it should have a prototype clone too. Right now the Entity API ends up making a new instance every time get value is called because no prototype clone is defined.

@mramato
Copy link
Contributor

mramato commented Sep 28, 2016

Point & Model does not seem to work at all in 2D or Columbus View.

@mramato
Copy link
Contributor

mramato commented Sep 28, 2016

Actually, I wasn't zoomed in enough. It appears to partially work but the model is never drawn.

@mramato
Copy link
Contributor

mramato commented Sep 28, 2016

This may be in master too, so create an issue if it's not related to this branch.

  1. Run the Sandcastle example.
  2. Switch to 2D
  3. Double click the point
  4. Switch to 3D. (The morph is all screwy)

@@ -649,7 +679,8 @@ define([
modelMatrix : !in3D ? modelMatrix : undefined,
attributes : {
show : new ShowGeometryInstanceAttribute(showOutline),
color : ColorGeometryInstanceAttribute.fromColor(outlineColor)
color : ColorGeometryInstanceAttribute.fromColor(outlineColor),
distanceDisplayCondition : distanceDisplayConditionAttribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be handled in the else path as well, just like show and color.

@mramato
Copy link
Contributor

mramato commented Sep 28, 2016

It doesn't look like any of the DynamicGeometryUpdater objects have been updated to set the displayCondition property on the underlying primitives. These are private classes that are part of each GeometryUpdater, just search for DynamicGeometryUpdater and you'll find them.

For the above, a corresponding test needs to be added to the dynamic updater sets properties test of each updated (again, searching for that phrase should reveal them all).

Basically, it looks like dynamic geometry never gets its display condition updated.

@mramato
Copy link
Contributor

mramato commented Sep 28, 2016

That's all I have for now. Thanks @bagnell

@bagnell
Copy link
Contributor Author

bagnell commented Sep 28, 2016

This may be in master too, so create an issue if it's not related to this branch.

  1. Run the Sandcastle example.
  2. Switch to 2D
  3. Double click the point
  4. Switch to 3D. (The morph is all screwy)

Models in 2D crash in master so I'll open an issue for it. In this branch the same weird morph happens for the model example.

@bagnell
Copy link
Contributor Author

bagnell commented Sep 28, 2016

Basically, it looks like dynamic geometry never gets its display condition updated.

All the dynamic geometries do update the distance display condition. It was only missing from that else block you mentioned above.

For the above, a corresponding test needs to be added to the dynamic updater sets properties test of each updated (again, searching for that phrase should reveal them all).

I didn't modify the test because it doesn't change any per-instance attributes besides show. Then, it makes sure that a primitive is created when true.

@mramato This is ready for another look. I'll add an issue for the model crash in 2D.

@mramato
Copy link
Contributor

mramato commented Sep 29, 2016

Scene/GroundPrimitive renders with distance display condition per instance attribute is failing on my machine.

@bagnell
Copy link
Contributor Author

bagnell commented Sep 29, 2016

@mramato The test is fixed. It wasn't updated with the other tests that were failing in master.

@mramato
Copy link
Contributor

mramato commented Sep 29, 2016

👍

@mramato mramato merged commit f1a5ff4 into master Sep 29, 2016
@mramato mramato deleted the distance-display-condition branch September 29, 2016 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants