| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "Prerequisites/BsPrerequisitesUtil.h" |
| 6 | |
| 7 | namespace bs |
| 8 | { |
| 9 | /** @addtogroup Math |
| 10 | * @{ |
| 11 | */ |
| 12 | |
| 13 | /** A four dimensional vector with integer coordinates. */ |
| 14 | struct BS_SCRIPT_EXPORT(m:Math,pl:true) Vector4I |
| 15 | { |
| 16 | INT32 x = 0; |
| 17 | INT32 y = 0; |
| 18 | INT32 z = 0; |
| 19 | INT32 w = 0; |
| 20 | |
| 21 | constexpr Vector4I() = default; |
| 22 | |
| 23 | constexpr Vector4I(INT32 x, INT32 y, INT32 z, INT32 w) |
| 24 | :x(x), y(y), z(z), w(w) |
| 25 | { } |
| 26 | |
| 27 | INT32 operator[] (size_t i) const |
| 28 | { |
| 29 | assert(i < 4); |
| 30 | |
| 31 | switch (i) |
| 32 | { |
| 33 | case 0: return x; |
| 34 | case 1: return y; |
| 35 | case 2: return z; |
| 36 | case 3: return w; |
| 37 | default: return 0; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | INT32& operator[] (size_t i) |
| 42 | { |
| 43 | assert(i < 4); |
| 44 | |
| 45 | switch (i) |
| 46 | { |
| 47 | case 0: return x; |
| 48 | case 1: return y; |
| 49 | case 2: return z; |
| 50 | case 3: return w; |
| 51 | default: return x; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | bool operator== (const Vector4I& rhs) const |
| 56 | { |
| 57 | return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; |
| 58 | } |
| 59 | |
| 60 | bool operator!= (const Vector4I& rhs) const |
| 61 | { |
| 62 | return !operator==(rhs); |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | /** @} */ |
| 67 | |
| 68 | BS_ALLOW_MEMCPY_SERIALIZATION(Vector4I) |
| 69 | } |
| 70 | |