diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-08 18:30:28 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-10 03:36:46 +0200 |
commit | d300f341bca4d4fe295a6dd303c0961bff7a0520 (patch) | |
tree | 5c3e2f9241a46a42ff1aae013a16beec4d759339 /include | |
parent | dc2853533f4e641ac192ebca5458f876109441ff (diff) | |
download | qtlocation-mapboxgl-d300f341bca4d4fe295a6dd303c0961bff7a0520.tar.gz |
[core] Remove _validPoint from Transform code
vec2<T>::operator bool() checks for NaNs already.
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/util/vec.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/mbgl/util/vec.hpp b/include/mbgl/util/vec.hpp index 83530a1798..a8bbd14b0f 100644 --- a/include/mbgl/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -105,6 +105,18 @@ struct vec3 { inline bool operator==(const vec3& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } + + template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> + inline operator bool() const { + return !std::isnan(x) && !std::isnan(y) && !std::isnan(z); + } + + template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> + inline operator bool() const { + return x != std::numeric_limits<T>::min() + && y != std::numeric_limits<T>::min() + && z != std::numeric_limits<T>::min(); + } }; template <typename T = double> @@ -117,6 +129,19 @@ struct vec4 { inline bool operator==(const vec4& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; } + + template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> + inline operator bool() const { + return !std::isnan(x) && !std::isnan(y) && !std::isnan(z) && !std::isnan(w); + } + + template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> + inline operator bool() const { + return x != std::numeric_limits<T>::min() + && y != std::numeric_limits<T>::min() + && z != std::numeric_limits<T>::min() + && w != std::numeric_limits<T>::min(); + } }; |