Simplify the static const definitions for vectors and quaternions

- DRY, baby!
This commit is contained in:
Jesse Talavera-Greenberg 2015-10-05 19:30:16 -04:00
parent 9604a7549f
commit ef320a2a2f
7 changed files with 110 additions and 110 deletions

View File

@ -34,10 +34,10 @@ namespace glm
{ {
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
template<typename T, precision P> template<typename T, precision P>
const tvec1<T, P> tvec1<T, P>::X = tvec1<T, P>(static_cast<T>(1)); const tvec1<T, P> tvec1<T, P>::X(static_cast<T>(1));
template<typename T, precision P> template<typename T, precision P>
const tvec1<T, P> tvec1<T, P>::ZERO = tvec1<T, P>(static_cast<T>(0)); const tvec1<T, P> tvec1<T, P>::ZERO(static_cast<T>(0));
# endif # endif
// -- Implicit basic constructors -- // -- Implicit basic constructors --

View File

@ -30,16 +30,16 @@ namespace glm
{ {
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P> template <typename T, precision P>
const tvec2<T, P> tvec2<T, P>::ZERO = tvec2<T, P>(static_cast<T>(0), static_cast<T>(0)); const tvec2<T, P> tvec2<T, P>::ZERO(static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec2<T, P> tvec2<T, P>::X = tvec2<T, P>(static_cast<T>(1), static_cast<T>(0)); const tvec2<T, P> tvec2<T, P>::X(static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec2<T, P> tvec2<T, P>::Y = tvec2<T, P>(static_cast<T>(0), static_cast<T>(1)); const tvec2<T, P> tvec2<T, P>::Y(static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec2<T, P> tvec2<T, P>::XY = tvec2<T, P>(static_cast<T>(1), static_cast<T>(1)); const tvec2<T, P> tvec2<T, P>::XY(static_cast<T>(1), static_cast<T>(1));
# endif # endif
// -- Implicit basic constructors -- // -- Implicit basic constructors --

View File

@ -35,28 +35,28 @@ namespace glm
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::ZERO = tvec3<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); const tvec3<T, P> tvec3<T, P>::ZERO(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::X = tvec3<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); const tvec3<T, P> tvec3<T, P>::X(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::Y = tvec3<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); const tvec3<T, P> tvec3<T, P>::Y(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::Z = tvec3<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); const tvec3<T, P> tvec3<T, P>::Z(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XY = tvec3<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); const tvec3<T, P> tvec3<T, P>::XY(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XZ = tvec3<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1)); const tvec3<T, P> tvec3<T, P>::XZ(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::YZ = tvec3<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); const tvec3<T, P> tvec3<T, P>::YZ(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec3<T, P> tvec3<T, P>::XYZ = tvec3<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); const tvec3<T, P> tvec3<T, P>::XYZ(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif # endif
// -- Implicit basic constructors -- // -- Implicit basic constructors --

View File

@ -35,68 +35,68 @@ namespace glm
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::ZERO = const tvec4<T, P> tvec4<T, P>::ZERO
tvec4<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::X = const tvec4<T, P> tvec4<T, P>::X
tvec4<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::Y = const tvec4<T, P> tvec4<T, P>::Y
tvec4<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::Z = const tvec4<T, P> tvec4<T, P>::Z
tvec4<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::W = const tvec4<T, P> tvec4<T, P>::W
tvec4<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XY = const tvec4<T, P> tvec4<T, P>::XY
tvec4<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XZ = const tvec4<T, P> tvec4<T, P>::XZ
tvec4<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XW = const tvec4<T, P> tvec4<T, P>::XW
tvec4<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YZ = const tvec4<T, P> tvec4<T, P>::YZ
tvec4<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YW = const tvec4<T, P> tvec4<T, P>::YW
tvec4<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::ZW = const tvec4<T, P> tvec4<T, P>::ZW
tvec4<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYZ = const tvec4<T, P> tvec4<T, P>::XYZ
tvec4<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYW = const tvec4<T, P> tvec4<T, P>::XYW
tvec4<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XZW = const tvec4<T, P> tvec4<T, P>::XZW
tvec4<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::YZW = const tvec4<T, P> tvec4<T, P>::YZW
tvec4<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tvec4<T, P> tvec4<T, P>::XYZW = const tvec4<T, P> tvec4<T, P>::XYZW
tvec4<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif # endif
// -- Implicit basic constructors -- // -- Implicit basic constructors --

View File

@ -51,68 +51,68 @@ namespace detail
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::ZERO = const tquat<T, P> tquat<T, P>::ZERO
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::X = const tquat<T, P> tquat<T, P>::X
tquat<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::Y = const tquat<T, P> tquat<T, P>::Y
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::Z = const tquat<T, P> tquat<T, P>::Z
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::W = const tquat<T, P> tquat<T, P>::W
tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XY = const tquat<T, P> tquat<T, P>::XY
tquat<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XZ = const tquat<T, P> tquat<T, P>::XZ
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XW = const tquat<T, P> tquat<T, P>::XW
tquat<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YZ = const tquat<T, P> tquat<T, P>::YZ
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YW = const tquat<T, P> tquat<T, P>::YW
tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::ZW = const tquat<T, P> tquat<T, P>::ZW
tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYZ = const tquat<T, P> tquat<T, P>::XYZ
tquat<T, P>(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(0), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYW = const tquat<T, P> tquat<T, P>::XYW
tquat<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(0));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XZW = const tquat<T, P> tquat<T, P>::XZW
tquat<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(0), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::YZW = const tquat<T, P> tquat<T, P>::YZW
tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(0), static_cast<T>(1), static_cast<T>(1));
template <typename T, precision P> template <typename T, precision P>
const tquat<T, P> tquat<T, P>::XYZW = const tquat<T, P> tquat<T, P>::XYZW
tquat<T, P>(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); (static_cast<T>(1), static_cast<T>(1), static_cast<T>(1), static_cast<T>(1));
# endif # endif
// -- Component accesses -- // -- Component accesses --

View File

@ -52,22 +52,22 @@ void print(const fvec4SIMD &v)
#endif #endif
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
const fquatSIMD fquatSIMD::ZERO = fquatSIMD(0, 0, 0, 0); const fquatSIMD fquatSIMD::ZERO(0, 0, 0, 0);
const fquatSIMD fquatSIMD::X = fquatSIMD(0, 1, 0, 0); const fquatSIMD fquatSIMD::X(0, 1, 0, 0);
const fquatSIMD fquatSIMD::Y = fquatSIMD(0, 0, 1, 0); const fquatSIMD fquatSIMD::Y(0, 0, 1, 0);
const fquatSIMD fquatSIMD::Z = fquatSIMD(0, 0, 0, 1); const fquatSIMD fquatSIMD::Z(0, 0, 0, 1);
const fquatSIMD fquatSIMD::W = fquatSIMD(1, 0, 0, 0); const fquatSIMD fquatSIMD::W(1, 0, 0, 0);
const fquatSIMD fquatSIMD::XY = fquatSIMD(0, 1, 1, 0); const fquatSIMD fquatSIMD::XY(0, 1, 1, 0);
const fquatSIMD fquatSIMD::XZ = fquatSIMD(0, 1, 0, 1); const fquatSIMD fquatSIMD::XZ(0, 1, 0, 1);
const fquatSIMD fquatSIMD::XW = fquatSIMD(1, 1, 0, 0); const fquatSIMD fquatSIMD::XW(1, 1, 0, 0);
const fquatSIMD fquatSIMD::YZ = fquatSIMD(0, 0, 1, 1); const fquatSIMD fquatSIMD::YZ(0, 0, 1, 1);
const fquatSIMD fquatSIMD::YW = fquatSIMD(1, 0, 1, 0); const fquatSIMD fquatSIMD::YW(1, 0, 1, 0);
const fquatSIMD fquatSIMD::ZW = fquatSIMD(1, 0, 0, 1); const fquatSIMD fquatSIMD::ZW(1, 0, 0, 1);
const fquatSIMD fquatSIMD::XYZ = fquatSIMD(0, 1, 1, 1); const fquatSIMD fquatSIMD::XYZ(0, 1, 1, 1);
const fquatSIMD fquatSIMD::XYW = fquatSIMD(1, 1, 1, 0); const fquatSIMD fquatSIMD::XYW(1, 1, 1, 0);
const fquatSIMD fquatSIMD::XZW = fquatSIMD(1, 1, 0, 1); const fquatSIMD fquatSIMD::XZW(1, 1, 0, 1);
const fquatSIMD fquatSIMD::YZW = fquatSIMD(1, 0, 1, 1); const fquatSIMD fquatSIMD::YZW(1, 0, 1, 1);
const fquatSIMD fquatSIMD::XYZW = fquatSIMD(1, 1, 1, 1); const fquatSIMD fquatSIMD::XYZW(1, 1, 1, 1);
# endif # endif
////////////////////////////////////// //////////////////////////////////////

View File

@ -17,22 +17,22 @@ struct shuffle_mask
}; };
# ifdef GLM_STATIC_CONST_MEMBERS # ifdef GLM_STATIC_CONST_MEMBERS
const fvec4SIMD fvec4SIMD::ZERO = fvec4SIMD(0, 0, 0, 0); const fvec4SIMD fvec4SIMD::ZERO(0, 0, 0, 0);
const fvec4SIMD fvec4SIMD::X = fvec4SIMD(1, 0, 0, 0); const fvec4SIMD fvec4SIMD::X(1, 0, 0, 0);
const fvec4SIMD fvec4SIMD::Y = fvec4SIMD(0, 1, 0, 0); const fvec4SIMD fvec4SIMD::Y(0, 1, 0, 0);
const fvec4SIMD fvec4SIMD::Z = fvec4SIMD(0, 0, 1, 0); const fvec4SIMD fvec4SIMD::Z(0, 0, 1, 0);
const fvec4SIMD fvec4SIMD::W = fvec4SIMD(0, 0, 0, 1); const fvec4SIMD fvec4SIMD::W(0, 0, 0, 1);
const fvec4SIMD fvec4SIMD::XY = fvec4SIMD(1, 1, 0, 0); const fvec4SIMD fvec4SIMD::XY(1, 1, 0, 0);
const fvec4SIMD fvec4SIMD::XZ = fvec4SIMD(1, 0, 1, 0); const fvec4SIMD fvec4SIMD::XZ(1, 0, 1, 0);
const fvec4SIMD fvec4SIMD::XW = fvec4SIMD(1, 0, 0, 1); const fvec4SIMD fvec4SIMD::XW(1, 0, 0, 1);
const fvec4SIMD fvec4SIMD::YZ = fvec4SIMD(0, 1, 1, 0); const fvec4SIMD fvec4SIMD::YZ(0, 1, 1, 0);
const fvec4SIMD fvec4SIMD::YW = fvec4SIMD(0, 1, 0, 1); const fvec4SIMD fvec4SIMD::YW(0, 1, 0, 1);
const fvec4SIMD fvec4SIMD::ZW = fvec4SIMD(0, 0, 1, 1); const fvec4SIMD fvec4SIMD::ZW(0, 0, 1, 1);
const fvec4SIMD fvec4SIMD::XYZ = fvec4SIMD(1, 1, 1, 0); const fvec4SIMD fvec4SIMD::XYZ(1, 1, 1, 0);
const fvec4SIMD fvec4SIMD::XYW = fvec4SIMD(1, 1, 0, 1); const fvec4SIMD fvec4SIMD::XYW(1, 1, 0, 1);
const fvec4SIMD fvec4SIMD::XZW = fvec4SIMD(1, 0, 1, 1); const fvec4SIMD fvec4SIMD::XZW(1, 0, 1, 1);
const fvec4SIMD fvec4SIMD::YZW = fvec4SIMD(0, 1, 1, 1); const fvec4SIMD fvec4SIMD::YZW(0, 1, 1, 1);
const fvec4SIMD fvec4SIMD::XYZW = fvec4SIMD(1, 1, 1, 1); const fvec4SIMD fvec4SIMD::XYZW(1, 1, 1, 1);
# endif # endif
////////////////////////////////////// //////////////////////////////////////