bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Fix size of MeshVertexAttributeId to be platform independent

Open komadori opened this issue 3 years ago • 0 comments

Objective

MeshVertexAttributeId is currently a wrapper type around a usize. Application developers are exposed to the usize whenever they need to define a new custom vertex attribute, which requires them to generate a random usize ID to avoid clashes with any other custom vertex attributes in the same application. As the range of a usize is platform dependent, developers on 64-bit machines may inadvertently generate random values which will fail to compile for a 32-bit target. The use of a usize here encourages non-portable behaviour and should be replaced with a fixed width type.

Solution

In this PR I have changed the ID type from usize to u64, but equally a u32 could be used at the risk of breaking some extant non-portable programs and increasing the chance of an ID collision.

komadori avatar Nov 14 '22 22:11 komadori