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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay CSG mesh updates with a debounce timer to improve editor responsiveness #4448

Open
Calinou opened this issue Apr 26, 2022 · 1 comment

Comments

@Calinou
Copy link
Member

Calinou commented Apr 26, 2022

Describe the project you are working on

The Godot editor 馃檪

Describe the problem or limitation you are having in your project

Editing complex CSG trees can be slow, since the CSG mesh is regenerated every time a change is made. This can occur every frame when dragging one of the handles or moving the node using the 3D manipulation gizmos.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a debounce delay to prevent CSG mesh updates from occurring too often while moving CSG nodes around.

This debounce delay should be adjustable with a project setting, in case you're actually using CSG for real-time purposes (which isn't recommended for performance reasons). I suggest setting this debounce delay to 0.1 seconds by default, but it may have to be tweaked in the future.

Alternatively, we can make this debounce delay effective only within the editor. This way, exported projects wouldn't be affected by this change.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This can be done with an internal timer that is kept track of in each CSG node. Since CSG mesh generation works on a per-tree basis, only the timer at the topmost of each CSG tree would be taken into account. Child nodes would modify the parent's timer node, and child nodes' timer value would be ignored.

Every time a change is made that requires updating the mesh, the timer is set to its maximum time and is started.
When time reaches zero, an update of the CSG mesh is queued.

I recommend not using a Timer node for this for performance reasons. Using a float variable instead will likely perform better.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

CSG is core engine functionality.

@QbieShay
Copy link

QbieShay commented Jun 3, 2022

This sounds like a good addition - my only comment on this is that i think that the debounce should be homogenous between editor and runtime: i think there could be cases where people see it running smoothly in the engine but it ends up lagging in the game (because of the high frequency of updates)

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

No branches or pull requests

2 participants