Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions glm/gtx/compatibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace glm
template<typename T, qualifier Q> GLM_FUNC_DECL vec<2, bool, Q> isfinite(const vec<2, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<3, bool, Q> isfinite(const vec<3, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<4, bool, Q> isfinite(const vec<4, T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
template<typename T, qualifier Q> GLM_FUNC_DECL vec<4, bool, Q> isfinite(const qua<T, Q>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)

typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension)
typedef vec<2, bool, highp> bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension)
Expand Down
11 changes: 11 additions & 0 deletions glm/gtx/compatibility.inl
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ namespace glm
isfinite(x.w));
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(
qua<T, Q> const& x)
{
return vec<4, bool, Q>(
isfinite(x.x),
isfinite(x.y),
isfinite(x.z),
isfinite(x.w));
}

}//namespace glm
29 changes: 29 additions & 0 deletions test/gtx/gtx_compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ int main()
{
int Error(0);

float Zero_f = 0.0;
double Zero_d = 0.0;

Error += glm::isfinite(1.0f) ? 0 : 1;
Error += glm::isfinite(1.0) ? 0 : 1;
Error += glm::isfinite(-1.0f) ? 0 : 1;
Expand All @@ -15,5 +18,31 @@ int main()
Error += glm::all(glm::isfinite(glm::vec4(-1.0f))) ? 0 : 1;
Error += glm::all(glm::isfinite(glm::dvec4(-1.0))) ? 0 : 1;

Error += glm::all(glm::isfinite(glm::quat(1.0f, 1.0f, 1.0f, 1.0f))) ? 0 : 1;
Error += glm::all(glm::isfinite(glm::dquat(1.0, 1.0, 1.0, 1.0))) ? 0 : 1;
Error += glm::all(glm::isfinite(glm::quat(-1.0f, -1.0f, -1.0f, -1.0f))) ? 0 : 1;
Error += glm::all(glm::isfinite(glm::dquat(-1.0, -1.0, -1.0, -1.0))) ? 0 : 1;

Error += glm::isfinite(0.0f/Zero_f) ? 1 : 0;
Error += glm::isfinite(0.0/Zero_d) ? 1 : 0;
Error += glm::isfinite(1.0f/Zero_f) ? 1 : 0;
Error += glm::isfinite(1.0/Zero_d) ? 1 : 0;
Error += glm::isfinite(-1.0f/Zero_f) ? 1 : 0;
Error += glm::isfinite(-1.0/Zero_d) ? 1 : 0;

Error += glm::any(glm::isfinite(glm::vec4(0.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dvec4(0.0/Zero_d))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::vec4(1.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dvec4(1.0/Zero_d))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::vec4(-1.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dvec4(-1.0/Zero_d))) ? 1 : 0;

Error += glm::any(glm::isfinite(glm::quat(0.0f/Zero_f, 0.0f/Zero_f, 0.0f/Zero_f, 0.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dquat(0.0/Zero_d, 0.0/Zero_d, 0.0/Zero_d, 0.0/Zero_d))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::quat(1.0f/Zero_f, 1.0f/Zero_f, 1.0f/Zero_f, 1.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dquat(1.0/Zero_d, 1.0/Zero_d, 1.0/Zero_d, 1.0/Zero_d))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::quat(-1.0f/Zero_f, -1.0f/Zero_f, -1.0f/Zero_f, -1.0f/Zero_f))) ? 1 : 0;
Error += glm::any(glm::isfinite(glm::dquat(-1.0/Zero_d, -1.0/Zero_d, -1.0/Zero_d, -1.0/Zero_d))) ? 1 : 0;

return Error;
}
Loading