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

feat(pointcloud): use 'changeSource' mechanism to avoid useless work #719

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

peppsac
Copy link
Contributor

@peppsac peppsac commented Apr 9, 2018

Implements a simple logic to avoid updating the full layer if we
already know that the result won't change.

This feature is already implemented for tile based layers
(see 3f340b9).

@peppsac peppsac force-pushed the feat_pointcloud_change_sources branch from 7ef054e to 9643de9 Compare April 10, 2018 07:59
}
}
}
if (commonAncestorName && commonAncestorName.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(neat) I guess the second test (after &&) is useless, so this could be simplified to if (commonAncestorName).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed: fixed.

preUpdate(context, layer) {
// TODO: use changeSource
layer.counters = {
pointCount: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the pointcloud.js and pointcloud_globe.js examples refer to pointcloud.counters.pointCount. Wouldn't that be a problem if you removed that count?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if you just keep displayedCount you may want to go with layer.displayCount instead of having an intermediary layer.counters object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@elemoine elemoine left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@elemoine
Copy link
Contributor

Just a quick unrelated note:

I note that iTowns often dynamically adds properties to objects. For example, layer.displayedCount in this patch. For performance it is better to set properties at object construction time, and not dynamically add properties afterwards. See for example the Hidden Classes section in this HTML5 Rocks article. For that reason I think it's a good thing to more strictly type things, using specific object constructors/types. For example I think the Layer constructor should look like this:

function  Layer(options) {
    this.name = options.name;
    this.projection = options.projection;
    
    this.displayedCount = 0;
}

It also makes the code more readable, and easier to document.

Just my 2 cents, and sorry for the unrelated comment here :)

Copy link
Contributor

@zarov zarov left a comment

Choose a reason for hiding this comment

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

LGTM, great improvement.

A question though (that have nothing to do with this PR): why is the node name is stored as a string ? Wouldn't be more efficient to store it with something as an octal ? I think it would simplify operation on it, and it could be simply converted to a string when needed. Nevermind, tried it up, not efficient.

@zarov
Copy link
Contributor

zarov commented Apr 11, 2018

@elemoine I agree completely on this, there could be improvement made here.

// some invisible tiles may now be visible
return [layer.root];
}
if (source.obj === undefined) {
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 remember where this obj came from?
it's an Object3D?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (source.obj === undefined) {
continue;
}
if (source.obj.isPoints && source.obj.layer == layer.id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you could add comment to explain this part with commonAncestorName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -206,6 +219,8 @@ export default {
// eslint-disable-next-line no-console
console.log('LAYER metadata:', root);
layer.root = root;
root.findChildrenByName = findChildrenByName.bind(root, root);
Copy link
Contributor

Choose a reason for hiding this comment

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

why you use bind?

Copy link
Contributor

Choose a reason for hiding this comment

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

To do currying and pre-set the first argument to root.

Implements a simple logic to avoid updating the full layer if we
already know that the result won't change.

This feature is already implemented for tile based layers
(see 3f340b9).
@peppsac peppsac force-pushed the feat_pointcloud_change_sources branch from 32f104c to 38e7c11 Compare April 13, 2018 08:18
@peppsac peppsac merged commit b67670a into master Apr 13, 2018
@peppsac peppsac deleted the feat_pointcloud_change_sources branch April 13, 2018 08:53
peppsac added a commit that referenced this pull request Apr 16, 2018
This commit fixes a left-over from #719
zarov pushed a commit that referenced this pull request Apr 16, 2018
This commit fixes a left-over from #719
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.

4 participants