-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
add InfallibleMesh for mesh construction without unwraps #21986
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Jasmine S <[email protected]>
5f2babf to
e3ad522
Compare
|
I've skimmed the changes and couldn't spot any obvious issues. I'm not sold on the way But that's debatable, and the current version does solve an immediate problem. So maybe it's fine to get the current version in first, and make the case for follow on changes separately. |
|
That would mean having InfallibleMesh as a separate asset type? I can see lots of issues arising from that, on first glance I’m definitely on the opposite team for the debate… In case it helps with framing, I would have called it MeshBuilder if that wasn’t already taken. |
|
No, I didn't intend for InfallibleMesh to be a separate asset type. It's just a temporary helper. So the only change to the current PR would be to remove the implicit deref - then InfallibleMesh can only be turned into a Mesh through Actually... just checking the PR - InfallibleMesh currently derives Asset? Is that intended? Feels wrong regardless of which approach is taken. |
|
the reason for the deref was primitive builders that use we only allow read-only access to the mesh content though, so that we can still ensure it hasn't been extracted. i don't think i've quite understood the point about compression though - if it modifies the mesh and we don't want it to, we just avoid providing an InfallibleMesh compression method ... but maybe that's not what you meant? |
|
The scenario I'm imagining is that Mesh becomes more optimised for loading and GPU upload at some point in the future - maybe that's through compression, or interleaving attributes, or packing everything into a single allocation. Or maybe there's extra validation added to make sure attributes match up. These kinds of things are difficult to do incrementally as attributes are added - they want the attributes finalised first so they can validate or optimize everything in a single step. If InfallibleMesh can be deref'd to Mesh at any time then that could be difficult. It would be easier if the only way to get a Mesh value is through calling But I'm just speculating. Maybe the API ends up looking completely different. |
|
you're right about the Asset derive - removed, thanks. regarding invalid mesh states, i see what you're saying now, but agree we can cross that bridge when we come to it. |
|
Sounds good to me. Personally I'd be minded to approve this PR even though I'm not keen on the deref - it's still a step in the right direction. |
@greeble-dev 😅I realize that is a bit difficult and greatly breaks compatibility. Because |
|
My guess is that there'll be pressure to keep |
|
Iterating over compressed or interleaved vertex attributes might degrade mesh performance for CPU reads, not the complexity of handling it. If the goal is just to have a mesh that’s efficient for GPU uploads, a mechanism like I think the current Mesh interface is fine. Even modifying it can panic if it's extracted, I guess most users would still use Mesh over InfallibleMesh. |
|
In my view, the key issue is separating the mesh types optimized for writing from the mesh types optimized for reading. I'm also assuming there would be multiple types optimised for different kinds of reads - so having physics be able to read GPU mesh data is a useful convenience in some situations, but for situations where performance is more important there would be a separate type optimized for physics. So I see this PR as a step forward to separating read and write types. I'm not so worried about which of those types ends up getting called |
Objective
InfallibleMeshbuilder type suggested by @greeble-dev in Retain asset without data for RENDER_WORLD-only assets #21732 (review)try_xxxmethods fromMesh, make the base methods returnResultsSolution
builds on #21732 - could replace that, but i thought better to raise a different PR to keep the changes separated as this touches quite a lot more of the codebase. to see the diff for just this pr i created https://github.com/robtfm/bevy/pull/5/files which applies this onto the original pr.
InfallibleMeshtype for use during cpu-side mesh construction, which wrapsMeshand ensures that the internal mesh data can't be extracted.From<primitives> for Meshcode: remove ~30 individualFrom<T> for Meshimplementations and replace with a blanket impl, supported by modifyingMeshable::meshto takeselfinstead of&self. basically all existing implementations were copying or cloning self anyway, so this doesn't seem like it should cause any issues.Changelog
Existing accessor methods on
Meshhave been changed to return aResult<T, MeshAccessError>which will return an error if the Mesh has been extracted to theRenderWorld.When constructing meshes we now recommend using the
InfallibleMeshtype which guarantees the internal data cannot be extracted prior to being converted into a normal mesh.