-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[surface] Reduce time taken in TextureMapping::sortFacesByCamera
from O(faces*points)
to O(faces)
#3981
Conversation
TextureMapping::sortFacesByCamera
from O(faces*points)
to O(faces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for this PR. Other clean-up in future
Minor: [&]
could have been used in the lambda, some comment cleanup (for and around the lambda)
I didn't look at the lambda but indeed: currently every capture is copied into the lambda, which looks needlessly expensive here. If I'm not mistaken it's even copied at each iteration. |
@kunaltyagi @Morwenn Just committed again. I had errors compiling at first with the [&] but that has been fixed. I've changed it back to [&] now and it works. Thanks for the corrections! |
Please rebase so we can test on the now working Mac and Ubuntu 20.04 CI |
… to be an unordered set. Previously, the system was checking through a vector in O(n), but now it's going much faster at approximately O(1).
… method than before as per @Morwenn 's suggestion
… errors led me to believe that I needed to list all captures, but now that those other errors have been ironed out, @kunaltyagi and @Morwenn have pointed out that that was unnecessary and is in fact computationally wasteful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply the following suggestions and if CI goes green go ahead and merge.
Note: squash and merge |
For large meshes, the old code was prohibitively slow, and had a TODO to address that. Changing from a vector to an unordered_set reduces the outer loop's complexity from O(N*M) to O(N) where N is the number of faces in a mesh and M is the number of points in the point cloud.
On the sample mesh I was using, I reduced the processing time for 3 test images from over 20 minutes to under 2.