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

Do not throw when there are less unique positions than required for rendering. #2386

Merged
merged 8 commits into from
Jan 9, 2015

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Jan 8, 2015

For #2375. Geometry.createGeometry can now return undefined. If it does return undefined, it adds nothing to the batched geometry/draws nothing.

…polyline and polygon geometries return undefined when there are not enough unique points to create the geometry rather than throwing an exception.
@@ -812,6 +820,11 @@ define([
this._state = PrimitiveState.COMBINING;

when(promise, function(packedResult) {
if (!defined(packedResult)) {
that._state = PrimitiveState.FAILED;
Copy link
Contributor

Choose a reason for hiding this comment

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

What triggers this if block? If zero geometry is created because all instances were invalid after deduplication?

Copy link
Contributor

Choose a reason for hiding this comment

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

Everything else looks fine; I just want to better understand what the change in behavior is. If I create a PolylineGeometry with 3 identical points, the Primitive will no longer throw, but it looks like the state becomes failed? Does that also mean Primitive.ready will never be true either?

Copy link
Contributor

Choose a reason for hiding this comment

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

One more question, if I create a batch with 3 per-color instance geometries and one of them fails. What happens when I call getGeometryInstanceAttributes does that still work?

Ideally (in my opinion) for all intents and purposes duplicate geometries would lead to that particular geometry not being drawn, but everything else would be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What triggers this if block? If zero geometry is created because all instances were invalid after deduplication?

Yes.

Does that also mean Primitive.ready will never be true either?

Yes, I'll change that.

What happens when I call getGeometryInstanceAttributes does that still work?

If one of them fails, then it will return an empty object. If all of them are invalid, it will return undefined. I think it should be one or the other so I'll make it consistent. You think it should return a valid object to get and set the attribute, but not actually do anything? I think that might be useful so users won't have to check for undefined, but it'll be slower when creating new types arrays and it'll waste memory.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that might be useful so users won't have to check for undefined, but it'll be slower when creating new types arrays and it'll waste memory.

Since most of the time, geometry is valid, I think it's perfectly fine to always return an object (since when it's valid there's no slow down). The rare occasion that the geometry didn't get created isn't worth the pain of having users have to check for undefined the rest of the time. For example, all of the entity batching code for geometry assumes that a valid object will be returned if attributes were set; so I would have to update that if it suddenly starts returning undefined. If we expected lots of failures to be the norm, then I would feel differently.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 8, 2015

Update CHANGES.md.

@bagnell
Copy link
Contributor Author

bagnell commented Jan 8, 2015

@mramato This is ready for another look. I updated CHANGES.md, but I wasn't sure if this should go in the Breaking Changes section or not.

@mramato
Copy link
Contributor

mramato commented Jan 8, 2015

This all looks good to me, I wouldn't count this as a breaking change; more like an improvement in expected behavior. @pjcozzi did you want to look at this again? If not, feel free to hit merge.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 9, 2015

I agree with @mramato about the breaking change.

pjcozzi added a commit that referenced this pull request Jan 9, 2015
Do not throw when there are less unique positions than required for rendering.
@pjcozzi pjcozzi merged commit 96f3d2a into master Jan 9, 2015
@pjcozzi pjcozzi deleted the dups branch January 9, 2015 00:44
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