graphene

changeset 5:2ce58d5309f0

swizzling
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 25 Jul 2015 17:19:27 +0300
parents d30e24132b6e
children 9fbbc96e6fbe
files src/gmath/swizzle.h src/gmath/vector.cc src/gmath/vector.h src/gmath/vector.inl
diffstat 4 files changed, 199 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gmath/swizzle.h	Sat Jul 25 17:19:27 2015 +0300
     1.3 @@ -0,0 +1,135 @@
     1.4 +// the only function of this file is to hide the swizzle-macro eyesore
     1.5 +
     1.6 +// swizzle macros for Vector2
     1.7 +#define GPH_VEC2_SWIZZLE	\
     1.8 +	GPH_SWIZZLE2(Vector2, x, x) GPH_SWIZZLE2(Vector2, x, y) \
     1.9 +	GPH_SWIZZLE2(Vector2, y, x) GPH_SWIZZLE2(Vector2, y, z)
    1.10 +
    1.11 +// swizzle macros for Vector3
    1.12 +#define GPH_VEC3_SWIZZLE	\
    1.13 +	GPH_SWIZZLE2(Vector3, x, x) GPH_SWIZZLE2(Vector3, x, y) GPH_SWIZZLE2(Vector3, x, z) \
    1.14 +	GPH_SWIZZLE2(Vector3, y, x) GPH_SWIZZLE2(Vector3, y, y) GPH_SWIZZLE2(Vector3, y, z) \
    1.15 +	GPH_SWIZZLE2(Vector3, z, x) GPH_SWIZZLE2(Vector3, z, y) GPH_SWIZZLE2(Vector3, z, z) \
    1.16 +	GPH_SWIZZLE3(Vector3, x, x, x) GPH_SWIZZLE3(Vector3, x, x, y) GPH_SWIZZLE3(Vector3, x, x, z) \
    1.17 +	GPH_SWIZZLE3(Vector3, x, y, x) GPH_SWIZZLE3(Vector3, x, y, y) GPH_SWIZZLE3(Vector3, x, y, z) \
    1.18 +	GPH_SWIZZLE3(Vector3, x, z, x) GPH_SWIZZLE3(Vector3, x, z, y) GPH_SWIZZLE3(Vector3, x, z, z) \
    1.19 +	GPH_SWIZZLE3(Vector3, y, x, x) GPH_SWIZZLE3(Vector3, y, x, y) GPH_SWIZZLE3(Vector3, y, x, z) \
    1.20 +	GPH_SWIZZLE3(Vector3, y, y, x) GPH_SWIZZLE3(Vector3, y, y, y) GPH_SWIZZLE3(Vector3, y, y, z) \
    1.21 +	GPH_SWIZZLE3(Vector3, y, z, x) GPH_SWIZZLE3(Vector3, y, z, y) GPH_SWIZZLE3(Vector3, y, z, z) \
    1.22 +	GPH_SWIZZLE3(Vector3, z, x, x) GPH_SWIZZLE3(Vector3, z, x, y) GPH_SWIZZLE3(Vector3, z, x, z) \
    1.23 +	GPH_SWIZZLE3(Vector3, z, y, x) GPH_SWIZZLE3(Vector3, z, y, y) GPH_SWIZZLE3(Vector3, z, y, z) \
    1.24 +	GPH_SWIZZLE3(Vector3, z, z, x) GPH_SWIZZLE3(Vector3, z, z, y) GPH_SWIZZLE3(Vector3, z, z, z) \
    1.25 +	GPH_SWIZZLE4(Vector3, x, x, x, x) GPH_SWIZZLE4(Vector3, x, x, x, y) GPH_SWIZZLE4(Vector3, x, x, x, z) \
    1.26 +	GPH_SWIZZLE4(Vector3, x, x, y, x) GPH_SWIZZLE4(Vector3, x, x, y, y) GPH_SWIZZLE4(Vector3, x, x, y, z) \
    1.27 +	GPH_SWIZZLE4(Vector3, x, x, z, x) GPH_SWIZZLE4(Vector3, x, x, z, y) GPH_SWIZZLE4(Vector3, x, x, z, z) \
    1.28 +	GPH_SWIZZLE4(Vector3, x, y, x, x) GPH_SWIZZLE4(Vector3, x, y, x, y) GPH_SWIZZLE4(Vector3, x, y, x, z) \
    1.29 +	GPH_SWIZZLE4(Vector3, x, y, y, x) GPH_SWIZZLE4(Vector3, x, y, y, y) GPH_SWIZZLE4(Vector3, x, y, y, z) \
    1.30 +	GPH_SWIZZLE4(Vector3, x, y, z, x) GPH_SWIZZLE4(Vector3, x, y, z, y) GPH_SWIZZLE4(Vector3, x, y, z, z) \
    1.31 +	GPH_SWIZZLE4(Vector3, x, z, x, x) GPH_SWIZZLE4(Vector3, x, z, x, y) GPH_SWIZZLE4(Vector3, x, z, x, z) \
    1.32 +	GPH_SWIZZLE4(Vector3, x, z, y, x) GPH_SWIZZLE4(Vector3, x, z, y, y) GPH_SWIZZLE4(Vector3, x, z, y, z) \
    1.33 +	GPH_SWIZZLE4(Vector3, x, z, z, x) GPH_SWIZZLE4(Vector3, x, z, z, y) GPH_SWIZZLE4(Vector3, x, z, z, z) \
    1.34 +	GPH_SWIZZLE4(Vector3, y, x, x, x) GPH_SWIZZLE4(Vector3, y, x, x, y) GPH_SWIZZLE4(Vector3, y, x, x, z) \
    1.35 +	GPH_SWIZZLE4(Vector3, y, x, y, x) GPH_SWIZZLE4(Vector3, y, x, y, y) GPH_SWIZZLE4(Vector3, y, x, y, z) \
    1.36 +	GPH_SWIZZLE4(Vector3, y, x, z, x) GPH_SWIZZLE4(Vector3, y, x, z, y) GPH_SWIZZLE4(Vector3, y, x, z, z) \
    1.37 +	GPH_SWIZZLE4(Vector3, y, y, x, x) GPH_SWIZZLE4(Vector3, y, y, x, y) GPH_SWIZZLE4(Vector3, y, y, x, z) \
    1.38 +	GPH_SWIZZLE4(Vector3, y, y, y, x) GPH_SWIZZLE4(Vector3, y, y, y, y) GPH_SWIZZLE4(Vector3, y, y, y, z) \
    1.39 +	GPH_SWIZZLE4(Vector3, y, y, z, x) GPH_SWIZZLE4(Vector3, y, y, z, y) GPH_SWIZZLE4(Vector3, y, y, z, z) \
    1.40 +	GPH_SWIZZLE4(Vector3, y, z, x, x) GPH_SWIZZLE4(Vector3, y, z, x, y) GPH_SWIZZLE4(Vector3, y, z, x, z) \
    1.41 +	GPH_SWIZZLE4(Vector3, y, z, y, x) GPH_SWIZZLE4(Vector3, y, z, y, y) GPH_SWIZZLE4(Vector3, y, z, y, z) \
    1.42 +	GPH_SWIZZLE4(Vector3, y, z, z, x) GPH_SWIZZLE4(Vector3, y, z, z, y) GPH_SWIZZLE4(Vector3, y, z, z, z) \
    1.43 +	GPH_SWIZZLE4(Vector3, z, x, x, x) GPH_SWIZZLE4(Vector3, z, x, x, y) GPH_SWIZZLE4(Vector3, z, x, x, z) \
    1.44 +	GPH_SWIZZLE4(Vector3, z, x, y, x) GPH_SWIZZLE4(Vector3, z, x, y, y) GPH_SWIZZLE4(Vector3, z, x, y, z) \
    1.45 +	GPH_SWIZZLE4(Vector3, z, x, z, x) GPH_SWIZZLE4(Vector3, z, x, z, y) GPH_SWIZZLE4(Vector3, z, x, z, z) \
    1.46 +	GPH_SWIZZLE4(Vector3, z, y, x, x) GPH_SWIZZLE4(Vector3, z, y, x, y) GPH_SWIZZLE4(Vector3, z, y, x, z) \
    1.47 +	GPH_SWIZZLE4(Vector3, z, y, y, x) GPH_SWIZZLE4(Vector3, z, y, y, y) GPH_SWIZZLE4(Vector3, z, y, y, z) \
    1.48 +	GPH_SWIZZLE4(Vector3, z, y, z, x) GPH_SWIZZLE4(Vector3, z, y, z, y) GPH_SWIZZLE4(Vector3, z, y, z, z) \
    1.49 +	GPH_SWIZZLE4(Vector3, z, z, x, x) GPH_SWIZZLE4(Vector3, z, z, x, y) GPH_SWIZZLE4(Vector3, z, z, x, z) \
    1.50 +	GPH_SWIZZLE4(Vector3, z, z, y, x) GPH_SWIZZLE4(Vector3, z, z, y, y) GPH_SWIZZLE4(Vector3, z, z, y, z) \
    1.51 +	GPH_SWIZZLE4(Vector3, z, z, z, x) GPH_SWIZZLE4(Vector3, z, z, z, y) GPH_SWIZZLE4(Vector3, z, z, z, z)
    1.52 +
    1.53 +// swizzle macros for Vector4 (oh shit...)
    1.54 +#define GPH_VEC4_SWIZZLE	\
    1.55 +	GPH_SWIZZLE2(Vector4, x, x) GPH_SWIZZLE2(Vector4, x, y) GPH_SWIZZLE2(Vector4, x, z) GPH_SWIZZLE2(Vector4, x, w) \
    1.56 +	GPH_SWIZZLE2(Vector4, y, x) GPH_SWIZZLE2(Vector4, y, y) GPH_SWIZZLE2(Vector4, y, z) GPH_SWIZZLE2(Vector4, y, w) \
    1.57 +	GPH_SWIZZLE2(Vector4, z, x) GPH_SWIZZLE2(Vector4, z, y) GPH_SWIZZLE2(Vector4, z, z) GPH_SWIZZLE2(Vector4, z, w) \
    1.58 +	GPH_SWIZZLE2(Vector4, w, x) GPH_SWIZZLE2(Vector4, w, y) GPH_SWIZZLE2(Vector4, w, z) GPH_SWIZZLE2(Vector4, w, w) \
    1.59 +	GPH_SWIZZLE3(Vector4, x, x, x) GPH_SWIZZLE3(Vector4, x, x, y) GPH_SWIZZLE3(Vector4, x, x, z) GPH_SWIZZLE3(Vector4, x, x, w) \
    1.60 +	GPH_SWIZZLE3(Vector4, x, y, x) GPH_SWIZZLE3(Vector4, x, y, y) GPH_SWIZZLE3(Vector4, x, y, z) GPH_SWIZZLE3(Vector4, x, y, w) \
    1.61 +	GPH_SWIZZLE3(Vector4, x, z, x) GPH_SWIZZLE3(Vector4, x, z, y) GPH_SWIZZLE3(Vector4, x, z, z) GPH_SWIZZLE3(Vector4, x, z, w) \
    1.62 +	GPH_SWIZZLE3(Vector4, x, w, x) GPH_SWIZZLE3(Vector4, x, w, y) GPH_SWIZZLE3(Vector4, x, w, z) GPH_SWIZZLE3(Vector4, x, w, w) \
    1.63 +	GPH_SWIZZLE3(Vector4, y, x, x) GPH_SWIZZLE3(Vector4, y, x, y) GPH_SWIZZLE3(Vector4, y, x, z) GPH_SWIZZLE3(Vector4, y, x, w) \
    1.64 +	GPH_SWIZZLE3(Vector4, y, y, x) GPH_SWIZZLE3(Vector4, y, y, y) GPH_SWIZZLE3(Vector4, y, y, z) GPH_SWIZZLE3(Vector4, y, y, w) \
    1.65 +	GPH_SWIZZLE3(Vector4, y, z, x) GPH_SWIZZLE3(Vector4, y, z, y) GPH_SWIZZLE3(Vector4, y, z, z) GPH_SWIZZLE3(Vector4, y, z, w) \
    1.66 +	GPH_SWIZZLE3(Vector4, y, w, x) GPH_SWIZZLE3(Vector4, y, w, y) GPH_SWIZZLE3(Vector4, y, w, z) GPH_SWIZZLE3(Vector4, y, w, w) \
    1.67 +	GPH_SWIZZLE3(Vector4, z, x, x) GPH_SWIZZLE3(Vector4, z, x, y) GPH_SWIZZLE3(Vector4, z, x, z) GPH_SWIZZLE3(Vector4, z, x, w) \
    1.68 +	GPH_SWIZZLE3(Vector4, z, y, x) GPH_SWIZZLE3(Vector4, z, y, y) GPH_SWIZZLE3(Vector4, z, y, z) GPH_SWIZZLE3(Vector4, z, y, w) \
    1.69 +	GPH_SWIZZLE3(Vector4, z, z, x) GPH_SWIZZLE3(Vector4, z, z, y) GPH_SWIZZLE3(Vector4, z, z, z) GPH_SWIZZLE3(Vector4, z, z, w) \
    1.70 +	GPH_SWIZZLE3(Vector4, z, w, x) GPH_SWIZZLE3(Vector4, z, w, y) GPH_SWIZZLE3(Vector4, z, w, z) GPH_SWIZZLE3(Vector4, z, w, w) \
    1.71 +	GPH_SWIZZLE3(Vector4, w, x, x) GPH_SWIZZLE3(Vector4, w, x, y) GPH_SWIZZLE3(Vector4, w, x, z) GPH_SWIZZLE3(Vector4, w, x, w) \
    1.72 +	GPH_SWIZZLE3(Vector4, w, y, x) GPH_SWIZZLE3(Vector4, w, y, y) GPH_SWIZZLE3(Vector4, w, y, z) GPH_SWIZZLE3(Vector4, w, y, w) \
    1.73 +	GPH_SWIZZLE3(Vector4, w, z, x) GPH_SWIZZLE3(Vector4, w, z, y) GPH_SWIZZLE3(Vector4, w, z, z) GPH_SWIZZLE3(Vector4, w, z, w) \
    1.74 +	GPH_SWIZZLE3(Vector4, w, w, x) GPH_SWIZZLE3(Vector4, w, w, y) GPH_SWIZZLE3(Vector4, w, w, z) GPH_SWIZZLE3(Vector4, w, w, w) \
    1.75 +	GPH_SWIZZLE4(Vector4, x, x, x, x) GPH_SWIZZLE4(Vector4, x, x, x, y) GPH_SWIZZLE4(Vector4, x, x, x, z) GPH_SWIZZLE4(Vector4, x, x, x, w) \
    1.76 +	GPH_SWIZZLE4(Vector4, x, x, y, x) GPH_SWIZZLE4(Vector4, x, x, y, y) GPH_SWIZZLE4(Vector4, x, x, y, z) GPH_SWIZZLE4(Vector4, x, x, y, w) \
    1.77 +	GPH_SWIZZLE4(Vector4, x, x, z, x) GPH_SWIZZLE4(Vector4, x, x, z, y) GPH_SWIZZLE4(Vector4, x, x, z, z) GPH_SWIZZLE4(Vector4, x, x, z, w) \
    1.78 +	GPH_SWIZZLE4(Vector4, x, x, w, x) GPH_SWIZZLE4(Vector4, x, x, w, y) GPH_SWIZZLE4(Vector4, x, x, w, z) GPH_SWIZZLE4(Vector4, x, x, w, w) \
    1.79 +	GPH_SWIZZLE4(Vector4, x, y, x, x) GPH_SWIZZLE4(Vector4, x, y, x, y) GPH_SWIZZLE4(Vector4, x, y, x, z) GPH_SWIZZLE4(Vector4, x, y, x, w) \
    1.80 +	GPH_SWIZZLE4(Vector4, x, y, y, x) GPH_SWIZZLE4(Vector4, x, y, y, y) GPH_SWIZZLE4(Vector4, x, y, y, z) GPH_SWIZZLE4(Vector4, x, y, y, w) \
    1.81 +	GPH_SWIZZLE4(Vector4, x, y, z, x) GPH_SWIZZLE4(Vector4, x, y, z, y) GPH_SWIZZLE4(Vector4, x, y, z, z) GPH_SWIZZLE4(Vector4, x, y, z, w) \
    1.82 +	GPH_SWIZZLE4(Vector4, x, y, w, x) GPH_SWIZZLE4(Vector4, x, y, w, y) GPH_SWIZZLE4(Vector4, x, y, w, z) GPH_SWIZZLE4(Vector4, x, y, w, w) \
    1.83 +	GPH_SWIZZLE4(Vector4, x, z, x, x) GPH_SWIZZLE4(Vector4, x, z, x, y) GPH_SWIZZLE4(Vector4, x, z, x, z) GPH_SWIZZLE4(Vector4, x, z, x, w) \
    1.84 +	GPH_SWIZZLE4(Vector4, x, z, y, x) GPH_SWIZZLE4(Vector4, x, z, y, y) GPH_SWIZZLE4(Vector4, x, z, y, z) GPH_SWIZZLE4(Vector4, x, z, y, w) \
    1.85 +	GPH_SWIZZLE4(Vector4, x, z, z, x) GPH_SWIZZLE4(Vector4, x, z, z, y) GPH_SWIZZLE4(Vector4, x, z, z, z) GPH_SWIZZLE4(Vector4, x, z, z, w) \
    1.86 +	GPH_SWIZZLE4(Vector4, x, z, w, x) GPH_SWIZZLE4(Vector4, x, z, w, y) GPH_SWIZZLE4(Vector4, x, z, w, z) GPH_SWIZZLE4(Vector4, x, z, w, w) \
    1.87 +	GPH_SWIZZLE4(Vector4, x, w, x, x) GPH_SWIZZLE4(Vector4, x, w, x, y) GPH_SWIZZLE4(Vector4, x, w, x, z) GPH_SWIZZLE4(Vector4, x, w, x, w) \
    1.88 +	GPH_SWIZZLE4(Vector4, x, w, y, x) GPH_SWIZZLE4(Vector4, x, w, y, y) GPH_SWIZZLE4(Vector4, x, w, y, z) GPH_SWIZZLE4(Vector4, x, w, y, w) \
    1.89 +	GPH_SWIZZLE4(Vector4, x, w, z, x) GPH_SWIZZLE4(Vector4, x, w, z, y) GPH_SWIZZLE4(Vector4, x, w, z, z) GPH_SWIZZLE4(Vector4, x, w, z, w) \
    1.90 +	GPH_SWIZZLE4(Vector4, x, w, w, x) GPH_SWIZZLE4(Vector4, x, w, w, y) GPH_SWIZZLE4(Vector4, x, w, w, z) GPH_SWIZZLE4(Vector4, x, w, w, w) \
    1.91 +	GPH_SWIZZLE4(Vector4, y, x, x, x) GPH_SWIZZLE4(Vector4, y, x, x, y) GPH_SWIZZLE4(Vector4, y, x, x, z) GPH_SWIZZLE4(Vector4, y, x, x, w) \
    1.92 +	GPH_SWIZZLE4(Vector4, y, x, y, x) GPH_SWIZZLE4(Vector4, y, x, y, y) GPH_SWIZZLE4(Vector4, y, x, y, z) GPH_SWIZZLE4(Vector4, y, x, y, w) \
    1.93 +	GPH_SWIZZLE4(Vector4, y, x, z, x) GPH_SWIZZLE4(Vector4, y, x, z, y) GPH_SWIZZLE4(Vector4, y, x, z, z) GPH_SWIZZLE4(Vector4, y, x, z, w) \
    1.94 +	GPH_SWIZZLE4(Vector4, y, x, w, x) GPH_SWIZZLE4(Vector4, y, x, w, y) GPH_SWIZZLE4(Vector4, y, x, w, z) GPH_SWIZZLE4(Vector4, y, x, w, w) \
    1.95 +	GPH_SWIZZLE4(Vector4, y, y, x, x) GPH_SWIZZLE4(Vector4, y, y, x, y) GPH_SWIZZLE4(Vector4, y, y, x, z) GPH_SWIZZLE4(Vector4, y, y, x, w) \
    1.96 +	GPH_SWIZZLE4(Vector4, y, y, y, x) GPH_SWIZZLE4(Vector4, y, y, y, y) GPH_SWIZZLE4(Vector4, y, y, y, z) GPH_SWIZZLE4(Vector4, y, y, y, w) \
    1.97 +	GPH_SWIZZLE4(Vector4, y, y, z, x) GPH_SWIZZLE4(Vector4, y, y, z, y) GPH_SWIZZLE4(Vector4, y, y, z, z) GPH_SWIZZLE4(Vector4, y, y, z, w) \
    1.98 +	GPH_SWIZZLE4(Vector4, y, y, w, x) GPH_SWIZZLE4(Vector4, y, y, w, y) GPH_SWIZZLE4(Vector4, y, y, w, z) GPH_SWIZZLE4(Vector4, y, y, w, w) \
    1.99 +	GPH_SWIZZLE4(Vector4, y, z, x, x) GPH_SWIZZLE4(Vector4, y, z, x, y) GPH_SWIZZLE4(Vector4, y, z, x, z) GPH_SWIZZLE4(Vector4, y, z, x, w) \
   1.100 +	GPH_SWIZZLE4(Vector4, y, z, y, x) GPH_SWIZZLE4(Vector4, y, z, y, y) GPH_SWIZZLE4(Vector4, y, z, y, z) GPH_SWIZZLE4(Vector4, y, z, y, w) \
   1.101 +	GPH_SWIZZLE4(Vector4, y, z, z, x) GPH_SWIZZLE4(Vector4, y, z, z, y) GPH_SWIZZLE4(Vector4, y, z, z, z) GPH_SWIZZLE4(Vector4, y, z, z, w) \
   1.102 +	GPH_SWIZZLE4(Vector4, y, z, w, x) GPH_SWIZZLE4(Vector4, y, z, w, y) GPH_SWIZZLE4(Vector4, y, z, w, z) GPH_SWIZZLE4(Vector4, y, z, w, w) \
   1.103 +	GPH_SWIZZLE4(Vector4, y, w, x, x) GPH_SWIZZLE4(Vector4, y, w, x, y) GPH_SWIZZLE4(Vector4, y, w, x, z) GPH_SWIZZLE4(Vector4, y, w, x, w) \
   1.104 +	GPH_SWIZZLE4(Vector4, y, w, y, x) GPH_SWIZZLE4(Vector4, y, w, y, y) GPH_SWIZZLE4(Vector4, y, w, y, z) GPH_SWIZZLE4(Vector4, y, w, y, w) \
   1.105 +	GPH_SWIZZLE4(Vector4, y, w, z, x) GPH_SWIZZLE4(Vector4, y, w, z, y) GPH_SWIZZLE4(Vector4, y, w, z, z) GPH_SWIZZLE4(Vector4, y, w, z, w) \
   1.106 +	GPH_SWIZZLE4(Vector4, y, w, w, x) GPH_SWIZZLE4(Vector4, y, w, w, y) GPH_SWIZZLE4(Vector4, y, w, w, z) GPH_SWIZZLE4(Vector4, y, w, w, w) \
   1.107 +	GPH_SWIZZLE4(Vector4, z, x, x, x) GPH_SWIZZLE4(Vector4, z, x, x, y) GPH_SWIZZLE4(Vector4, z, x, x, z) GPH_SWIZZLE4(Vector4, z, x, x, w) \
   1.108 +	GPH_SWIZZLE4(Vector4, z, x, y, x) GPH_SWIZZLE4(Vector4, z, x, y, y) GPH_SWIZZLE4(Vector4, z, x, y, z) GPH_SWIZZLE4(Vector4, z, x, y, w) \
   1.109 +	GPH_SWIZZLE4(Vector4, z, x, z, x) GPH_SWIZZLE4(Vector4, z, x, z, y) GPH_SWIZZLE4(Vector4, z, x, z, z) GPH_SWIZZLE4(Vector4, z, x, z, w) \
   1.110 +	GPH_SWIZZLE4(Vector4, z, x, w, x) GPH_SWIZZLE4(Vector4, z, x, w, y) GPH_SWIZZLE4(Vector4, z, x, w, z) GPH_SWIZZLE4(Vector4, z, x, w, w) \
   1.111 +	GPH_SWIZZLE4(Vector4, z, y, x, x) GPH_SWIZZLE4(Vector4, z, y, x, y) GPH_SWIZZLE4(Vector4, z, y, x, z) GPH_SWIZZLE4(Vector4, z, y, x, w) \
   1.112 +	GPH_SWIZZLE4(Vector4, z, y, y, x) GPH_SWIZZLE4(Vector4, z, y, y, y) GPH_SWIZZLE4(Vector4, z, y, y, z) GPH_SWIZZLE4(Vector4, z, y, y, w) \
   1.113 +	GPH_SWIZZLE4(Vector4, z, y, z, x) GPH_SWIZZLE4(Vector4, z, y, z, y) GPH_SWIZZLE4(Vector4, z, y, z, z) GPH_SWIZZLE4(Vector4, z, y, z, w) \
   1.114 +	GPH_SWIZZLE4(Vector4, z, y, w, x) GPH_SWIZZLE4(Vector4, z, y, w, y) GPH_SWIZZLE4(Vector4, z, y, w, z) GPH_SWIZZLE4(Vector4, z, y, w, w) \
   1.115 +	GPH_SWIZZLE4(Vector4, z, z, x, x) GPH_SWIZZLE4(Vector4, z, z, x, y) GPH_SWIZZLE4(Vector4, z, z, x, z) GPH_SWIZZLE4(Vector4, z, z, x, w) \
   1.116 +	GPH_SWIZZLE4(Vector4, z, z, y, x) GPH_SWIZZLE4(Vector4, z, z, y, y) GPH_SWIZZLE4(Vector4, z, z, y, z) GPH_SWIZZLE4(Vector4, z, z, y, w) \
   1.117 +	GPH_SWIZZLE4(Vector4, z, z, z, x) GPH_SWIZZLE4(Vector4, z, z, z, y) GPH_SWIZZLE4(Vector4, z, z, z, z) GPH_SWIZZLE4(Vector4, z, z, z, w) \
   1.118 +	GPH_SWIZZLE4(Vector4, z, z, w, x) GPH_SWIZZLE4(Vector4, z, z, w, y) GPH_SWIZZLE4(Vector4, z, z, w, z) GPH_SWIZZLE4(Vector4, z, z, w, w) \
   1.119 +	GPH_SWIZZLE4(Vector4, z, w, x, x) GPH_SWIZZLE4(Vector4, z, w, x, y) GPH_SWIZZLE4(Vector4, z, w, x, z) GPH_SWIZZLE4(Vector4, z, w, x, w) \
   1.120 +	GPH_SWIZZLE4(Vector4, z, w, y, x) GPH_SWIZZLE4(Vector4, z, w, y, y) GPH_SWIZZLE4(Vector4, z, w, y, z) GPH_SWIZZLE4(Vector4, z, w, y, w) \
   1.121 +	GPH_SWIZZLE4(Vector4, z, w, z, x) GPH_SWIZZLE4(Vector4, z, w, z, y) GPH_SWIZZLE4(Vector4, z, w, z, z) GPH_SWIZZLE4(Vector4, z, w, z, w) \
   1.122 +	GPH_SWIZZLE4(Vector4, z, w, w, x) GPH_SWIZZLE4(Vector4, z, w, w, y) GPH_SWIZZLE4(Vector4, z, w, w, z) GPH_SWIZZLE4(Vector4, z, w, w, w) \
   1.123 +	GPH_SWIZZLE4(Vector4, w, x, x, x) GPH_SWIZZLE4(Vector4, w, x, x, y) GPH_SWIZZLE4(Vector4, w, x, x, z) GPH_SWIZZLE4(Vector4, w, x, x, w) \
   1.124 +	GPH_SWIZZLE4(Vector4, w, x, y, x) GPH_SWIZZLE4(Vector4, w, x, y, y) GPH_SWIZZLE4(Vector4, w, x, y, z) GPH_SWIZZLE4(Vector4, w, x, y, w) \
   1.125 +	GPH_SWIZZLE4(Vector4, w, x, z, x) GPH_SWIZZLE4(Vector4, w, x, z, y) GPH_SWIZZLE4(Vector4, w, x, z, z) GPH_SWIZZLE4(Vector4, w, x, z, w) \
   1.126 +	GPH_SWIZZLE4(Vector4, w, x, w, x) GPH_SWIZZLE4(Vector4, w, x, w, y) GPH_SWIZZLE4(Vector4, w, x, w, z) GPH_SWIZZLE4(Vector4, w, x, w, w) \
   1.127 +	GPH_SWIZZLE4(Vector4, w, y, x, x) GPH_SWIZZLE4(Vector4, w, y, x, y) GPH_SWIZZLE4(Vector4, w, y, x, z) GPH_SWIZZLE4(Vector4, w, y, x, w) \
   1.128 +	GPH_SWIZZLE4(Vector4, w, y, y, x) GPH_SWIZZLE4(Vector4, w, y, y, y) GPH_SWIZZLE4(Vector4, w, y, y, z) GPH_SWIZZLE4(Vector4, w, y, y, w) \
   1.129 +	GPH_SWIZZLE4(Vector4, w, y, z, x) GPH_SWIZZLE4(Vector4, w, y, z, y) GPH_SWIZZLE4(Vector4, w, y, z, z) GPH_SWIZZLE4(Vector4, w, y, z, w) \
   1.130 +	GPH_SWIZZLE4(Vector4, w, y, w, x) GPH_SWIZZLE4(Vector4, w, y, w, y) GPH_SWIZZLE4(Vector4, w, y, w, z) GPH_SWIZZLE4(Vector4, w, y, w, w) \
   1.131 +	GPH_SWIZZLE4(Vector4, w, z, x, x) GPH_SWIZZLE4(Vector4, w, z, x, y) GPH_SWIZZLE4(Vector4, w, z, x, z) GPH_SWIZZLE4(Vector4, w, z, x, w) \
   1.132 +	GPH_SWIZZLE4(Vector4, w, z, y, x) GPH_SWIZZLE4(Vector4, w, z, y, y) GPH_SWIZZLE4(Vector4, w, z, y, z) GPH_SWIZZLE4(Vector4, w, z, y, w) \
   1.133 +	GPH_SWIZZLE4(Vector4, w, z, z, x) GPH_SWIZZLE4(Vector4, w, z, z, y) GPH_SWIZZLE4(Vector4, w, z, z, z) GPH_SWIZZLE4(Vector4, w, z, z, w) \
   1.134 +	GPH_SWIZZLE4(Vector4, w, z, w, x) GPH_SWIZZLE4(Vector4, w, z, w, y) GPH_SWIZZLE4(Vector4, w, z, w, z) GPH_SWIZZLE4(Vector4, w, z, w, w) \
   1.135 +	GPH_SWIZZLE4(Vector4, w, w, x, x) GPH_SWIZZLE4(Vector4, w, w, x, y) GPH_SWIZZLE4(Vector4, w, w, x, z) GPH_SWIZZLE4(Vector4, w, w, x, w) \
   1.136 +	GPH_SWIZZLE4(Vector4, w, w, y, x) GPH_SWIZZLE4(Vector4, w, w, y, y) GPH_SWIZZLE4(Vector4, w, w, y, z) GPH_SWIZZLE4(Vector4, w, w, y, w) \
   1.137 +	GPH_SWIZZLE4(Vector4, w, w, z, x) GPH_SWIZZLE4(Vector4, w, w, z, y) GPH_SWIZZLE4(Vector4, w, w, z, z) GPH_SWIZZLE4(Vector4, w, w, z, w) \
   1.138 +	GPH_SWIZZLE4(Vector4, w, w, w, x) GPH_SWIZZLE4(Vector4, w, w, w, y) GPH_SWIZZLE4(Vector4, w, w, w, z) GPH_SWIZZLE4(Vector4, w, w, w, w)
     2.1 --- a/src/gmath/vector.cc	Sat Jul 25 07:42:30 2015 +0300
     2.2 +++ b/src/gmath/vector.cc	Sat Jul 25 17:19:27 2015 +0300
     2.3 @@ -3,6 +3,11 @@
     2.4  
     2.5  namespace gph {
     2.6  
     2.7 +Vector2::Vector2(const Vector3 &v)
     2.8 +	: x(v.x), y(v.y)
     2.9 +{
    2.10 +}
    2.11 +
    2.12  Vector3::Vector3(const Vector4 &v)
    2.13  	: x(v.x), y(v.y), z(v.z)
    2.14  {
     3.1 --- a/src/gmath/vector.h	Sat Jul 25 07:42:30 2015 +0300
     3.2 +++ b/src/gmath/vector.h	Sat Jul 25 17:19:27 2015 +0300
     3.3 @@ -2,12 +2,33 @@
     3.4  #define GMATH_VEC_H_
     3.5  
     3.6  #include <math.h>
     3.7 +#include "swizzle.h"
     3.8  
     3.9  namespace gph {
    3.10  
    3.11 +#define GPH_SWIZZLE2(T, a, b)		inline Vector2 a##b() const;
    3.12 +#define GPH_SWIZZLE3(T, a, b, c)	inline Vector3 a##b##c() const;
    3.13 +#define GPH_SWIZZLE4(T, a, b, c, d)	inline Vector4 a##b##c##d() const;
    3.14 +
    3.15 +class Vector3;
    3.16  class Vector4;
    3.17  class Matrix4x4;
    3.18  
    3.19 +class Vector2 {
    3.20 +public:
    3.21 +	float x, y;
    3.22 +
    3.23 +	Vector2() : x(0), y(0) {}
    3.24 +	Vector2(float x_, float y_) : x(x_), y(y_) {}
    3.25 +	Vector2(const Vector3 &v);
    3.26 +
    3.27 +	inline void normalize();
    3.28 +	inline float &operator[] (int idx);
    3.29 +	inline const float &operator[] (int idx) const;
    3.30 +
    3.31 +	GPH_VEC2_SWIZZLE
    3.32 +};
    3.33 +
    3.34  class Vector3 {
    3.35  public:
    3.36  	float x, y, z;
    3.37 @@ -19,6 +40,8 @@
    3.38  	inline void normalize();
    3.39  	inline float &operator[] (int idx);
    3.40  	inline const float &operator[] (int idx) const;
    3.41 +
    3.42 +	GPH_VEC3_SWIZZLE
    3.43  };
    3.44  
    3.45  
    3.46 @@ -33,6 +56,8 @@
    3.47  	inline void normalize();
    3.48  	inline float &operator[] (int idx);
    3.49  	inline const float &operator[] (int idx) const;
    3.50 +
    3.51 +	GPH_VEC4_SWIZZLE
    3.52  };
    3.53  
    3.54  // ---- Vector3 functions ----
     4.1 --- a/src/gmath/vector.inl	Sat Jul 25 07:42:30 2015 +0300
     4.2 +++ b/src/gmath/vector.inl	Sat Jul 25 17:19:27 2015 +0300
     4.3 @@ -2,6 +2,13 @@
     4.4  
     4.5  namespace gph {
     4.6  
     4.7 +#undef GPH_SWIZZLE2
     4.8 +#undef GPH_SWIZZLE3
     4.9 +#undef GPH_SWIZZLE4
    4.10 +#define GPH_SWIZZLE2(T, a, b)		inline Vector2 T::a##b() const { return Vector2(a, b); }
    4.11 +#define GPH_SWIZZLE3(T, a, b, c)	inline Vector3 T::a##b##c() const { return Vector3(a, b, c); }
    4.12 +#define GPH_SWIZZLE4(T, a, b, c, d)	inline Vector4 T::a##b##c##d() const { return Vector4(a, b, c, d); }
    4.13 +
    4.14  // ---- Vector3 ----
    4.15  
    4.16  inline void Vector3::normalize()
    4.17 @@ -190,6 +197,8 @@
    4.18  	return dot(ng, i) < 0.0f ? n : -n;
    4.19  }
    4.20  
    4.21 +GPH_VEC3_SWIZZLE
    4.22 +
    4.23  // ---- Vector4 ----
    4.24  
    4.25  
    4.26 @@ -214,4 +223,29 @@
    4.27  	return idx == 0 ? x : (idx == 1 ? y : (idx == 2 ? z : w));
    4.28  }
    4.29  
    4.30 +GPH_VEC4_SWIZZLE
    4.31 +
    4.32 +// ---- Vector2 ----
    4.33 +
    4.34 +inline void Vector2::normalize()
    4.35 +{
    4.36 +	float len = (float)sqrt(x * x + y * y);
    4.37 +	if(len != 0.0f) {
    4.38 +		x /= len;
    4.39 +		y /= len;
    4.40 +	}
    4.41 +}
    4.42 +
    4.43 +inline float &Vector2::operator[] (int idx)
    4.44 +{
    4.45 +	return idx == 0 ? x : y;
    4.46 +}
    4.47 +
    4.48 +inline const float &Vector2::operator[] (int idx) const
    4.49 +{
    4.50 +	return idx == 0 ? x : y;
    4.51 +}
    4.52 +
    4.53 +GPH_VEC2_SWIZZLE
    4.54 +
    4.55  }	// namespace gph