mirror of
https://github.com/g-truc/glm.git
synced 2025-04-10 15:23:53 +00:00
Remove unneccesary vec_swizzle
overloads and added a script to generate them
This commit is contained in:
parent
a81871a8a4
commit
a04b1af3fa
2 changed files with 354 additions and 2740 deletions
File diff suppressed because it is too large
Load diff
18
util/generate_swizzle_functions.py
Normal file
18
util/generate_swizzle_functions.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import itertools
|
||||
|
||||
def make_swizzlers(letters, vector_length):
|
||||
if vector_length == 4:
|
||||
template = "template<typename T, qualifier Q> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<{vector_length},T,Q> {function_name}(vec<4,T,Q> const& v) {{ return vec<4,T,Q>({swizzle}); }}"
|
||||
else:
|
||||
template = "template<length_t L, typename T, qualifier Q> GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<{vector_length},T,Q> {function_name}(vec<L,T,Q> const& v) {{ return vec<{vector_length},T,Q>({swizzle}); }}"
|
||||
for perm in itertools.product(letters, repeat=vector_length):
|
||||
print(template.format(
|
||||
vector_length=vector_length,
|
||||
function_name=''.join(perm),
|
||||
swizzle=', '.join([f'v.{i}' for i in perm])
|
||||
))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for i in range(2,5):
|
||||
make_swizzlers(['x', 'y', 'z', 'w'], i)
|
Loading…
Add table
Reference in a new issue