Skip to content
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

duplicate_vertices silently consumes indices #13228

Open
tbillington opened this issue May 4, 2024 · 1 comment
Open

duplicate_vertices silently consumes indices #13228

tbillington opened this issue May 4, 2024 · 1 comment
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation

Comments

@tbillington
Copy link
Contributor

How can Bevy's documentation be improved?

Mesh::duplicate_vertices silently takes indices from the Mesh but doesn't mention it in the method documentation.

This lead to my code breaking because it relied upon indices being present. I added a call to duplicate_vertices and didn't realise my later code that did something for each index was now not running.

I assume not rebuilding the index data is an optimisation. Either way this behaviour should be documented or the code should rebuild the index data if it was previously present.

An alternative could be to have a function duplicate_vertices_without_indices (naming aside) that would have the current behaviour, and change duplicate_vertices to rebuild the index data before finishing. I'm thinking along the same lines as Vec::sort and Vec::sort_unstable, or Vec::remove and Vec::swap_remove having longer/different names for behaviours that have side effects the programmer should take note of.

@tbillington tbillington added C-Docs An addition or correction to our documentation S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@VVishion
Copy link
Contributor

VVishion commented May 9, 2024

The way I see this function is:
It expands the vertices so that no vertex position is reused. Therefore no index appears twice in the index array and may only order the vertices. Now order the vertices array and you dont need the index data anymore.

This can obviously be better documented, but this side effect can be implied with some knowledge about the rasterization process. But - yes - as you have suggested, its only implicit.
I would argue expand_vertices, or even something like integrate_indices is a better name, though. There are probably even better ones.

@james7132 james7132 added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation
Projects
None yet
Development

No branches or pull requests

3 participants