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

Optimize Path3DGizmo mesh generation #83741

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

BlueCube3310
Copy link
Contributor

@BlueCube3310 BlueCube3310 commented Oct 21, 2023

Optimizes the way Path3d editor preview meshes are generated by avoiding unnecessary reallocations and COW, as suggested by AThousandShips in #83698 (comment).

Also fixes a bug where the function would reach outside of the frames array when generating _collision_segments.

The function itself is bottlenecked mainly by the sample_baked function and as such the resulting times vary between 3.5s and 5.0s.

As for the changes with the modified part of the function:
Build: editor x64 --production=yes & debug_symbols=yes

Path3D with baked length of 26744.5:

master PR
0.03s 0.005s

@clayjohn
Copy link
Member

How much did performance improve in your tests?

@BlueCube3310
Copy link
Contributor Author

After experimenting more with the --production build, the modified part of the function seems to perform about 5-6 times faster. The redraw function as a whole yields heavily varying results, as no matter which build is tested (master or this PR) the time takes between 3.5 and 5.0 seconds.

@BlueCube3310 BlueCube3310 marked this pull request as draft October 21, 2023 23:04
@fire
Copy link
Member

fire commented Oct 23, 2023

Let us know when this is ready for review.

@BlueCube3310 BlueCube3310 marked this pull request as ready for review October 23, 2023 17:21
@BlueCube3310
Copy link
Contributor Author

BlueCube3310 commented Oct 23, 2023

It's ready now.
I also feel like it's worth mentioning that the performance difference is most significant on older CPUs, while on the most modern ones it's not particularily noticeable.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it works as expected (gizmo appearance is identical to before, and editing the gizmo still looks correct).

@clayjohn clayjohn modified the milestones: 4.x, 4.3 Dec 6, 2023
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for following up

@YuriSizov YuriSizov merged commit 959c166 into godotengine:master Dec 8, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@YuriSizov YuriSizov changed the title Optimize Path3DGizmo Mesh Generation Optimize Path3DGizmo mesh generation Dec 21, 2023
@BlueCube3310 BlueCube3310 deleted the path-3d-plugin-optimize branch April 25, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants