diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-06-01 03:55:28 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-06-01 03:55:28 +0000 |
| commit | 6548dfd5fee019fb4ab128db0cc982f4baf5537b (patch) | |
| tree | 7bb67b8de6122690113e6457ffba2002967251bc /Common/interface | |
| parent | Fixed MinGW build issues (diff) | |
| download | DiligentCore-6548dfd5fee019fb4ab128db0cc982f4baf5537b.tar.gz DiligentCore-6548dfd5fee019fb4ab128db0cc982f4baf5537b.zip | |
Math lib: added vector type recast methods
Diffstat (limited to 'Common/interface')
| -rw-r--r-- | Common/interface/BasicMath.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Common/interface/BasicMath.h b/Common/interface/BasicMath.h index f9af0d56..33922e9e 100644 --- a/Common/interface/BasicMath.h +++ b/Common/interface/BasicMath.h @@ -221,6 +221,16 @@ template <class T> struct Vector2 static_cast<T>(*it++) }; } + + template<typename Y> + Vector2<Y> Recast()const + { + return Vector2<Y> + { + static_cast<Y>(x), + static_cast<Y>(y) + }; + } }; template <class T> @@ -406,6 +416,17 @@ template <class T> struct Vector3 }; } + template<typename Y> + Vector3<Y> Recast()const + { + return Vector3<Y> + { + static_cast<Y>(x), + static_cast<Y>(y), + static_cast<Y>(z) + }; + } + operator Vector2<T>()const{return Vector2<T>(x,y);} }; @@ -613,6 +634,18 @@ template <class T> struct Vector4 }; } + template<typename Y> + Vector4<Y> Recast()const + { + return Vector4<Y> + { + static_cast<Y>(x), + static_cast<Y>(y), + static_cast<Y>(z), + static_cast<Y>(w) + }; + } + operator Vector3<T>() const { return Vector3<T>(x, y, z); |
