Added code that allows for easier rendering of meshes#108
Open
Gip-Gip wants to merge 5 commits intotimschmidt:mainfrom
Open
Added code that allows for easier rendering of meshes#108Gip-Gip wants to merge 5 commits intotimschmidt:mainfrom
Gip-Gip wants to merge 5 commits intotimschmidt:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've found that in order to render triangulated meshes, it is necessary to do the following operations:
The end user could do this themselves but adding a function that does that for them would make things easier.
I added the
GraphicsMeshtype which contains all the info needed to render the mesh(not including texture data)and the
build_graphics_mesh()function to the Mesh type. It does perform a bit of calculation; it takes 40ms to convert around 119,988 triangles. But it uses about 40% less vram vs directly drawing triangles. It's not likely that this conversion function will be the bottleneck of a rendering pipeline.High-level PR Summary
This PR introduces a new
GraphicsMeshtype andbuild_graphics_mesh()method to simplify rendering of triangulated meshes. The function handles converting vertices fromf64tof32precision and removes redundant vertices by generating an indexed representation, which reduces VRAM usage by approximately 40% at the cost of a one-time conversion overhead (40ms for ~120k triangles). The changes add thebytemuckdependency for safe type casting between numeric types.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
Cargo.tomlCargo.locksrc/mesh/mod.rs