bevyengine / bevyengine/bevy

duplicate_vertices silently consumes indices

Open
#13,228 1 comment 2 reactions 0 assignees View on GitHub
A-Rendering C-Docs
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## How can Bevy's documentation be improved?

[`Mesh::duplicate_vertices`](https://docs.rs/bevy/0.13.2/bevy/render/mesh/struct.Mesh.html#method.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.

Contributor guide

Open the contributing guide

Research direction

Start with the linked Mesh::duplicate_vertices documentation and its implementation in the Bevy source to confirm how existing indices are handled. Update the method documentation to state the effect on indices, or clarify the intended API behavior if maintainers choose a code change; done means the documented behavior matches the implementation and the reported usage is unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.