-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
[3.x] Fix CPUParticles2D hierarchical culling #80090
[3.x] Fix CPUParticles2D hierarchical culling #80090
Conversation
Useful for debugging hierarchical culling.
So if this is going to be merged as is then relevant docs (for multimeshes / hierarchical culling (does it have docs?) / something else?) would need to be updated to mention this, probably by adding some warning notes. |
I'll also try an alternative PR which works similar to skeleton and produces a back link from the multimesh to the canvas_item. I'm not sure which would be better at this stage, but the latter has the advantage that it requires no changes from the user, even when using the servers directly. There are no significant docs for hierarchical culling so far (other than the project setting itself), simply because it shouldn't require any, there's no changes required. Which would be kind of nice to keep. But if we go with this PR I can add a note to the docs for multimesh. It's basically a choice between:
UPDATE: UPDATE 2: |
Updating the MultiMesh was previously not triggering a recalculation of local bounds in the hierarchical culling system. This PR adds an explicit function `canvas_item_invalidate_local_bound()` to trigger this update, and ensure particles are correctly culled.
e67ccf3
to
9ac4435
Compare
Actually given all the permutations involved (with |
Updating the MultiMesh was previously not triggering a recalculation of local bounds in the hierarchical culling system. This PR adds an explicit function
canvas_item_invalidate_local_bound()
to trigger this update, and ensure particles are correctly culled.This is called automatically by
CPUParticles2D
, but those users using 2D multimeshes viaVisualServer
directly will need to callcanvas_item_invalidate_local_bound()
.Fixes #80086
First commit is #80084 , that is useful for debugging and verifying the fix.
before
culling_broken.mp4
after
culling_fixed.mp4
Discussion
There are several ways of fixing this. It is possible to introduce a back link from the
MultiMesh
to the canvas item, and automatically invalidate the local bounds when it is updated. This is the system used for skeletons. However in this case the extra machinery seemed like overkill, and the same function could potentially be used to fix other cases of the same class of problem.On the downside, this does mean that currently users updating 2D multimeshes directly to the
VisualServer
will be responsible for calling this function themselves, when using hierarchical culling.I'm unsure which is best longterm, but this PR is nice and simple to get started, and may do the job, and we can always change to the other approach if feedback in a beta suggests it is needed.
GPUParticles2D
On further examination, GPU version only currently supports custom bounds, so there don't seem any changes needed.
Demo
particle_culling.zip
Just run it, the debug rect shows the local bounds correctly updating for the particles, even when the origin is offscreen.