godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.38k stars 21.26k forks source link

Optimize mesh generation by preventing unneeded shape recalculations #99498

Closed carsonetb closed 2 days ago

carsonetb commented 4 days ago

Currently whenever a value of a PrimitiveMesh is set in GDScript it will completely regenerate the entire mesh. This is fine in most cases, but in the case that the set variable is the same as the current variable (p_radius == radius), there's no need to regenerate the mesh. In some cases we could get a big performance boost by just returning the function if the set variable is the same as the current one.

This PR fixes #99414

carsonetb commented 3 days ago

This should be ready to merge, unless anyone has any more seggustions!

Repiteo commented 2 days ago

Thanks! Congratulations on your first merged contribution! 🎉

lighttroupe commented 2 days ago

Fantastic work, @carsonetb

I was surprised to read on your profile that you're a middle schooler. Your communication on the original issue and here, use of git, PR naming, is all excellent. Keep it up; you're going to go far!

elouangrimm commented 2 days ago

Congrats @carsonetb! :)