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

huge speedup possible: meshes are regenerated unnecessarily when settings (eg radius) are set to their existing value #99414

Closed
lighttroupe opened this issue Nov 19, 2024 · 3 comments · Fixed by #99498

Comments

@lighttroupe
Copy link

lighttroupe commented Nov 19, 2024

Tested versions

v4.2.2.stable.official [15073af]

System information

Ubuntu 22.04

Issue description

Mesh (such as a Sphere) is regenerated, wasting work, when the result will be exactly the same.

Steps to reproduce

Add this to a _process():

mesh.radius = 0.5

(in a real-world app, the value is calculated every frame based on user settings, but when the value is not changing, it still rebuilds the mesh)

Minimal reproduction project (MRP)

void SphereMesh::set_radius(const float p_radius) {

I'm wondering if a line like this would be appropriate:

if is_equal_approx(radius, p_radius) { return }

Otherwise, the app has to do it in GDScript, which is much slower than C++, duplicated work across godot apps, etc.

I think this easy optimization should be added everywhere in Godot when changing a setting triggers heavy work.

If this is not implemented, then the docs should be updated to warn about the performance hit "even if setting to the same value".

@carsonetb
Copy link
Contributor

I'd be interested in helping with this ... it seems like a very easy optimization.

I could start working on a PR if you don't want to do it yourself, it seems like you've already found a lot of the source code.

@lighttroupe
Copy link
Author

lighttroupe commented Nov 19, 2024

Please do go ahead! I think all the mesh types could use this speedup.

I'm not sure the process in this project, doesn't anyone need to greenlight this?

@carsonetb
Copy link
Contributor

carsonetb commented Nov 19, 2024

According to the godot docs anyone can submit a pull request ... I think the main process for creating one is someone should submit an issue, and the pull request fixes that issue.

Anyway, I'll start working on a pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants