-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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 2D MultiMesh hierarchical culling #80106
Conversation
a71f305
to
ed8afb3
Compare
ed8afb3
to
1bf56c5
Compare
1bf56c5
to
a2eb98b
Compare
a2eb98b
to
971521b
Compare
Fixes updating local bounds for MultiMeshes used in canvas items by introducing a back link.
971521b
to
ad577e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes make sense, code looks good AFAICT.
I'd say don't merge without @clayjohn's review though.
Thanks! |
Woops, I missed that one before merging. I'll ask Clay to review post-merge when he has time. |
It looks fine from a visual review! |
Fixes updating local bounds for MultiMeshes used in canvas items by introducing a back link.
This version as well as fixing
CPUParticles2D
, also fixesMultiMeshInstance2D
and direct use ofVisualServer
.Fixes #80086
Alternative to #80090
before
culling_broken.mp4
after
culling_fixed.mp4
This PR is basically an automated version of #80090 .
canvas_item_invalidate_local_bound()
is called automatically when changing theMultiMesh
. This means users don't have to call this function.The downside is that the machinery for maintaining the backlink is fairly complex, and complexity often equals bug prone and more maintenance burden. The system is equivalent to that used for
Skeleton
, which maintains a backlink to thecanvas_item
. However, the situation here is more complex for two reasons:MultiMesh
references are stored in Item commands, rather than directly in thecanvas_item
. This means that adding / removing links has to to take place via the command list, rather than directly via thecanvas_item
. There can also potentially be multiple commands referencing the sameMultiMesh
. There is no need to reference count here, because commands are only cleared all at once, so there either is, or is not a reference held at any one time.MultiMesh
being deleted before thecanvas_item
, and the other way around, with code to support both.Designed to keep CanvasItem "light"
LocalVector
of linkedMultiMeshes
on theCanvasItem
, which would in some ways be simpler (with no need to iterate through commands). However we want to keepCanvasItem
as light as possible (mostCanvasItem
s will be rects, and not care aboutMultiMesh
), and storing the links in the commands is effectively "free", so it's probably worth the extra hassle.canvas_item
RID on eachCommand::MultiMesh
is a little superfluous, but it enables us to clear out the links in the destructor with no cost toCanvasItem
s that do not contain multimeshes. The 8 extra bytes is likely to be unimportant, because mostCommand::MultiMesh
es will only be stored singly onCanvasItems
. Essentially it is more important to keep the typicalCanvasItem
light than theCommand::MultiMesh
.There may be a slightly better way of doing this (e.g. using a static or global to store the canvas_item RID during deletion) but storing the canvas_item RID is at least thread safe.
Notes
MultiMeshInstance2D
we would have to introduce similar complexity scene side, so I'm now leading with this PR.