bitshifter / glam-rs

A simple and fast linear algebra library for games and graphics
Apache License 2.0
1.48k stars 151 forks source link

Short Vec types #248

Closed anderslanglands closed 2 years ago

anderslanglands commented 2 years ago

Hi, I'm a big fan of your crate for graphics stuff. One thing that's missing that would be useful for vulkan, optix etc would be a 16-bit integer vec type, basically IVecX but with i16 instead of i32 (SVec3 etc perhaps?). Would you accept a PR adding this?

bitshifter commented 2 years ago

Hi there!

I'm interested in hearing a bit more about your use case for i16 vector types if you can talk about it.

This is a bit of a Pandora's Box because obviously there are a lot of types that glam still doesn't support and not being a generic lib each type needs to have their implementation added. That said, if this is a common thing that is needed then I am not opposed to adding them, although I have so far resisted in some cases (e.g. #232). It isn't that hard to add new types as most of the implementation could reuse the existing macros.

It seems that i16 etc. extensions to glsl have been proposed by nvidia and amd. Naming wise I've tended to use glsl style naming so far so that's what I'd suggest (with Rust capitialization, e.g. I16Vec3).

tl;dr I would be open to a PR. It might make sense to have this on a feature toggle initially, it would be good to check if there's any noticeable compile time / size increase from expanding the number of types, especially if they expand beyond i16. If they're more niche a feature would mean general users wouldn't need to pay for things they don't use.