From e3220b2d743511802f020f412f70ae72bf28e2fc Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 4 Feb 2012 22:18:26 +0000 Subject: [PATCH] math: some simplifications in the magic vector templates, and some macros removed because they were used only once. --- src/lol/math/matrix.h | 1191 ++++++++++++++++++++--------------------- 1 file changed, 592 insertions(+), 599 deletions(-) diff --git a/src/lol/math/matrix.h b/src/lol/math/matrix.h index 205d68e3..78eaa44f 100644 --- a/src/lol/math/matrix.h +++ b/src/lol/math/matrix.h @@ -50,30 +50,39 @@ VECTOR_TYPES(Quat, quat) VECTOR_TYPES(Mat4, mat4) /* - * Magic swizzling (part 1/2) + * Magic vector swizzling (part 1/2) */ -template struct MagicVec2 +template struct XVec2 { inline Vec2 operator =(Vec2 that); - float ptr[1 + (I > J ? I : J)]; + static int const I = (N >> 2) & 3; + static int const J = (N >> 0) & 3; + T ptr[1 + (I > J ? I : J)]; }; -template struct MagicVec3 +template struct XVec3 { inline Vec3 operator =(Vec3 that); - float ptr[1 + (I > J ? I > K ? I : K - : J > K ? J : K)]; + static int const I = (N >> 4) & 3; + static int const J = (N >> 2) & 3; + static int const K = (N >> 0) & 3; + T ptr[1 + (I > J ? I > K ? I : K + : J > K ? J : K)]; }; -template struct MagicVec4 +template struct XVec4 { inline Vec4 operator =(Vec4 that); - float ptr[1 + (I > J ? I > K ? I > L ? I : L : K > L ? K : L - : J > K ? J > L ? J : L : K > L ? K : L)]; + static int const I = (N >> 6) & 3; + static int const J = (N >> 4) & 3; + static int const K = (N >> 2) & 3; + static int const L = (N >> 0) & 3; + T ptr[1 + (I > J ? I > K ? I > L ? I : L : K > L ? K : L + : J > K ? J > L ? J : L : K > L ? K : L)]; }; /* @@ -86,52 +95,6 @@ template struct MagicVec4 \ void printf() const; -#define COMPLEX_OPS() \ - inline type_t operator *(type_t const &val) const \ - { \ - return type_t(x * val.x - y * val.y, x * val.y + y * val.x); \ - } \ - \ - inline type_t operator *=(type_t const &val) \ - { \ - return *this = (*this) * val; \ - } \ - \ - inline type_t operator ~() const \ - { \ - return type_t(x, -y); \ - } \ - \ - inline T norm() const { return len(*this); } - -#define QUATERNION_OPS() \ - inline type_t operator *(type_t const &val) const \ - { \ - type_t ret; \ - Vec3 v1(x, y, z); \ - Vec3 v2(val.x, val.y, val.z); \ - Vec3 v3 = cross(v1, v2) + w * v2 + val.w * v1; \ - ret.x = v3.x; \ - ret.y = v3.y; \ - ret.z = v3.z; \ - ret.w = w * val.w - dot(v1, v2); \ - return ret; \ - } \ - \ - inline type_t operator *=(type_t const &val) \ - { \ - return *this = (*this) * val; \ - } \ - \ - inline type_t operator ~() const \ - { \ - type_t ret; \ - for (int n = 0; n < 3; n++) \ - ret[n] = -(*this)[n]; \ - ret[3] = (*this)[3]; \ - return ret; \ - } - #define OTHER_MEMBER_OPS(tname) \ template \ inline operator tname() const \ @@ -148,19 +111,18 @@ template struct MagicVec4 template struct Vec2 { - typedef Vec2 type_t; + inline Vec2() {} + inline Vec2(T X, T Y) : x(X), y(Y) {} - inline Vec2() { } - explicit inline Vec2(T val) { x = y = val; } - inline Vec2(T _x, T _y) { x = _x; y = _y; } + explicit inline Vec2(T X) : x(X), y(X) {} - template - inline Vec2(MagicVec2 const &v) - : x(v.ptr[I]), y(v.ptr[J]) {} + template + inline Vec2(XVec2 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]) {} - template - explicit inline Vec2(MagicVec2 const &v) - : x(v.ptr[I]), y(v.ptr[J]) {} + template + explicit inline Vec2(XVec2 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]) {} MEMBER_OPS() OTHER_MEMBER_OPS(Vec2) @@ -176,34 +138,34 @@ template struct Vec2 struct { T r, g; }; struct { T s, t; }; - MagicVec2 xx, rr, ss; - MagicVec2 xy, rg, st; - MagicVec2 yx, gr, ts; - MagicVec2 yy, gg, tt; - MagicVec3 xxx, rrr, sss; - MagicVec3 xxy, rrg, sst; - MagicVec3 xyx, rgr, sts; - MagicVec3 xyy, rgg, stt; - MagicVec3 yxx, grr, tss; - MagicVec3 yxy, grg, tst; - MagicVec3 yyx, ggr, tts; - MagicVec3 yyy, ggg, ttt; - MagicVec4 xxxx, rrrr, ssss; - MagicVec4 xxxy, rrrg, ssst; - MagicVec4 xxyx, rrgr, ssts; - MagicVec4 xxyy, rrgg, sstt; - MagicVec4 xyxx, rgrr, stss; - MagicVec4 xyxy, rgrg, stst; - MagicVec4 xyyx, rggr, stts; - MagicVec4 xyyy, rggg, sttt; - MagicVec4 yxxx, grrr, tsss; - MagicVec4 yxxy, grrg, tsst; - MagicVec4 yxyx, grgr, tsts; - MagicVec4 yxyy, grgg, tstt; - MagicVec4 yyxx, ggrr, ttss; - MagicVec4 yyxy, ggrg, ttst; - MagicVec4 yyyx, gggr, ttts; - MagicVec4 yyyy, gggg, tttt; + XVec2 xx, rr, ss; + XVec2 xy, rg, st; + XVec2 yx, gr, ts; + XVec2 yy, gg, tt; + XVec3 xxx, rrr, sss; + XVec3 xxy, rrg, sst; + XVec3 xyx, rgr, sts; + XVec3 xyy, rgg, stt; + XVec3 yxx, grr, tss; + XVec3 yxy, grg, tst; + XVec3 yyx, ggr, tts; + XVec3 yyy, ggg, ttt; + XVec4 xxxx, rrrr, ssss; + XVec4 xxxy, rrrg, ssst; + XVec4 xxyx, rrgr, ssts; + XVec4 xxyy, rrgg, sstt; + XVec4 xyxx, rgrr, stss; + XVec4 xyxy, rgrg, stst; + XVec4 xyyx, rggr, stts; + XVec4 xyyy, rggg, sttt; + XVec4 yxxx, grrr, tsss; + XVec4 yxxy, grrg, tsst; + XVec4 yxyx, grgr, tsts; + XVec4 yxyy, grgg, tstt; + XVec4 yyxx, ggrr, ttss; + XVec4 yyxy, ggrg, ttst; + XVec4 yyyx, gggr, ttts; + XVec4 yyyy, gggg, tttt; }; }; @@ -213,16 +175,28 @@ template struct Vec2 template struct Cmplx { - typedef Cmplx type_t; - - inline Cmplx() { } - inline Cmplx(T val) : x(val), y(0) { } - inline Cmplx(T _x, T _y) : x(_x), y(_y) { } + inline Cmplx() {} + inline Cmplx(T X) : x(X), y(0) {} + inline Cmplx(T X, T Y) : x(X), y(Y) {} MEMBER_OPS() - COMPLEX_OPS() + inline Cmplx operator *(Cmplx const &val) const + { + return Cmplx(x * val.x - y * val.y, x * val.y + y * val.x); + } + + inline Cmplx operator *=(Cmplx const &val) + { + return *this = (*this) * val; + } + + inline Cmplx operator ~() const + { + return Cmplx(x, -y); + } + inline T norm() const { return len(*this); } #if !defined __ANDROID__ template friend std::ostream &operator<<(std::ostream &stream, Cmplx const &v); @@ -273,21 +247,20 @@ static inline bool operator !=(T a, Cmplx const &b) { return b != a; } template struct Vec3 { - typedef Vec3 type_t; + inline Vec3() {} + inline Vec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {} + inline Vec3(Vec2 XY, T Z) : x(XY.x), y(XY.y), z(Z) {} + inline Vec3(T X, Vec2 YZ) : x(X), y(YZ.x), z(YZ.y) {} - inline Vec3() { } - explicit inline Vec3(T val) { x = y = z = val; } - inline Vec3(T _x, T _y, T _z) { x = _x; y = _y; z = _z; } - inline Vec3(Vec2 _xy, T _z) { x = _xy.x; y = _xy.y; z = _z; } - inline Vec3(T _x, Vec2 _yz) { x = _x; y = _yz.x; z = _yz.y; } + explicit inline Vec3(T X) : x(X), y(X), z(X) {} - template - inline Vec3(MagicVec3 const &v) - : x(v.ptr[I]), y(v.ptr[J]), z(v.ptr[K]) {} + template + inline Vec3(XVec3 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]), z(v.ptr[v.K]) {} - template - explicit inline Vec3(MagicVec3 const &v) - : x(v.ptr[I]), y(v.ptr[J]), z(v.ptr[K]) {} + template + explicit inline Vec3(XVec3 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]), z(v.ptr[v.K]) {} MEMBER_OPS() OTHER_MEMBER_OPS(Vec3) @@ -306,123 +279,123 @@ template struct Vec3 struct { T r, g, b; }; struct { T s, t, p; }; - MagicVec2 xx, rr, ss; - MagicVec2 xy, rg, st; - MagicVec2 xz, rb, sp; - MagicVec2 yx, gr, ts; - MagicVec2 yy, gg, tt; - MagicVec2 yz, gb, tp; - MagicVec2 zx, br, ps; - MagicVec2 zy, bg, pt; - MagicVec2 zz, bb, pp; - MagicVec3 xxx, rrr, sss; - MagicVec3 xxy, rrg, sst; - MagicVec3 xxz, rrb, ssp; - MagicVec3 xyx, rgr, sts; - MagicVec3 xyy, rgg, stt; - MagicVec3 xyz, rgb, stp; - MagicVec3 xzx, rbr, sps; - MagicVec3 xzy, rbg, spt; - MagicVec3 xzz, rbb, spp; - MagicVec3 yxx, grr, tss; - MagicVec3 yxy, grg, tst; - MagicVec3 yxz, grb, tsp; - MagicVec3 yyx, ggr, tts; - MagicVec3 yyy, ggg, ttt; - MagicVec3 yyz, ggb, ttp; - MagicVec3 yzx, gbr, tps; - MagicVec3 yzy, gbg, tpt; - MagicVec3 yzz, gbb, tpp; - MagicVec3 zxx, brr, pss; - MagicVec3 zxy, brg, pst; - MagicVec3 zxz, brb, psp; - MagicVec3 zyx, bgr, pts; - MagicVec3 zyy, bgg, ptt; - MagicVec3 zyz, bgb, ptp; - MagicVec3 zzx, bbr, pps; - MagicVec3 zzy, bbg, ppt; - MagicVec3 zzz, bbb, ppp; - MagicVec4 xxxx, rrrr, ssss; - MagicVec4 xxxy, rrrg, ssst; - MagicVec4 xxxz, rrrb, sssp; - MagicVec4 xxyx, rrgr, ssts; - MagicVec4 xxyy, rrgg, sstt; - MagicVec4 xxyz, rrgb, sstp; - MagicVec4 xxzx, rrbr, ssps; - MagicVec4 xxzy, rrbg, sspt; - MagicVec4 xxzz, rrbb, sspp; - MagicVec4 xyxx, rgrr, stss; - MagicVec4 xyxy, rgrg, stst; - MagicVec4 xyxz, rgrb, stsp; - MagicVec4 xyyx, rggr, stts; - MagicVec4 xyyy, rggg, sttt; - MagicVec4 xyyz, rggb, sttp; - MagicVec4 xyzx, rgbr, stps; - MagicVec4 xyzy, rgbg, stpt; - MagicVec4 xyzz, rgbb, stpp; - MagicVec4 xzxx, rbrr, spss; - MagicVec4 xzxy, rbrg, spst; - MagicVec4 xzxz, rbrb, spsp; - MagicVec4 xzyx, rbgr, spts; - MagicVec4 xzyy, rbgg, sptt; - MagicVec4 xzyz, rbgb, sptp; - MagicVec4 xzzx, rbbr, spps; - MagicVec4 xzzy, rbbg, sppt; - MagicVec4 xzzz, rbbb, sppp; - MagicVec4 yxxx, grrr, tsss; - MagicVec4 yxxy, grrg, tsst; - MagicVec4 yxxz, grrb, tssp; - MagicVec4 yxyx, grgr, tsts; - MagicVec4 yxyy, grgg, tstt; - MagicVec4 yxyz, grgb, tstp; - MagicVec4 yxzx, grbr, tsps; - MagicVec4 yxzy, grbg, tspt; - MagicVec4 yxzz, grbb, tspp; - MagicVec4 yyxx, ggrr, ttss; - MagicVec4 yyxy, ggrg, ttst; - MagicVec4 yyxz, ggrb, ttsp; - MagicVec4 yyyx, gggr, ttts; - MagicVec4 yyyy, gggg, tttt; - MagicVec4 yyyz, gggb, tttp; - MagicVec4 yyzx, ggbr, ttps; - MagicVec4 yyzy, ggbg, ttpt; - MagicVec4 yyzz, ggbb, ttpp; - MagicVec4 yzxx, gbrr, tpss; - MagicVec4 yzxy, gbrg, tpst; - MagicVec4 yzxz, gbrb, tpsp; - MagicVec4 yzyx, gbgr, tpts; - MagicVec4 yzyy, gbgg, tptt; - MagicVec4 yzyz, gbgb, tptp; - MagicVec4 yzzx, gbbr, tpps; - MagicVec4 yzzy, gbbg, tppt; - MagicVec4 yzzz, gbbb, tppp; - MagicVec4 zxxx, brrr, psss; - MagicVec4 zxxy, brrg, psst; - MagicVec4 zxxz, brrb, pssp; - MagicVec4 zxyx, brgr, psts; - MagicVec4 zxyy, brgg, pstt; - MagicVec4 zxyz, brgb, pstp; - MagicVec4 zxzx, brbr, psps; - MagicVec4 zxzy, brbg, pspt; - MagicVec4 zxzz, brbb, pspp; - MagicVec4 zyxx, bgrr, ptss; - MagicVec4 zyxy, bgrg, ptst; - MagicVec4 zyxz, bgrb, ptsp; - MagicVec4 zyyx, bggr, ptts; - MagicVec4 zyyy, bggg, pttt; - MagicVec4 zyyz, bggb, pttp; - MagicVec4 zyzx, bgbr, ptps; - MagicVec4 zyzy, bgbg, ptpt; - MagicVec4 zyzz, bgbb, ptpp; - MagicVec4 zzxx, bbrr, ppss; - MagicVec4 zzxy, bbrg, ppst; - MagicVec4 zzxz, bbrb, ppsp; - MagicVec4 zzyx, bbgr, ppts; - MagicVec4 zzyy, bbgg, pptt; - MagicVec4 zzyz, bbgb, pptp; - MagicVec4 zzzx, bbbr, ppps; - MagicVec4 zzzy, bbbg, pppt; - MagicVec4 zzzz, bbbb, pppp; + XVec2 xx, rr, ss; + XVec2 xy, rg, st; + XVec2 xz, rb, sp; + XVec2 yx, gr, ts; + XVec2 yy, gg, tt; + XVec2 yz, gb, tp; + XVec2 zx, br, ps; + XVec2 zy, bg, pt; + XVec2 zz, bb, pp; + XVec3 xxx, rrr, sss; + XVec3 xxy, rrg, sst; + XVec3 xxz, rrb, ssp; + XVec3 xyx, rgr, sts; + XVec3 xyy, rgg, stt; + XVec3 xyz, rgb, stp; + XVec3 xzx, rbr, sps; + XVec3 xzy, rbg, spt; + XVec3 xzz, rbb, spp; + XVec3 yxx, grr, tss; + XVec3 yxy, grg, tst; + XVec3 yxz, grb, tsp; + XVec3 yyx, ggr, tts; + XVec3 yyy, ggg, ttt; + XVec3 yyz, ggb, ttp; + XVec3 yzx, gbr, tps; + XVec3 yzy, gbg, tpt; + XVec3 yzz, gbb, tpp; + XVec3 zxx, brr, pss; + XVec3 zxy, brg, pst; + XVec3 zxz, brb, psp; + XVec3 zyx, bgr, pts; + XVec3 zyy, bgg, ptt; + XVec3 zyz, bgb, ptp; + XVec3 zzx, bbr, pps; + XVec3 zzy, bbg, ppt; + XVec3 zzz, bbb, ppp; + XVec4 xxxx, rrrr, ssss; + XVec4 xxxy, rrrg, ssst; + XVec4 xxxz, rrrb, sssp; + XVec4 xxyx, rrgr, ssts; + XVec4 xxyy, rrgg, sstt; + XVec4 xxyz, rrgb, sstp; + XVec4 xxzx, rrbr, ssps; + XVec4 xxzy, rrbg, sspt; + XVec4 xxzz, rrbb, sspp; + XVec4 xyxx, rgrr, stss; + XVec4 xyxy, rgrg, stst; + XVec4 xyxz, rgrb, stsp; + XVec4 xyyx, rggr, stts; + XVec4 xyyy, rggg, sttt; + XVec4 xyyz, rggb, sttp; + XVec4 xyzx, rgbr, stps; + XVec4 xyzy, rgbg, stpt; + XVec4 xyzz, rgbb, stpp; + XVec4 xzxx, rbrr, spss; + XVec4 xzxy, rbrg, spst; + XVec4 xzxz, rbrb, spsp; + XVec4 xzyx, rbgr, spts; + XVec4 xzyy, rbgg, sptt; + XVec4 xzyz, rbgb, sptp; + XVec4 xzzx, rbbr, spps; + XVec4 xzzy, rbbg, sppt; + XVec4 xzzz, rbbb, sppp; + XVec4 yxxx, grrr, tsss; + XVec4 yxxy, grrg, tsst; + XVec4 yxxz, grrb, tssp; + XVec4 yxyx, grgr, tsts; + XVec4 yxyy, grgg, tstt; + XVec4 yxyz, grgb, tstp; + XVec4 yxzx, grbr, tsps; + XVec4 yxzy, grbg, tspt; + XVec4 yxzz, grbb, tspp; + XVec4 yyxx, ggrr, ttss; + XVec4 yyxy, ggrg, ttst; + XVec4 yyxz, ggrb, ttsp; + XVec4 yyyx, gggr, ttts; + XVec4 yyyy, gggg, tttt; + XVec4 yyyz, gggb, tttp; + XVec4 yyzx, ggbr, ttps; + XVec4 yyzy, ggbg, ttpt; + XVec4 yyzz, ggbb, ttpp; + XVec4 yzxx, gbrr, tpss; + XVec4 yzxy, gbrg, tpst; + XVec4 yzxz, gbrb, tpsp; + XVec4 yzyx, gbgr, tpts; + XVec4 yzyy, gbgg, tptt; + XVec4 yzyz, gbgb, tptp; + XVec4 yzzx, gbbr, tpps; + XVec4 yzzy, gbbg, tppt; + XVec4 yzzz, gbbb, tppp; + XVec4 zxxx, brrr, psss; + XVec4 zxxy, brrg, psst; + XVec4 zxxz, brrb, pssp; + XVec4 zxyx, brgr, psts; + XVec4 zxyy, brgg, pstt; + XVec4 zxyz, brgb, pstp; + XVec4 zxzx, brbr, psps; + XVec4 zxzy, brbg, pspt; + XVec4 zxzz, brbb, pspp; + XVec4 zyxx, bgrr, ptss; + XVec4 zyxy, bgrg, ptst; + XVec4 zyxz, bgrb, ptsp; + XVec4 zyyx, bggr, ptts; + XVec4 zyyy, bggg, pttt; + XVec4 zyyz, bggb, pttp; + XVec4 zyzx, bgbr, ptps; + XVec4 zyzy, bgbg, ptpt; + XVec4 zyzz, bgbb, ptpp; + XVec4 zzxx, bbrr, ppss; + XVec4 zzxy, bbrg, ppst; + XVec4 zzxz, bbrb, ppsp; + XVec4 zzyx, bbgr, ppts; + XVec4 zzyy, bbgg, pptt; + XVec4 zzyz, bbgb, pptp; + XVec4 zzzx, bbbr, ppps; + XVec4 zzzy, bbbg, pppt; + XVec4 zzzz, bbbb, pppp; }; }; @@ -432,25 +405,24 @@ template struct Vec3 template struct Vec4 { - typedef Vec4 type_t; - - inline Vec4() { } - explicit inline Vec4(T val) : x(val), y(val), z(val), w(val) { } - inline Vec4(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } - inline Vec4(Vec2 _xy, T _z, T _w) : x(_xy.x), y(_xy.y), z(_z), w(_w) { } - inline Vec4(T _x, Vec2 _yz, T _w) : x(_x), y(_yz.x), z(_yz.y), w(_w) { } - inline Vec4(T _x, T _y, Vec2 _zw) : x(_x), y(_y), z(_zw.x), w(_zw.y) { } - inline Vec4(Vec2 _xy, Vec2 _zw) : x(_xy.x), y(_xy.y), z(_zw.x), w(_zw.y) { } - inline Vec4(Vec3 _xyz, T _w) : x(_xyz.x), y(_xyz.y), z(_xyz.z), w(_w) { } - inline Vec4(T _x, Vec3 _yzw) : x(_x), y(_yzw.x), z(_yzw.y), w(_yzw.z) { } - - template - inline Vec4(MagicVec4 const &v) - : x(v.ptr[I]), y(v.ptr[J]), z(v.ptr[K]), w(v.ptr[L]) {} - - template - explicit inline Vec4(MagicVec4 const &v) - : x(v.ptr[I]), y(v.ptr[J]), z(v.ptr[K]), w(v.ptr[L]) {} + inline Vec4() {} + inline Vec4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {} + inline Vec4(Vec2 XY, T Z, T W) : x(XY.x), y(XY.y), z(Z), w(W) {} + inline Vec4(T X, Vec2 YZ, T W) : x(X), y(YZ.x), z(YZ.y), w(W) {} + inline Vec4(T X, T Y, Vec2 ZW) : x(X), y(Y), z(ZW.x), w(ZW.y) {} + inline Vec4(Vec2 XY, Vec2 ZW) : x(XY.x), y(XY.y), z(ZW.x), w(ZW.y) {} + inline Vec4(Vec3 XYZ, T W) : x(XYZ.x), y(XYZ.y), z(XYZ.z), w(W) {} + inline Vec4(T X, Vec3 YZW) : x(X), y(YZW.x), z(YZW.y), w(YZW.z) {} + + explicit inline Vec4(T X) : x(X), y(X), z(X), w(X) {} + + template + inline Vec4(XVec4 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]), z(v.ptr[v.K]), w(v.ptr[v.L]) {} + + template + explicit inline Vec4(XVec4 const &v) + : x(v.ptr[v.I]), y(v.ptr[v.J]), z(v.ptr[v.K]), w(v.ptr[v.L]) {} MEMBER_OPS() OTHER_MEMBER_OPS(Vec4) @@ -466,342 +438,342 @@ template struct Vec4 struct { T r, g, b, a; }; struct { T s, t, p, q; }; - MagicVec2 xx, rr, ss; - MagicVec2 xy, rg, st; - MagicVec2 xz, rb, sp; - MagicVec2 xw, ra, sq; - MagicVec2 yx, gr, ts; - MagicVec2 yy, gg, tt; - MagicVec2 yz, gb, tp; - MagicVec2 yw, ga, tq; - MagicVec2 zx, br, ps; - MagicVec2 zy, bg, pt; - MagicVec2 zz, bb, pp; - MagicVec2 zw, ba, pq; - MagicVec2 wx, ar, qs; - MagicVec2 wy, ag, qt; - MagicVec2 wz, ab, qp; - MagicVec2 ww, aa, qq; - MagicVec3 xxx, rrr, sss; - MagicVec3 xxy, rrg, sst; - MagicVec3 xxz, rrb, ssp; - MagicVec3 xxw, rra, ssq; - MagicVec3 xyx, rgr, sts; - MagicVec3 xyy, rgg, stt; - MagicVec3 xyz, rgb, stp; - MagicVec3 xyw, rga, stq; - MagicVec3 xzx, rbr, sps; - MagicVec3 xzy, rbg, spt; - MagicVec3 xzz, rbb, spp; - MagicVec3 xzw, rba, spq; - MagicVec3 xwx, rar, sqs; - MagicVec3 xwy, rag, sqt; - MagicVec3 xwz, rab, sqp; - MagicVec3 xww, raa, sqq; - MagicVec3 yxx, grr, tss; - MagicVec3 yxy, grg, tst; - MagicVec3 yxz, grb, tsp; - MagicVec3 yxw, gra, tsq; - MagicVec3 yyx, ggr, tts; - MagicVec3 yyy, ggg, ttt; - MagicVec3 yyz, ggb, ttp; - MagicVec3 yyw, gga, ttq; - MagicVec3 yzx, gbr, tps; - MagicVec3 yzy, gbg, tpt; - MagicVec3 yzz, gbb, tpp; - MagicVec3 yzw, gba, tpq; - MagicVec3 ywx, gar, tqs; - MagicVec3 ywy, gag, tqt; - MagicVec3 ywz, gab, tqp; - MagicVec3 yww, gaa, tqq; - MagicVec3 zxx, brr, pss; - MagicVec3 zxy, brg, pst; - MagicVec3 zxz, brb, psp; - MagicVec3 zxw, bra, psq; - MagicVec3 zyx, bgr, pts; - MagicVec3 zyy, bgg, ptt; - MagicVec3 zyz, bgb, ptp; - MagicVec3 zyw, bga, ptq; - MagicVec3 zzx, bbr, pps; - MagicVec3 zzy, bbg, ppt; - MagicVec3 zzz, bbb, ppp; - MagicVec3 zzw, bba, ppq; - MagicVec3 zwx, bar, pqs; - MagicVec3 zwy, bag, pqt; - MagicVec3 zwz, bab, pqp; - MagicVec3 zww, baa, pqq; - MagicVec3 wxx, arr, qss; - MagicVec3 wxy, arg, qst; - MagicVec3 wxz, arb, qsp; - MagicVec3 wxw, ara, qsq; - MagicVec3 wyx, agr, qts; - MagicVec3 wyy, agg, qtt; - MagicVec3 wyz, agb, qtp; - MagicVec3 wyw, aga, qtq; - MagicVec3 wzx, abr, qps; - MagicVec3 wzy, abg, qpt; - MagicVec3 wzz, abb, qpp; - MagicVec3 wzw, aba, qpq; - MagicVec3 wwx, aar, qqs; - MagicVec3 wwy, aag, qqt; - MagicVec3 wwz, aab, qqp; - MagicVec3 www, aaa, qqq; - MagicVec4 xxxx, rrrr, ssss; - MagicVec4 xxxy, rrrg, ssst; - MagicVec4 xxxz, rrrb, sssp; - MagicVec4 xxxw, rrra, sssq; - MagicVec4 xxyx, rrgr, ssts; - MagicVec4 xxyy, rrgg, sstt; - MagicVec4 xxyz, rrgb, sstp; - MagicVec4 xxyw, rrga, sstq; - MagicVec4 xxzx, rrbr, ssps; - MagicVec4 xxzy, rrbg, sspt; - MagicVec4 xxzz, rrbb, sspp; - MagicVec4 xxzw, rrba, sspq; - MagicVec4 xxwx, rrar, ssqs; - MagicVec4 xxwy, rrag, ssqt; - MagicVec4 xxwz, rrab, ssqp; - MagicVec4 xxww, rraa, ssqq; - MagicVec4 xyxx, rgrr, stss; - MagicVec4 xyxy, rgrg, stst; - MagicVec4 xyxz, rgrb, stsp; - MagicVec4 xyxw, rgra, stsq; - MagicVec4 xyyx, rggr, stts; - MagicVec4 xyyy, rggg, sttt; - MagicVec4 xyyz, rggb, sttp; - MagicVec4 xyyw, rgga, sttq; - MagicVec4 xyzx, rgbr, stps; - MagicVec4 xyzy, rgbg, stpt; - MagicVec4 xyzz, rgbb, stpp; - MagicVec4 xyzw, rgba, stpq; - MagicVec4 xywx, rgar, stqs; - MagicVec4 xywy, rgag, stqt; - MagicVec4 xywz, rgab, stqp; - MagicVec4 xyww, rgaa, stqq; - MagicVec4 xzxx, rbrr, spss; - MagicVec4 xzxy, rbrg, spst; - MagicVec4 xzxz, rbrb, spsp; - MagicVec4 xzxw, rbra, spsq; - MagicVec4 xzyx, rbgr, spts; - MagicVec4 xzyy, rbgg, sptt; - MagicVec4 xzyz, rbgb, sptp; - MagicVec4 xzyw, rbga, sptq; - MagicVec4 xzzx, rbbr, spps; - MagicVec4 xzzy, rbbg, sppt; - MagicVec4 xzzz, rbbb, sppp; - MagicVec4 xzzw, rbba, sppq; - MagicVec4 xzwx, rbar, spqs; - MagicVec4 xzwy, rbag, spqt; - MagicVec4 xzwz, rbab, spqp; - MagicVec4 xzww, rbaa, spqq; - MagicVec4 xwxx, rarr, sqss; - MagicVec4 xwxy, rarg, sqst; - MagicVec4 xwxz, rarb, sqsp; - MagicVec4 xwxw, rara, sqsq; - MagicVec4 xwyx, ragr, sqts; - MagicVec4 xwyy, ragg, sqtt; - MagicVec4 xwyz, ragb, sqtp; - MagicVec4 xwyw, raga, sqtq; - MagicVec4 xwzx, rabr, sqps; - MagicVec4 xwzy, rabg, sqpt; - MagicVec4 xwzz, rabb, sqpp; - MagicVec4 xwzw, raba, sqpq; - MagicVec4 xwwx, raar, sqqs; - MagicVec4 xwwy, raag, sqqt; - MagicVec4 xwwz, raab, sqqp; - MagicVec4 xwww, raaa, sqqq; - MagicVec4 yxxx, grrr, tsss; - MagicVec4 yxxy, grrg, tsst; - MagicVec4 yxxz, grrb, tssp; - MagicVec4 yxxw, grra, tssq; - MagicVec4 yxyx, grgr, tsts; - MagicVec4 yxyy, grgg, tstt; - MagicVec4 yxyz, grgb, tstp; - MagicVec4 yxyw, grga, tstq; - MagicVec4 yxzx, grbr, tsps; - MagicVec4 yxzy, grbg, tspt; - MagicVec4 yxzz, grbb, tspp; - MagicVec4 yxzw, grba, tspq; - MagicVec4 yxwx, grar, tsqs; - MagicVec4 yxwy, grag, tsqt; - MagicVec4 yxwz, grab, tsqp; - MagicVec4 yxww, graa, tsqq; - MagicVec4 yyxx, ggrr, ttss; - MagicVec4 yyxy, ggrg, ttst; - MagicVec4 yyxz, ggrb, ttsp; - MagicVec4 yyxw, ggra, ttsq; - MagicVec4 yyyx, gggr, ttts; - MagicVec4 yyyy, gggg, tttt; - MagicVec4 yyyz, gggb, tttp; - MagicVec4 yyyw, ggga, tttq; - MagicVec4 yyzx, ggbr, ttps; - MagicVec4 yyzy, ggbg, ttpt; - MagicVec4 yyzz, ggbb, ttpp; - MagicVec4 yyzw, ggba, ttpq; - MagicVec4 yywx, ggar, ttqs; - MagicVec4 yywy, ggag, ttqt; - MagicVec4 yywz, ggab, ttqp; - MagicVec4 yyww, ggaa, ttqq; - MagicVec4 yzxx, gbrr, tpss; - MagicVec4 yzxy, gbrg, tpst; - MagicVec4 yzxz, gbrb, tpsp; - MagicVec4 yzxw, gbra, tpsq; - MagicVec4 yzyx, gbgr, tpts; - MagicVec4 yzyy, gbgg, tptt; - MagicVec4 yzyz, gbgb, tptp; - MagicVec4 yzyw, gbga, tptq; - MagicVec4 yzzx, gbbr, tpps; - MagicVec4 yzzy, gbbg, tppt; - MagicVec4 yzzz, gbbb, tppp; - MagicVec4 yzzw, gbba, tppq; - MagicVec4 yzwx, gbar, tpqs; - MagicVec4 yzwy, gbag, tpqt; - MagicVec4 yzwz, gbab, tpqp; - MagicVec4 yzww, gbaa, tpqq; - MagicVec4 ywxx, garr, tqss; - MagicVec4 ywxy, garg, tqst; - MagicVec4 ywxz, garb, tqsp; - MagicVec4 ywxw, gara, tqsq; - MagicVec4 ywyx, gagr, tqts; - MagicVec4 ywyy, gagg, tqtt; - MagicVec4 ywyz, gagb, tqtp; - MagicVec4 ywyw, gaga, tqtq; - MagicVec4 ywzx, gabr, tqps; - MagicVec4 ywzy, gabg, tqpt; - MagicVec4 ywzz, gabb, tqpp; - MagicVec4 ywzw, gaba, tqpq; - MagicVec4 ywwx, gaar, tqqs; - MagicVec4 ywwy, gaag, tqqt; - MagicVec4 ywwz, gaab, tqqp; - MagicVec4 ywww, gaaa, tqqq; - MagicVec4 zxxx, brrr, psss; - MagicVec4 zxxy, brrg, psst; - MagicVec4 zxxz, brrb, pssp; - MagicVec4 zxxw, brra, pssq; - MagicVec4 zxyx, brgr, psts; - MagicVec4 zxyy, brgg, pstt; - MagicVec4 zxyz, brgb, pstp; - MagicVec4 zxyw, brga, pstq; - MagicVec4 zxzx, brbr, psps; - MagicVec4 zxzy, brbg, pspt; - MagicVec4 zxzz, brbb, pspp; - MagicVec4 zxzw, brba, pspq; - MagicVec4 zxwx, brar, psqs; - MagicVec4 zxwy, brag, psqt; - MagicVec4 zxwz, brab, psqp; - MagicVec4 zxww, braa, psqq; - MagicVec4 zyxx, bgrr, ptss; - MagicVec4 zyxy, bgrg, ptst; - MagicVec4 zyxz, bgrb, ptsp; - MagicVec4 zyxw, bgra, ptsq; - MagicVec4 zyyx, bggr, ptts; - MagicVec4 zyyy, bggg, pttt; - MagicVec4 zyyz, bggb, pttp; - MagicVec4 zyyw, bgga, pttq; - MagicVec4 zyzx, bgbr, ptps; - MagicVec4 zyzy, bgbg, ptpt; - MagicVec4 zyzz, bgbb, ptpp; - MagicVec4 zyzw, bgba, ptpq; - MagicVec4 zywx, bgar, ptqs; - MagicVec4 zywy, bgag, ptqt; - MagicVec4 zywz, bgab, ptqp; - MagicVec4 zyww, bgaa, ptqq; - MagicVec4 zzxx, bbrr, ppss; - MagicVec4 zzxy, bbrg, ppst; - MagicVec4 zzxz, bbrb, ppsp; - MagicVec4 zzxw, bbra, ppsq; - MagicVec4 zzyx, bbgr, ppts; - MagicVec4 zzyy, bbgg, pptt; - MagicVec4 zzyz, bbgb, pptp; - MagicVec4 zzyw, bbga, pptq; - MagicVec4 zzzx, bbbr, ppps; - MagicVec4 zzzy, bbbg, pppt; - MagicVec4 zzzz, bbbb, pppp; - MagicVec4 zzzw, bbba, pppq; - MagicVec4 zzwx, bbar, ppqs; - MagicVec4 zzwy, bbag, ppqt; - MagicVec4 zzwz, bbab, ppqp; - MagicVec4 zzww, bbaa, ppqq; - MagicVec4 zwxx, barr, pqss; - MagicVec4 zwxy, barg, pqst; - MagicVec4 zwxz, barb, pqsp; - MagicVec4 zwxw, bara, pqsq; - MagicVec4 zwyx, bagr, pqts; - MagicVec4 zwyy, bagg, pqtt; - MagicVec4 zwyz, bagb, pqtp; - MagicVec4 zwyw, baga, pqtq; - MagicVec4 zwzx, babr, pqps; - MagicVec4 zwzy, babg, pqpt; - MagicVec4 zwzz, babb, pqpp; - MagicVec4 zwzw, baba, pqpq; - MagicVec4 zwwx, baar, pqqs; - MagicVec4 zwwy, baag, pqqt; - MagicVec4 zwwz, baab, pqqp; - MagicVec4 zwww, baaa, pqqq; - MagicVec4 wxxx, arrr, qsss; - MagicVec4 wxxy, arrg, qsst; - MagicVec4 wxxz, arrb, qssp; - MagicVec4 wxxw, arra, qssq; - MagicVec4 wxyx, argr, qsts; - MagicVec4 wxyy, argg, qstt; - MagicVec4 wxyz, argb, qstp; - MagicVec4 wxyw, arga, qstq; - MagicVec4 wxzx, arbr, qsps; - MagicVec4 wxzy, arbg, qspt; - MagicVec4 wxzz, arbb, qspp; - MagicVec4 wxzw, arba, qspq; - MagicVec4 wxwx, arar, qsqs; - MagicVec4 wxwy, arag, qsqt; - MagicVec4 wxwz, arab, qsqp; - MagicVec4 wxww, araa, qsqq; - MagicVec4 wyxx, agrr, qtss; - MagicVec4 wyxy, agrg, qtst; - MagicVec4 wyxz, agrb, qtsp; - MagicVec4 wyxw, agra, qtsq; - MagicVec4 wyyx, aggr, qtts; - MagicVec4 wyyy, aggg, qttt; - MagicVec4 wyyz, aggb, qttp; - MagicVec4 wyyw, agga, qttq; - MagicVec4 wyzx, agbr, qtps; - MagicVec4 wyzy, agbg, qtpt; - MagicVec4 wyzz, agbb, qtpp; - MagicVec4 wyzw, agba, qtpq; - MagicVec4 wywx, agar, qtqs; - MagicVec4 wywy, agag, qtqt; - MagicVec4 wywz, agab, qtqp; - MagicVec4 wyww, agaa, qtqq; - MagicVec4 wzxx, abrr, qpss; - MagicVec4 wzxy, abrg, qpst; - MagicVec4 wzxz, abrb, qpsp; - MagicVec4 wzxw, abra, qpsq; - MagicVec4 wzyx, abgr, qpts; - MagicVec4 wzyy, abgg, qptt; - MagicVec4 wzyz, abgb, qptp; - MagicVec4 wzyw, abga, qptq; - MagicVec4 wzzx, abbr, qpps; - MagicVec4 wzzy, abbg, qppt; - MagicVec4 wzzz, abbb, qppp; - MagicVec4 wzzw, abba, qppq; - MagicVec4 wzwx, abar, qpqs; - MagicVec4 wzwy, abag, qpqt; - MagicVec4 wzwz, abab, qpqp; - MagicVec4 wzww, abaa, qpqq; - MagicVec4 wwxx, aarr, qqss; - MagicVec4 wwxy, aarg, qqst; - MagicVec4 wwxz, aarb, qqsp; - MagicVec4 wwxw, aara, qqsq; - MagicVec4 wwyx, aagr, qqts; - MagicVec4 wwyy, aagg, qqtt; - MagicVec4 wwyz, aagb, qqtp; - MagicVec4 wwyw, aaga, qqtq; - MagicVec4 wwzx, aabr, qqps; - MagicVec4 wwzy, aabg, qqpt; - MagicVec4 wwzz, aabb, qqpp; - MagicVec4 wwzw, aaba, qqpq; - MagicVec4 wwwx, aaar, qqqs; - MagicVec4 wwwy, aaag, qqqt; - MagicVec4 wwwz, aaab, qqqp; - MagicVec4 wwww, aaaa, qqqq; + XVec2 xx, rr, ss; + XVec2 xy, rg, st; + XVec2 xz, rb, sp; + XVec2 xw, ra, sq; + XVec2 yx, gr, ts; + XVec2 yy, gg, tt; + XVec2 yz, gb, tp; + XVec2 yw, ga, tq; + XVec2 zx, br, ps; + XVec2 zy, bg, pt; + XVec2 zz, bb, pp; + XVec2 zw, ba, pq; + XVec2 wx, ar, qs; + XVec2 wy, ag, qt; + XVec2 wz, ab, qp; + XVec2 ww, aa, qq; + XVec3 xxx, rrr, sss; + XVec3 xxy, rrg, sst; + XVec3 xxz, rrb, ssp; + XVec3 xxw, rra, ssq; + XVec3 xyx, rgr, sts; + XVec3 xyy, rgg, stt; + XVec3 xyz, rgb, stp; + XVec3 xyw, rga, stq; + XVec3 xzx, rbr, sps; + XVec3 xzy, rbg, spt; + XVec3 xzz, rbb, spp; + XVec3 xzw, rba, spq; + XVec3 xwx, rar, sqs; + XVec3 xwy, rag, sqt; + XVec3 xwz, rab, sqp; + XVec3 xww, raa, sqq; + XVec3 yxx, grr, tss; + XVec3 yxy, grg, tst; + XVec3 yxz, grb, tsp; + XVec3 yxw, gra, tsq; + XVec3 yyx, ggr, tts; + XVec3 yyy, ggg, ttt; + XVec3 yyz, ggb, ttp; + XVec3 yyw, gga, ttq; + XVec3 yzx, gbr, tps; + XVec3 yzy, gbg, tpt; + XVec3 yzz, gbb, tpp; + XVec3 yzw, gba, tpq; + XVec3 ywx, gar, tqs; + XVec3 ywy, gag, tqt; + XVec3 ywz, gab, tqp; + XVec3 yww, gaa, tqq; + XVec3 zxx, brr, pss; + XVec3 zxy, brg, pst; + XVec3 zxz, brb, psp; + XVec3 zxw, bra, psq; + XVec3 zyx, bgr, pts; + XVec3 zyy, bgg, ptt; + XVec3 zyz, bgb, ptp; + XVec3 zyw, bga, ptq; + XVec3 zzx, bbr, pps; + XVec3 zzy, bbg, ppt; + XVec3 zzz, bbb, ppp; + XVec3 zzw, bba, ppq; + XVec3 zwx, bar, pqs; + XVec3 zwy, bag, pqt; + XVec3 zwz, bab, pqp; + XVec3 zww, baa, pqq; + XVec3 wxx, arr, qss; + XVec3 wxy, arg, qst; + XVec3 wxz, arb, qsp; + XVec3 wxw, ara, qsq; + XVec3 wyx, agr, qts; + XVec3 wyy, agg, qtt; + XVec3 wyz, agb, qtp; + XVec3 wyw, aga, qtq; + XVec3 wzx, abr, qps; + XVec3 wzy, abg, qpt; + XVec3 wzz, abb, qpp; + XVec3 wzw, aba, qpq; + XVec3 wwx, aar, qqs; + XVec3 wwy, aag, qqt; + XVec3 wwz, aab, qqp; + XVec3 www, aaa, qqq; + XVec4 xxxx, rrrr, ssss; + XVec4 xxxy, rrrg, ssst; + XVec4 xxxz, rrrb, sssp; + XVec4 xxxw, rrra, sssq; + XVec4 xxyx, rrgr, ssts; + XVec4 xxyy, rrgg, sstt; + XVec4 xxyz, rrgb, sstp; + XVec4 xxyw, rrga, sstq; + XVec4 xxzx, rrbr, ssps; + XVec4 xxzy, rrbg, sspt; + XVec4 xxzz, rrbb, sspp; + XVec4 xxzw, rrba, sspq; + XVec4 xxwx, rrar, ssqs; + XVec4 xxwy, rrag, ssqt; + XVec4 xxwz, rrab, ssqp; + XVec4 xxww, rraa, ssqq; + XVec4 xyxx, rgrr, stss; + XVec4 xyxy, rgrg, stst; + XVec4 xyxz, rgrb, stsp; + XVec4 xyxw, rgra, stsq; + XVec4 xyyx, rggr, stts; + XVec4 xyyy, rggg, sttt; + XVec4 xyyz, rggb, sttp; + XVec4 xyyw, rgga, sttq; + XVec4 xyzx, rgbr, stps; + XVec4 xyzy, rgbg, stpt; + XVec4 xyzz, rgbb, stpp; + XVec4 xyzw, rgba, stpq; + XVec4 xywx, rgar, stqs; + XVec4 xywy, rgag, stqt; + XVec4 xywz, rgab, stqp; + XVec4 xyww, rgaa, stqq; + XVec4 xzxx, rbrr, spss; + XVec4 xzxy, rbrg, spst; + XVec4 xzxz, rbrb, spsp; + XVec4 xzxw, rbra, spsq; + XVec4 xzyx, rbgr, spts; + XVec4 xzyy, rbgg, sptt; + XVec4 xzyz, rbgb, sptp; + XVec4 xzyw, rbga, sptq; + XVec4 xzzx, rbbr, spps; + XVec4 xzzy, rbbg, sppt; + XVec4 xzzz, rbbb, sppp; + XVec4 xzzw, rbba, sppq; + XVec4 xzwx, rbar, spqs; + XVec4 xzwy, rbag, spqt; + XVec4 xzwz, rbab, spqp; + XVec4 xzww, rbaa, spqq; + XVec4 xwxx, rarr, sqss; + XVec4 xwxy, rarg, sqst; + XVec4 xwxz, rarb, sqsp; + XVec4 xwxw, rara, sqsq; + XVec4 xwyx, ragr, sqts; + XVec4 xwyy, ragg, sqtt; + XVec4 xwyz, ragb, sqtp; + XVec4 xwyw, raga, sqtq; + XVec4 xwzx, rabr, sqps; + XVec4 xwzy, rabg, sqpt; + XVec4 xwzz, rabb, sqpp; + XVec4 xwzw, raba, sqpq; + XVec4 xwwx, raar, sqqs; + XVec4 xwwy, raag, sqqt; + XVec4 xwwz, raab, sqqp; + XVec4 xwww, raaa, sqqq; + XVec4 yxxx, grrr, tsss; + XVec4 yxxy, grrg, tsst; + XVec4 yxxz, grrb, tssp; + XVec4 yxxw, grra, tssq; + XVec4 yxyx, grgr, tsts; + XVec4 yxyy, grgg, tstt; + XVec4 yxyz, grgb, tstp; + XVec4 yxyw, grga, tstq; + XVec4 yxzx, grbr, tsps; + XVec4 yxzy, grbg, tspt; + XVec4 yxzz, grbb, tspp; + XVec4 yxzw, grba, tspq; + XVec4 yxwx, grar, tsqs; + XVec4 yxwy, grag, tsqt; + XVec4 yxwz, grab, tsqp; + XVec4 yxww, graa, tsqq; + XVec4 yyxx, ggrr, ttss; + XVec4 yyxy, ggrg, ttst; + XVec4 yyxz, ggrb, ttsp; + XVec4 yyxw, ggra, ttsq; + XVec4 yyyx, gggr, ttts; + XVec4 yyyy, gggg, tttt; + XVec4 yyyz, gggb, tttp; + XVec4 yyyw, ggga, tttq; + XVec4 yyzx, ggbr, ttps; + XVec4 yyzy, ggbg, ttpt; + XVec4 yyzz, ggbb, ttpp; + XVec4 yyzw, ggba, ttpq; + XVec4 yywx, ggar, ttqs; + XVec4 yywy, ggag, ttqt; + XVec4 yywz, ggab, ttqp; + XVec4 yyww, ggaa, ttqq; + XVec4 yzxx, gbrr, tpss; + XVec4 yzxy, gbrg, tpst; + XVec4 yzxz, gbrb, tpsp; + XVec4 yzxw, gbra, tpsq; + XVec4 yzyx, gbgr, tpts; + XVec4 yzyy, gbgg, tptt; + XVec4 yzyz, gbgb, tptp; + XVec4 yzyw, gbga, tptq; + XVec4 yzzx, gbbr, tpps; + XVec4 yzzy, gbbg, tppt; + XVec4 yzzz, gbbb, tppp; + XVec4 yzzw, gbba, tppq; + XVec4 yzwx, gbar, tpqs; + XVec4 yzwy, gbag, tpqt; + XVec4 yzwz, gbab, tpqp; + XVec4 yzww, gbaa, tpqq; + XVec4 ywxx, garr, tqss; + XVec4 ywxy, garg, tqst; + XVec4 ywxz, garb, tqsp; + XVec4 ywxw, gara, tqsq; + XVec4 ywyx, gagr, tqts; + XVec4 ywyy, gagg, tqtt; + XVec4 ywyz, gagb, tqtp; + XVec4 ywyw, gaga, tqtq; + XVec4 ywzx, gabr, tqps; + XVec4 ywzy, gabg, tqpt; + XVec4 ywzz, gabb, tqpp; + XVec4 ywzw, gaba, tqpq; + XVec4 ywwx, gaar, tqqs; + XVec4 ywwy, gaag, tqqt; + XVec4 ywwz, gaab, tqqp; + XVec4 ywww, gaaa, tqqq; + XVec4 zxxx, brrr, psss; + XVec4 zxxy, brrg, psst; + XVec4 zxxz, brrb, pssp; + XVec4 zxxw, brra, pssq; + XVec4 zxyx, brgr, psts; + XVec4 zxyy, brgg, pstt; + XVec4 zxyz, brgb, pstp; + XVec4 zxyw, brga, pstq; + XVec4 zxzx, brbr, psps; + XVec4 zxzy, brbg, pspt; + XVec4 zxzz, brbb, pspp; + XVec4 zxzw, brba, pspq; + XVec4 zxwx, brar, psqs; + XVec4 zxwy, brag, psqt; + XVec4 zxwz, brab, psqp; + XVec4 zxww, braa, psqq; + XVec4 zyxx, bgrr, ptss; + XVec4 zyxy, bgrg, ptst; + XVec4 zyxz, bgrb, ptsp; + XVec4 zyxw, bgra, ptsq; + XVec4 zyyx, bggr, ptts; + XVec4 zyyy, bggg, pttt; + XVec4 zyyz, bggb, pttp; + XVec4 zyyw, bgga, pttq; + XVec4 zyzx, bgbr, ptps; + XVec4 zyzy, bgbg, ptpt; + XVec4 zyzz, bgbb, ptpp; + XVec4 zyzw, bgba, ptpq; + XVec4 zywx, bgar, ptqs; + XVec4 zywy, bgag, ptqt; + XVec4 zywz, bgab, ptqp; + XVec4 zyww, bgaa, ptqq; + XVec4 zzxx, bbrr, ppss; + XVec4 zzxy, bbrg, ppst; + XVec4 zzxz, bbrb, ppsp; + XVec4 zzxw, bbra, ppsq; + XVec4 zzyx, bbgr, ppts; + XVec4 zzyy, bbgg, pptt; + XVec4 zzyz, bbgb, pptp; + XVec4 zzyw, bbga, pptq; + XVec4 zzzx, bbbr, ppps; + XVec4 zzzy, bbbg, pppt; + XVec4 zzzz, bbbb, pppp; + XVec4 zzzw, bbba, pppq; + XVec4 zzwx, bbar, ppqs; + XVec4 zzwy, bbag, ppqt; + XVec4 zzwz, bbab, ppqp; + XVec4 zzww, bbaa, ppqq; + XVec4 zwxx, barr, pqss; + XVec4 zwxy, barg, pqst; + XVec4 zwxz, barb, pqsp; + XVec4 zwxw, bara, pqsq; + XVec4 zwyx, bagr, pqts; + XVec4 zwyy, bagg, pqtt; + XVec4 zwyz, bagb, pqtp; + XVec4 zwyw, baga, pqtq; + XVec4 zwzx, babr, pqps; + XVec4 zwzy, babg, pqpt; + XVec4 zwzz, babb, pqpp; + XVec4 zwzw, baba, pqpq; + XVec4 zwwx, baar, pqqs; + XVec4 zwwy, baag, pqqt; + XVec4 zwwz, baab, pqqp; + XVec4 zwww, baaa, pqqq; + XVec4 wxxx, arrr, qsss; + XVec4 wxxy, arrg, qsst; + XVec4 wxxz, arrb, qssp; + XVec4 wxxw, arra, qssq; + XVec4 wxyx, argr, qsts; + XVec4 wxyy, argg, qstt; + XVec4 wxyz, argb, qstp; + XVec4 wxyw, arga, qstq; + XVec4 wxzx, arbr, qsps; + XVec4 wxzy, arbg, qspt; + XVec4 wxzz, arbb, qspp; + XVec4 wxzw, arba, qspq; + XVec4 wxwx, arar, qsqs; + XVec4 wxwy, arag, qsqt; + XVec4 wxwz, arab, qsqp; + XVec4 wxww, araa, qsqq; + XVec4 wyxx, agrr, qtss; + XVec4 wyxy, agrg, qtst; + XVec4 wyxz, agrb, qtsp; + XVec4 wyxw, agra, qtsq; + XVec4 wyyx, aggr, qtts; + XVec4 wyyy, aggg, qttt; + XVec4 wyyz, aggb, qttp; + XVec4 wyyw, agga, qttq; + XVec4 wyzx, agbr, qtps; + XVec4 wyzy, agbg, qtpt; + XVec4 wyzz, agbb, qtpp; + XVec4 wyzw, agba, qtpq; + XVec4 wywx, agar, qtqs; + XVec4 wywy, agag, qtqt; + XVec4 wywz, agab, qtqp; + XVec4 wyww, agaa, qtqq; + XVec4 wzxx, abrr, qpss; + XVec4 wzxy, abrg, qpst; + XVec4 wzxz, abrb, qpsp; + XVec4 wzxw, abra, qpsq; + XVec4 wzyx, abgr, qpts; + XVec4 wzyy, abgg, qptt; + XVec4 wzyz, abgb, qptp; + XVec4 wzyw, abga, qptq; + XVec4 wzzx, abbr, qpps; + XVec4 wzzy, abbg, qppt; + XVec4 wzzz, abbb, qppp; + XVec4 wzzw, abba, qppq; + XVec4 wzwx, abar, qpqs; + XVec4 wzwy, abag, qpqt; + XVec4 wzwz, abab, qpqp; + XVec4 wzww, abaa, qpqq; + XVec4 wwxx, aarr, qqss; + XVec4 wwxy, aarg, qqst; + XVec4 wwxz, aarb, qqsp; + XVec4 wwxw, aara, qqsq; + XVec4 wwyx, aagr, qqts; + XVec4 wwyy, aagg, qqtt; + XVec4 wwyz, aagb, qqtp; + XVec4 wwyw, aaga, qqtq; + XVec4 wwzx, aabr, qqps; + XVec4 wwzy, aabg, qqpt; + XVec4 wwzz, aabb, qqpp; + XVec4 wwzw, aaba, qqpq; + XVec4 wwwx, aaar, qqqs; + XVec4 wwwy, aaag, qqqt; + XVec4 wwwz, aaab, qqqp; + XVec4 wwww, aaaa, qqqq; }; }; @@ -811,17 +783,40 @@ template struct Vec4 template struct Quat { - typedef Quat type_t; - - inline Quat() { } - inline Quat(T val) : x(0), y(0), z(0), w(val) { } - inline Quat(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } + inline Quat() {} + inline Quat(T X) : x(0), y(0), z(0), w(X) {} + inline Quat(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {} Quat(Mat4 const &m); MEMBER_OPS() - QUATERNION_OPS() + inline Quat operator *(Quat const &val) const + { + Quat ret; + Vec3 v1(x, y, z); + Vec3 v2(val.x, val.y, val.z); + Vec3 v3 = cross(v1, v2) + w * v2 + val.w * v1; + ret.x = v3.x; + ret.y = v3.y; + ret.z = v3.z; + ret.w = w * val.w - dot(v1, v2); + return ret; + } + + inline Quat operator *=(Quat const &val) + { + return *this = (*this) * val; + } + + inline Quat operator ~() const + { + Quat ret; + for (int n = 0; n < 3; n++) + ret[n] = -(*this)[n]; + ret[3] = (*this)[3]; + return ret; + } #if !defined __ANDROID__ template @@ -1008,25 +1003,25 @@ GLOBAL_TYPED_OPS(Vec3) GLOBAL_TYPED_OPS(Vec4) /* - * Magic swizzling (part 2/2) + * Magic vector swizzling (part 2/2) */ -template -inline Vec2 MagicVec2::operator =(Vec2 that) +template +inline Vec2 XVec2::operator =(Vec2 that) { ptr[I] = that.x; ptr[J] = that.y; return *this; } -template -inline Vec3 MagicVec3::operator =(Vec3 that) +template +inline Vec3 XVec3::operator =(Vec3 that) { ptr[I] = that.x; ptr[J] = that.y; ptr[K] = that.z; return *this; } -template -inline Vec4 MagicVec4::operator =(Vec4 that) +template +inline Vec4 XVec4::operator =(Vec4 that) { ptr[I] = that.x; ptr[J] = that.y; ptr[K] = that.z; ptr[L] = that.w; return *this; @@ -1038,9 +1033,7 @@ inline Vec4 MagicVec4::operator =(Vec4 that) template struct Mat4 { - typedef Mat4 type_t; - - inline Mat4() { } + inline Mat4() {} explicit inline Mat4(T val) { for (int j = 0; j < 4; j++)