Add static constants for vec3

- Tests, too
This commit is contained in:
Jesse Talavera-Greenberg 2015-10-02 18:34:17 -04:00
parent b42a46d246
commit 25bd7014b0
3 changed files with 49 additions and 0 deletions

View File

@ -58,6 +58,15 @@ namespace glm
static GLM_RELAXED_CONSTEXPR precision prec = P;
# endif//GLM_META_PROG_HELPERS
static const type ZERO;
static const type X;
static const type Y;
static const type Z;
static const type XY;
static const type XZ;
static const type YZ;
static const type XYZ;
// -- Data --
# if GLM_HAS_ANONYMOUS_UNION

View File

@ -32,6 +32,30 @@
namespace glm
{
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));
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));
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));
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));
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));
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));
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));
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));
// -- Implicit basic constructors --
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)

View File

@ -493,6 +493,21 @@ int test_operator_increment()
return Error;
}
int test_vec3_static_const() {
int Error(0);
Error += (glm::ivec3(0, 0, 0) == glm::ivec3::ZERO) ? 0 : 1;
Error += (glm::vec3(1, 0, 0) == glm::vec3::X) ? 0 : 1;
Error += (glm::bvec3(false, true, false) == glm::bvec3::Y) ? 0 : 1;
Error += (glm::bvec3(false, false, true) == glm::bvec3::Z) ? 0 : 1;
Error += (glm::dvec3(1, 1, 0) == glm::dvec3::XY) ? 0 : 1;
Error += (glm::vec3(1, 0, 1) == glm::vec3::XZ) ? 0 : 1;
Error += (glm::uvec3(0u, 1u, 1u) == glm::uvec3::YZ) ? 0 : 1;
Error += (glm::dvec3(1, 1, 1) == glm::dvec3::XYZ) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@ -505,6 +520,7 @@ int main()
assert(glm::vec3::components == 3);
# endif
Error += test_vec3_static_const();
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();