-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Recompute Aabbs for updated Meshes #7971
base: main
Are you sure you want to change the base?
Conversation
I'm not sure I understand your comment about asset preprocessing. Isn't the point of this to be able to recompute AABBs on runtime meshes? Spawning a mesh will already create the correct AABB. Asset preprocessing will help of course, but this will still need to exist for people making dynamic runtime meshes. |
if let Some(aabb) = changed.get(&mesh_handle.id()) { | ||
*entity_aabb = *aabb; | ||
} else if removed.contains(&mesh_handle.id()) { | ||
commands.entity(entity).remove::<Aabb>(); |
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.
is it possible to get both a Created and Removed asset event for the same handle?
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.
I'm not certain, but I think we should probably code assuming this is possible, even if the current implementation happens to not make this possible (due to system ordering / deferred ops / etc).
I still think all of this state-syncing is a nightmare and we should try removing it entirely: Needs more benchmarking though |
I just put together a "store aabb directly on meshes" impl: cart@a465c1d (still needs benchmarking ... haven't been able to compile Tracy on my new debian install yet) |
Tested a few different stress tests. On ( I tried testing thread 'main' panicked at 'scene contains the unregistered type |
Hmm thats certainly a big perf difference (likely prohibitively so). Worth trying to see what we can optimize though. |
Sadly punting this to 0.12. We've run out of time and this needs more of it :) |
This is a pretty high impact bug: I'm in favor of getting any fix in rather than delaying another cycle. |
I think this could be updated to use the new AssetId. And there was some feedback. It’s a shame it has to do so many lookups but if the benchmarking for this looks ok then it seems reasonable. |
Objective
Partially address #4294. This was attempted in #4944 and #5423., but reverted in #5489.
Aabb
components are not updated when the underlyingMesh
has changed in some way.Solution
Recompute their
Aabb
when it's been updated or newly created.Note: this only addresses when the
Mesh
is updated itself, not when theHandle<Mesh>
has changed. I attempted to include aRef<Handle<Mesh>>::is_changed
check, but that easily added 1+ms onmany_cubes
to do what is basically zero work in that common case. I attempted to parallelize it withQueryParIter
, which shrunk it down to 360us, but it still was an excessive amount of work for basically nothing. This current implementation only incurs a cost when a Mesh is created or modified.I view this as a stop gap until we have a form of asset preprocessing that can be used to compute the Aabb offline, or force meshes to be immutable after construction and precompute it's Aabb ahead of time.
Changelog
TODO
Migration Guide
TODO