Skip to content

Added code that allows for easier rendering of meshes#108

Open
Gip-Gip wants to merge 5 commits intotimschmidt:mainfrom
Gip-Gip:fix-vetind-gen
Open

Added code that allows for easier rendering of meshes#108
Gip-Gip wants to merge 5 commits intotimschmidt:mainfrom
Gip-Gip:fix-vetind-gen

Conversation

@Gip-Gip
Copy link
Copy Markdown

@Gip-Gip Gip-Gip commented Nov 16, 2025

I've found that in order to render triangulated meshes, it is necessary to do the following operations:

  • Convert all f64s to f32s
  • Remove redundant vertices and generate indices for rendering

The end user could do this themselves but adding a function that does that for them would make things easier.

I added the GraphicsMesh type 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 GraphicsMesh type and build_graphics_mesh() method to simplify rendering of triangulated meshes. The function handles converting vertices from f64 to f32 precision 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 the bytemuck dependency for safe type casting between numeric types.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 Cargo.toml
2 Cargo.lock
3 src/mesh/mod.rs

Need help? Join our Discord

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant