diff --git a/src/lol/base/types.h b/src/lol/base/types.h index c7bf81b2..e02016a2 100644 --- a/src/lol/base/types.h +++ b/src/lol/base/types.h @@ -65,6 +65,14 @@ template struct dualquat_t; _T(vec_t<, _C 2>, vec2) _T(vec_t<, _C 3>, vec3) _T(vec_t<, _C 4>, vec4) +_T(vec_t<, _C 5>, vec5) +_T(vec_t<, _C 6>, vec6) +_T(vec_t<, _C 7>, vec7) +_T(vec_t<, _C 8>, vec8) +_T(vec_t<, _C 9>, vec9) +_T(vec_t<, _C 10>, vec10) +_T(vec_t<, _C 11>, vec11) +_T(vec_t<, _C 12>, vec12) _T(mat_t<, _C 2 _C 2>, mat2) _T(mat_t<, _C 3 _C 3>, mat3) @@ -91,6 +99,14 @@ _T(dualquat_t<, >, dualquat) typedef vec2 float2; typedef vec3 float3; typedef vec4 float4; +typedef vec5 float5; +typedef vec6 float6; +typedef vec7 float7; +typedef vec8 float8; +typedef vec9 float9; +typedef vec10 float10; +typedef vec11 float11; +typedef vec12 float12; typedef mat2 float2x2; typedef mat3 float3x3; typedef mat4 float4x4; @@ -117,6 +133,14 @@ typedef f16mat4x3 half4x3; typedef ivec2 int2; typedef ivec3 int3; typedef ivec4 int4; +typedef ivec5 int5; +typedef ivec6 int6; +typedef ivec7 int7; +typedef ivec8 int8; +typedef ivec9 int9; +typedef ivec10 int10; +typedef ivec11 int11; +typedef ivec12 int12; typedef imat2 int2x2; typedef imat3 int3x3; typedef imat4 int4x4; diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 92e49c2a..0c8feb59 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -20,6 +20,7 @@ #include #include +#include namespace lol { @@ -118,6 +119,14 @@ struct vec_t } inline ~vec_t() {} + /* Explicit constructor that takes exactly N arguments thanks to SFINAE. */ + template + explicit inline vec_t(typename std::enable_if + ::type const &x, ARGS... args) + { + internal_init(m_data, x, args...); + } + /* Explicit constructor for type conversion */ template explicit inline vec_t(vec_t const &v) @@ -148,6 +157,18 @@ struct vec_t inline T const& operator[](size_t n) const { return m_data[n]; } private: + template + static inline void internal_init(T *data, T const &x, ARGS... args) + { + *data++ = x; + internal_init(data, args...); + } + + static inline void internal_init(T *data) + { + UNUSED(data); + } + T m_data[count]; }; diff --git a/tools/vimlol/vimlol.vim b/tools/vimlol/vimlol.vim index 30b01c31..f3e9b4e0 100644 --- a/tools/vimlol/vimlol.vim +++ b/tools/vimlol/vimlol.vim @@ -23,12 +23,12 @@ au Syntax cpp " GLSL types and the Lol Engine extensions au Syntax cpp \ syn match cType - \ "\<\(f16\|\|f64\|f128\|r\|[iu]\(8\|16\|\|64\)\)\(vec[234]\|cmplx\|quat\|mat\([234]\|2x3\|3x2\|3x4\|4x3\|2x4\|4x2\)\)\>" + \ "\<\(f16\|\|f64\|f128\|r\|[iu]\(8\|16\|\|64\)\)\(vec\([23456789]\|1[012]\)\|cmplx\|quat\|dualquat\|mat\([234]\|2x3\|3x2\|3x4\|4x3\|2x4\|4x2\)\)\>" -" HLSL types +" HLSL types and the Lol Engine extensions au Syntax cpp \ syn match cType - \ "\<\(int\|half\|float\)[234]\(\|x[234]\)\>" + \ "\<\(int\|half\|float\)\([23456789]\|1[012]\|[234]x[234]\)\>" " More GLSL-like types from the Lol Engine au Syntax cpp