goat3d

diff libs/vmath/vector.inl @ 28:9ba3e2fb8a33

modified vmath to work with vs2012, still memory corruptions in 3dsmax...
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Sep 2013 08:46:19 +0300
parents 4deb0b12fe14
children
line diff
     1.1 --- a/libs/vmath/vector.inl	Sun Sep 29 08:20:19 2013 +0300
     1.2 +++ b/libs/vmath/vector.inl	Sun Sep 29 08:46:19 2013 +0300
     1.3 @@ -23,7 +23,7 @@
     1.4  #endif	/* __cplusplus */
     1.5  
     1.6  /* C 2D vector functions */
     1.7 -static inline vec2_t v2_cons(scalar_t x, scalar_t y)
     1.8 +static VMATH_INLINE vec2_t v2_cons(scalar_t x, scalar_t y)
     1.9  {
    1.10  	vec2_t v;
    1.11  	v.x = x;
    1.12 @@ -31,12 +31,12 @@
    1.13  	return v;
    1.14  }
    1.15  
    1.16 -static inline void v2_print(FILE *fp, vec2_t v)
    1.17 +static VMATH_INLINE void v2_print(FILE *fp, vec2_t v)
    1.18  {
    1.19  	fprintf(fp, "[ %.4f %.4f ]", v.x, v.y);
    1.20  }
    1.21  
    1.22 -static inline vec2_t v2_add(vec2_t v1, vec2_t v2)
    1.23 +static VMATH_INLINE vec2_t v2_add(vec2_t v1, vec2_t v2)
    1.24  {
    1.25  	vec2_t res;
    1.26  	res.x = v1.x + v2.x;
    1.27 @@ -44,7 +44,7 @@
    1.28  	return res;
    1.29  }
    1.30  
    1.31 -static inline vec2_t v2_sub(vec2_t v1, vec2_t v2)
    1.32 +static VMATH_INLINE vec2_t v2_sub(vec2_t v1, vec2_t v2)
    1.33  {
    1.34  	vec2_t res;
    1.35  	res.x = v1.x - v2.x;
    1.36 @@ -52,7 +52,7 @@
    1.37  	return res;
    1.38  }
    1.39  
    1.40 -static inline vec2_t v2_scale(vec2_t v, scalar_t s)
    1.41 +static VMATH_INLINE vec2_t v2_scale(vec2_t v, scalar_t s)
    1.42  {
    1.43  	vec2_t res;
    1.44  	res.x = v.x * s;
    1.45 @@ -60,22 +60,22 @@
    1.46  	return res;
    1.47  }
    1.48  
    1.49 -static inline scalar_t v2_dot(vec2_t v1, vec2_t v2)
    1.50 +static VMATH_INLINE scalar_t v2_dot(vec2_t v1, vec2_t v2)
    1.51  {
    1.52  	return v1.x * v2.x + v1.y * v2.y;
    1.53  }
    1.54  
    1.55 -static inline scalar_t v2_length(vec2_t v)
    1.56 +static VMATH_INLINE scalar_t v2_length(vec2_t v)
    1.57  {
    1.58  	return sqrt(v.x * v.x + v.y * v.y);
    1.59  }
    1.60  
    1.61 -static inline scalar_t v2_length_sq(vec2_t v)
    1.62 +static VMATH_INLINE scalar_t v2_length_sq(vec2_t v)
    1.63  {
    1.64  	return v.x * v.x + v.y * v.y;
    1.65  }
    1.66  
    1.67 -static inline vec2_t v2_normalize(vec2_t v)
    1.68 +static VMATH_INLINE vec2_t v2_normalize(vec2_t v)
    1.69  {
    1.70  	scalar_t len = (scalar_t)sqrt(v.x * v.x + v.y * v.y);
    1.71  	v.x /= len;
    1.72 @@ -83,7 +83,7 @@
    1.73  	return v;
    1.74  }
    1.75  
    1.76 -static inline vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t)
    1.77 +static VMATH_INLINE vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t)
    1.78  {
    1.79  	vec2_t res;
    1.80  	res.x = v1.x + (v2.x - v1.x) * t;
    1.81 @@ -93,7 +93,7 @@
    1.82  
    1.83  
    1.84  /* C 3D vector functions */
    1.85 -static inline vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z)
    1.86 +static VMATH_INLINE vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z)
    1.87  {
    1.88  	vec3_t v;
    1.89  	v.x = x;
    1.90 @@ -102,12 +102,12 @@
    1.91  	return v;
    1.92  }
    1.93  
    1.94 -static inline void v3_print(FILE *fp, vec3_t v)
    1.95 +static VMATH_INLINE void v3_print(FILE *fp, vec3_t v)
    1.96  {
    1.97  	fprintf(fp, "[ %.4f %.4f %.4f ]", v.x, v.y, v.z);
    1.98  }
    1.99  
   1.100 -static inline vec3_t v3_add(vec3_t v1, vec3_t v2)
   1.101 +static VMATH_INLINE vec3_t v3_add(vec3_t v1, vec3_t v2)
   1.102  {
   1.103  	v1.x += v2.x;
   1.104  	v1.y += v2.y;
   1.105 @@ -115,7 +115,7 @@
   1.106  	return v1;
   1.107  }
   1.108  
   1.109 -static inline vec3_t v3_sub(vec3_t v1, vec3_t v2)
   1.110 +static VMATH_INLINE vec3_t v3_sub(vec3_t v1, vec3_t v2)
   1.111  {
   1.112  	v1.x -= v2.x;
   1.113  	v1.y -= v2.y;
   1.114 @@ -123,7 +123,7 @@
   1.115  	return v1;
   1.116  }
   1.117  
   1.118 -static inline vec3_t v3_neg(vec3_t v)
   1.119 +static VMATH_INLINE vec3_t v3_neg(vec3_t v)
   1.120  {
   1.121  	v.x = -v.x;
   1.122  	v.y = -v.y;
   1.123 @@ -131,7 +131,7 @@
   1.124  	return v;
   1.125  }
   1.126  
   1.127 -static inline vec3_t v3_mul(vec3_t v1, vec3_t v2)
   1.128 +static VMATH_INLINE vec3_t v3_mul(vec3_t v1, vec3_t v2)
   1.129  {
   1.130  	v1.x *= v2.x;
   1.131  	v1.y *= v2.y;
   1.132 @@ -139,7 +139,7 @@
   1.133  	return v1;
   1.134  }
   1.135  
   1.136 -static inline vec3_t v3_scale(vec3_t v1, scalar_t s)
   1.137 +static VMATH_INLINE vec3_t v3_scale(vec3_t v1, scalar_t s)
   1.138  {
   1.139  	v1.x *= s;
   1.140  	v1.y *= s;
   1.141 @@ -147,12 +147,12 @@
   1.142  	return v1;
   1.143  }
   1.144  
   1.145 -static inline scalar_t v3_dot(vec3_t v1, vec3_t v2)
   1.146 +static VMATH_INLINE scalar_t v3_dot(vec3_t v1, vec3_t v2)
   1.147  {
   1.148  	return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
   1.149  }
   1.150  
   1.151 -static inline vec3_t v3_cross(vec3_t v1, vec3_t v2)
   1.152 +static VMATH_INLINE vec3_t v3_cross(vec3_t v1, vec3_t v2)
   1.153  {
   1.154  	vec3_t v;
   1.155  	v.x = v1.y * v2.z - v1.z * v2.y;
   1.156 @@ -161,17 +161,17 @@
   1.157  	return v;
   1.158  }
   1.159  
   1.160 -static inline scalar_t v3_length(vec3_t v)
   1.161 +static VMATH_INLINE scalar_t v3_length(vec3_t v)
   1.162  {
   1.163  	return sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
   1.164  }
   1.165  
   1.166 -static inline scalar_t v3_length_sq(vec3_t v)
   1.167 +static VMATH_INLINE scalar_t v3_length_sq(vec3_t v)
   1.168  {
   1.169  	return v.x * v.x + v.y * v.y + v.z * v.z;
   1.170  }
   1.171  
   1.172 -static inline vec3_t v3_normalize(vec3_t v)
   1.173 +static VMATH_INLINE vec3_t v3_normalize(vec3_t v)
   1.174  {
   1.175  	scalar_t len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
   1.176  	v.x /= len;
   1.177 @@ -180,7 +180,7 @@
   1.178  	return v;
   1.179  }
   1.180  
   1.181 -static inline vec3_t v3_transform(vec3_t v, mat4_t m)
   1.182 +static VMATH_INLINE vec3_t v3_transform(vec3_t v, mat4_t m)
   1.183  {
   1.184  	vec3_t res;
   1.185  	res.x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3];
   1.186 @@ -189,7 +189,7 @@
   1.187  	return res;
   1.188  }
   1.189  
   1.190 -static inline vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z)
   1.191 +static VMATH_INLINE vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z)
   1.192  {
   1.193  	void m4_rotate(mat4_t, scalar_t, scalar_t, scalar_t);
   1.194  
   1.195 @@ -198,7 +198,7 @@
   1.196  	return v3_transform(v, m);
   1.197  }
   1.198  
   1.199 -static inline vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z)
   1.200 +static VMATH_INLINE vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z)
   1.201  {
   1.202  	void m4_rotate_axis(mat4_t, scalar_t, scalar_t, scalar_t, scalar_t);
   1.203  
   1.204 @@ -207,7 +207,7 @@
   1.205  	return v3_transform(v, m);
   1.206  }
   1.207  
   1.208 -static inline vec3_t v3_rotate_quat(vec3_t v, quat_t q)
   1.209 +static VMATH_INLINE vec3_t v3_rotate_quat(vec3_t v, quat_t q)
   1.210  {
   1.211  	quat_t quat_rotate_quat(quat_t, quat_t);
   1.212  
   1.213 @@ -216,13 +216,13 @@
   1.214  	return v3_cons(res.x, res.y, res.z);
   1.215  }
   1.216  
   1.217 -static inline vec3_t v3_reflect(vec3_t v, vec3_t n)
   1.218 +static VMATH_INLINE vec3_t v3_reflect(vec3_t v, vec3_t n)
   1.219  {
   1.220  	scalar_t dot = v3_dot(v, n);
   1.221  	return v3_sub(v3_scale(n, dot * 2.0), v);
   1.222  }
   1.223  
   1.224 -static inline vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t)
   1.225 +static VMATH_INLINE vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t)
   1.226  {
   1.227  	v1.x += (v2.x - v1.x) * t;
   1.228  	v1.y += (v2.y - v1.y) * t;
   1.229 @@ -231,7 +231,7 @@
   1.230  }
   1.231  
   1.232  /* C 4D vector functions */
   1.233 -static inline vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w)
   1.234 +static VMATH_INLINE vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w)
   1.235  {
   1.236  	vec4_t v;
   1.237  	v.x = x;
   1.238 @@ -241,12 +241,12 @@
   1.239  	return v;
   1.240  }
   1.241  
   1.242 -static inline void v4_print(FILE *fp, vec4_t v)
   1.243 +static VMATH_INLINE void v4_print(FILE *fp, vec4_t v)
   1.244  {
   1.245  	fprintf(fp, "[ %.4f %.4f %.4f %.4f ]", v.x, v.y, v.z, v.w);
   1.246  }
   1.247  
   1.248 -static inline vec4_t v4_add(vec4_t v1, vec4_t v2)
   1.249 +static VMATH_INLINE vec4_t v4_add(vec4_t v1, vec4_t v2)
   1.250  {
   1.251  	v1.x += v2.x;
   1.252  	v1.y += v2.y;
   1.253 @@ -255,7 +255,7 @@
   1.254  	return v1;
   1.255  }
   1.256  
   1.257 -static inline vec4_t v4_sub(vec4_t v1, vec4_t v2)
   1.258 +static VMATH_INLINE vec4_t v4_sub(vec4_t v1, vec4_t v2)
   1.259  {
   1.260  	v1.x -= v2.x;
   1.261  	v1.y -= v2.y;
   1.262 @@ -264,7 +264,7 @@
   1.263  	return v1;
   1.264  }
   1.265  
   1.266 -static inline vec4_t v4_neg(vec4_t v)
   1.267 +static VMATH_INLINE vec4_t v4_neg(vec4_t v)
   1.268  {
   1.269  	v.x = -v.x;
   1.270  	v.y = -v.y;
   1.271 @@ -273,7 +273,7 @@
   1.272  	return v;
   1.273  }
   1.274  
   1.275 -static inline vec4_t v4_mul(vec4_t v1, vec4_t v2)
   1.276 +static VMATH_INLINE vec4_t v4_mul(vec4_t v1, vec4_t v2)
   1.277  {
   1.278  	v1.x *= v2.x;
   1.279  	v1.y *= v2.y;
   1.280 @@ -282,7 +282,7 @@
   1.281  	return v1;
   1.282  }
   1.283  
   1.284 -static inline vec4_t v4_scale(vec4_t v, scalar_t s)
   1.285 +static VMATH_INLINE vec4_t v4_scale(vec4_t v, scalar_t s)
   1.286  {
   1.287  	v.x *= s;
   1.288  	v.y *= s;
   1.289 @@ -291,22 +291,22 @@
   1.290  	return v;
   1.291  }
   1.292  
   1.293 -static inline scalar_t v4_dot(vec4_t v1, vec4_t v2)
   1.294 +static VMATH_INLINE scalar_t v4_dot(vec4_t v1, vec4_t v2)
   1.295  {
   1.296  	return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
   1.297  }
   1.298  
   1.299 -static inline scalar_t v4_length(vec4_t v)
   1.300 +static VMATH_INLINE scalar_t v4_length(vec4_t v)
   1.301  {
   1.302  	return sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w);
   1.303  }
   1.304  
   1.305 -static inline scalar_t v4_length_sq(vec4_t v)
   1.306 +static VMATH_INLINE scalar_t v4_length_sq(vec4_t v)
   1.307  {
   1.308  	return v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w;
   1.309  }
   1.310  
   1.311 -static inline vec4_t v4_normalize(vec4_t v)
   1.312 +static VMATH_INLINE vec4_t v4_normalize(vec4_t v)
   1.313  {
   1.314  	scalar_t len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w);
   1.315  	v.x /= len;
   1.316 @@ -316,7 +316,7 @@
   1.317  	return v;
   1.318  }
   1.319  
   1.320 -static inline vec4_t v4_transform(vec4_t v, mat4_t m)
   1.321 +static VMATH_INLINE vec4_t v4_transform(vec4_t v, mat4_t m)
   1.322  {
   1.323  	vec4_t res;
   1.324  	res.x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w;
   1.325 @@ -332,120 +332,120 @@
   1.326  
   1.327  /* --------------- C++ part -------------- */
   1.328  
   1.329 -inline scalar_t &Vector2::operator [](int elem) {
   1.330 +VMATH_INLINE scalar_t &Vector2::operator [](int elem) {
   1.331  	return elem ? y : x;
   1.332  }
   1.333  
   1.334 -inline const scalar_t &Vector2::operator [](int elem) const {
   1.335 +VMATH_INLINE const scalar_t &Vector2::operator [](int elem) const {
   1.336  	return elem ? y : x;
   1.337  }
   1.338  
   1.339 -inline Vector2 operator -(const Vector2 &vec) {
   1.340 +VMATH_INLINE Vector2 operator -(const Vector2 &vec) {
   1.341  	return Vector2(-vec.x, -vec.y);
   1.342  }
   1.343  
   1.344 -inline scalar_t dot_product(const Vector2 &v1, const Vector2 &v2) {
   1.345 +VMATH_INLINE scalar_t dot_product(const Vector2 &v1, const Vector2 &v2) {
   1.346  	return v1.x * v2.x + v1.y * v2.y;
   1.347  }
   1.348  
   1.349 -inline Vector2 operator +(const Vector2 &v1, const Vector2 &v2) {
   1.350 +VMATH_INLINE Vector2 operator +(const Vector2 &v1, const Vector2 &v2) {
   1.351  	return Vector2(v1.x + v2.x, v1.y + v2.y);
   1.352  }
   1.353  
   1.354 -inline Vector2 operator -(const Vector2 &v1, const Vector2 &v2) {
   1.355 +VMATH_INLINE Vector2 operator -(const Vector2 &v1, const Vector2 &v2) {
   1.356  	return Vector2(v1.x - v2.x, v1.y - v2.y);
   1.357  }
   1.358  
   1.359 -inline Vector2 operator *(const Vector2 &v1, const Vector2 &v2) {
   1.360 +VMATH_INLINE Vector2 operator *(const Vector2 &v1, const Vector2 &v2) {
   1.361  	return Vector2(v1.x * v2.x, v1.y * v2.y);
   1.362  }
   1.363  
   1.364 -inline Vector2 operator /(const Vector2 &v1, const Vector2 &v2) {
   1.365 +VMATH_INLINE Vector2 operator /(const Vector2 &v1, const Vector2 &v2) {
   1.366  	return Vector2(v1.x / v2.x, v1.y / v2.y);
   1.367  }
   1.368  
   1.369 -inline bool operator ==(const Vector2 &v1, const Vector2 &v2) {
   1.370 +VMATH_INLINE bool operator ==(const Vector2 &v1, const Vector2 &v2) {
   1.371  	return (fabs(v1.x - v2.x) < XSMALL_NUMBER) && (fabs(v1.y - v2.x) < XSMALL_NUMBER);
   1.372  }
   1.373  
   1.374 -inline void operator +=(Vector2 &v1, const Vector2 &v2) {
   1.375 +VMATH_INLINE void operator +=(Vector2 &v1, const Vector2 &v2) {
   1.376  	v1.x += v2.x;
   1.377  	v1.y += v2.y;
   1.378  }
   1.379  
   1.380 -inline void operator -=(Vector2 &v1, const Vector2 &v2) {
   1.381 +VMATH_INLINE void operator -=(Vector2 &v1, const Vector2 &v2) {
   1.382  	v1.x -= v2.x;
   1.383  	v1.y -= v2.y;
   1.384  }
   1.385  
   1.386 -inline void operator *=(Vector2 &v1, const Vector2 &v2) {
   1.387 +VMATH_INLINE void operator *=(Vector2 &v1, const Vector2 &v2) {
   1.388  	v1.x *= v2.x;
   1.389  	v1.y *= v2.y;
   1.390  }
   1.391  
   1.392 -inline void operator /=(Vector2 &v1, const Vector2 &v2) {
   1.393 +VMATH_INLINE void operator /=(Vector2 &v1, const Vector2 &v2) {
   1.394  	v1.x /= v2.x;
   1.395  	v1.y /= v2.y;
   1.396  }
   1.397  
   1.398 -inline Vector2 operator +(const Vector2 &vec, scalar_t scalar) {
   1.399 +VMATH_INLINE Vector2 operator +(const Vector2 &vec, scalar_t scalar) {
   1.400  	return Vector2(vec.x + scalar, vec.y + scalar);
   1.401  }
   1.402  
   1.403 -inline Vector2 operator +(scalar_t scalar, const Vector2 &vec) {
   1.404 +VMATH_INLINE Vector2 operator +(scalar_t scalar, const Vector2 &vec) {
   1.405  	return Vector2(vec.x + scalar, vec.y + scalar);
   1.406  }
   1.407  
   1.408 -inline Vector2 operator -(scalar_t scalar, const Vector2 &vec) {
   1.409 +VMATH_INLINE Vector2 operator -(scalar_t scalar, const Vector2 &vec) {
   1.410  	return Vector2(vec.x - scalar, vec.y - scalar);
   1.411  }
   1.412  
   1.413 -inline Vector2 operator *(const Vector2 &vec, scalar_t scalar) {
   1.414 +VMATH_INLINE Vector2 operator *(const Vector2 &vec, scalar_t scalar) {
   1.415  	return Vector2(vec.x * scalar, vec.y * scalar);
   1.416  }
   1.417  
   1.418 -inline Vector2 operator *(scalar_t scalar, const Vector2 &vec) {
   1.419 +VMATH_INLINE Vector2 operator *(scalar_t scalar, const Vector2 &vec) {
   1.420  	return Vector2(vec.x * scalar, vec.y * scalar);
   1.421  }
   1.422  
   1.423 -inline Vector2 operator /(const Vector2 &vec, scalar_t scalar) {
   1.424 +VMATH_INLINE Vector2 operator /(const Vector2 &vec, scalar_t scalar) {
   1.425  	return Vector2(vec.x / scalar, vec.y / scalar);
   1.426  }
   1.427  
   1.428 -inline void operator +=(Vector2 &vec, scalar_t scalar) {
   1.429 +VMATH_INLINE void operator +=(Vector2 &vec, scalar_t scalar) {
   1.430  	vec.x += scalar;
   1.431  	vec.y += scalar;
   1.432  }
   1.433  
   1.434 -inline void operator -=(Vector2 &vec, scalar_t scalar) {
   1.435 +VMATH_INLINE void operator -=(Vector2 &vec, scalar_t scalar) {
   1.436  	vec.x -= scalar;
   1.437  	vec.y -= scalar;
   1.438  }
   1.439  
   1.440 -inline void operator *=(Vector2 &vec, scalar_t scalar) {
   1.441 +VMATH_INLINE void operator *=(Vector2 &vec, scalar_t scalar) {
   1.442  	vec.x *= scalar;
   1.443  	vec.y *= scalar;
   1.444  }
   1.445  
   1.446 -inline void operator /=(Vector2 &vec, scalar_t scalar) {
   1.447 +VMATH_INLINE void operator /=(Vector2 &vec, scalar_t scalar) {
   1.448  	vec.x /= scalar;
   1.449  	vec.y /= scalar;
   1.450  }
   1.451  
   1.452 -inline scalar_t Vector2::length() const {
   1.453 +VMATH_INLINE scalar_t Vector2::length() const {
   1.454  	return sqrt(x*x + y*y);
   1.455  }
   1.456  
   1.457 -inline scalar_t Vector2::length_sq() const {
   1.458 +VMATH_INLINE scalar_t Vector2::length_sq() const {
   1.459  	return x*x + y*y;
   1.460  }
   1.461  
   1.462 -inline Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t)
   1.463 +VMATH_INLINE Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t)
   1.464  {
   1.465  	return a + (b - a) * t;
   1.466  }
   1.467  
   1.468 -inline Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1,
   1.469 +VMATH_INLINE Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1,
   1.470  		const Vector2 &v2, const Vector2 &v3, scalar_t t)
   1.471  {
   1.472  	scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t);
   1.473 @@ -457,133 +457,133 @@
   1.474  
   1.475  /* ------------- Vector3 -------------- */
   1.476  
   1.477 -inline scalar_t &Vector3::operator [](int elem) {
   1.478 +VMATH_INLINE scalar_t &Vector3::operator [](int elem) {
   1.479  	return elem ? (elem == 1 ? y : z) : x;
   1.480  }
   1.481  
   1.482 -inline const scalar_t &Vector3::operator [](int elem) const {
   1.483 +VMATH_INLINE const scalar_t &Vector3::operator [](int elem) const {
   1.484  	return elem ? (elem == 1 ? y : z) : x;
   1.485  }
   1.486  
   1.487  /* unary operations */
   1.488 -inline Vector3 operator -(const Vector3 &vec) {
   1.489 +VMATH_INLINE Vector3 operator -(const Vector3 &vec) {
   1.490  	return Vector3(-vec.x, -vec.y, -vec.z);
   1.491  }
   1.492  
   1.493  /* binary vector (op) vector operations */
   1.494 -inline scalar_t dot_product(const Vector3 &v1, const Vector3 &v2) {
   1.495 +VMATH_INLINE scalar_t dot_product(const Vector3 &v1, const Vector3 &v2) {
   1.496  	return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
   1.497  }
   1.498  
   1.499 -inline Vector3 cross_product(const Vector3 &v1, const Vector3 &v2) {
   1.500 +VMATH_INLINE Vector3 cross_product(const Vector3 &v1, const Vector3 &v2) {
   1.501  	return Vector3(v1.y * v2.z - v1.z * v2.y,  v1.z * v2.x - v1.x * v2.z,  v1.x * v2.y - v1.y * v2.x);
   1.502  }
   1.503  
   1.504  
   1.505 -inline Vector3 operator +(const Vector3 &v1, const Vector3 &v2) {
   1.506 +VMATH_INLINE Vector3 operator +(const Vector3 &v1, const Vector3 &v2) {
   1.507  	return Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
   1.508  }
   1.509  
   1.510 -inline Vector3 operator -(const Vector3 &v1, const Vector3 &v2) {
   1.511 +VMATH_INLINE Vector3 operator -(const Vector3 &v1, const Vector3 &v2) {
   1.512  	return Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
   1.513  }
   1.514  
   1.515 -inline Vector3 operator *(const Vector3 &v1, const Vector3 &v2) {
   1.516 +VMATH_INLINE Vector3 operator *(const Vector3 &v1, const Vector3 &v2) {
   1.517  	return Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
   1.518  }
   1.519  
   1.520 -inline Vector3 operator /(const Vector3 &v1, const Vector3 &v2) {
   1.521 +VMATH_INLINE Vector3 operator /(const Vector3 &v1, const Vector3 &v2) {
   1.522  	return Vector3(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z);
   1.523  }
   1.524  
   1.525 -inline bool operator ==(const Vector3 &v1, const Vector3 &v2) {
   1.526 +VMATH_INLINE bool operator ==(const Vector3 &v1, const Vector3 &v2) {
   1.527  	return (fabs(v1.x - v2.x) < XSMALL_NUMBER) && (fabs(v1.y - v2.y) < XSMALL_NUMBER) && (fabs(v1.z - v2.z) < XSMALL_NUMBER);
   1.528  }
   1.529  
   1.530 -inline void operator +=(Vector3 &v1, const Vector3 &v2) {
   1.531 +VMATH_INLINE void operator +=(Vector3 &v1, const Vector3 &v2) {
   1.532  	v1.x += v2.x;
   1.533  	v1.y += v2.y;
   1.534  	v1.z += v2.z;
   1.535  }
   1.536  
   1.537 -inline void operator -=(Vector3 &v1, const Vector3 &v2) {
   1.538 +VMATH_INLINE void operator -=(Vector3 &v1, const Vector3 &v2) {
   1.539  	v1.x -= v2.x;
   1.540  	v1.y -= v2.y;
   1.541  	v1.z -= v2.z;
   1.542  }
   1.543  
   1.544 -inline void operator *=(Vector3 &v1, const Vector3 &v2) {
   1.545 +VMATH_INLINE void operator *=(Vector3 &v1, const Vector3 &v2) {
   1.546  	v1.x *= v2.x;
   1.547  	v1.y *= v2.y;
   1.548  	v1.z *= v2.z;
   1.549  }
   1.550  
   1.551 -inline void operator /=(Vector3 &v1, const Vector3 &v2) {
   1.552 +VMATH_INLINE void operator /=(Vector3 &v1, const Vector3 &v2) {
   1.553  	v1.x /= v2.x;
   1.554  	v1.y /= v2.y;
   1.555  	v1.z /= v2.z;
   1.556  }
   1.557  /* binary vector (op) scalar and scalar (op) vector operations */
   1.558 -inline Vector3 operator +(const Vector3 &vec, scalar_t scalar) {
   1.559 +VMATH_INLINE Vector3 operator +(const Vector3 &vec, scalar_t scalar) {
   1.560  	return Vector3(vec.x + scalar, vec.y + scalar, vec.z + scalar);
   1.561  }
   1.562  
   1.563 -inline Vector3 operator +(scalar_t scalar, const Vector3 &vec) {
   1.564 +VMATH_INLINE Vector3 operator +(scalar_t scalar, const Vector3 &vec) {
   1.565  	return Vector3(vec.x + scalar, vec.y + scalar, vec.z + scalar);
   1.566  }
   1.567  
   1.568 -inline Vector3 operator -(const Vector3 &vec, scalar_t scalar) {
   1.569 +VMATH_INLINE Vector3 operator -(const Vector3 &vec, scalar_t scalar) {
   1.570  	return Vector3(vec.x - scalar, vec.y - scalar, vec.z - scalar);
   1.571  }
   1.572  
   1.573 -inline Vector3 operator *(const Vector3 &vec, scalar_t scalar) {
   1.574 +VMATH_INLINE Vector3 operator *(const Vector3 &vec, scalar_t scalar) {
   1.575  	return Vector3(vec.x * scalar, vec.y * scalar, vec.z * scalar);
   1.576  }
   1.577  
   1.578 -inline Vector3 operator *(scalar_t scalar, const Vector3 &vec) {
   1.579 +VMATH_INLINE Vector3 operator *(scalar_t scalar, const Vector3 &vec) {
   1.580  	return Vector3(vec.x * scalar, vec.y * scalar, vec.z * scalar);
   1.581  }
   1.582  
   1.583 -inline Vector3 operator /(const Vector3 &vec, scalar_t scalar) {
   1.584 +VMATH_INLINE Vector3 operator /(const Vector3 &vec, scalar_t scalar) {
   1.585  	return Vector3(vec.x / scalar, vec.y / scalar, vec.z / scalar);
   1.586  }
   1.587  
   1.588 -inline void operator +=(Vector3 &vec, scalar_t scalar) {
   1.589 +VMATH_INLINE void operator +=(Vector3 &vec, scalar_t scalar) {
   1.590  	vec.x += scalar;
   1.591  	vec.y += scalar;
   1.592  	vec.z += scalar;
   1.593  }
   1.594  
   1.595 -inline void operator -=(Vector3 &vec, scalar_t scalar) {
   1.596 +VMATH_INLINE void operator -=(Vector3 &vec, scalar_t scalar) {
   1.597  	vec.x -= scalar;
   1.598  	vec.y -= scalar;
   1.599  	vec.z -= scalar;
   1.600  }
   1.601  
   1.602 -inline void operator *=(Vector3 &vec, scalar_t scalar) {
   1.603 +VMATH_INLINE void operator *=(Vector3 &vec, scalar_t scalar) {
   1.604  	vec.x *= scalar;
   1.605  	vec.y *= scalar;
   1.606  	vec.z *= scalar;
   1.607  }
   1.608  
   1.609 -inline void operator /=(Vector3 &vec, scalar_t scalar) {
   1.610 +VMATH_INLINE void operator /=(Vector3 &vec, scalar_t scalar) {
   1.611  	vec.x /= scalar;
   1.612  	vec.y /= scalar;
   1.613  	vec.z /= scalar;
   1.614  }
   1.615  
   1.616 -inline scalar_t Vector3::length() const {
   1.617 +VMATH_INLINE scalar_t Vector3::length() const {
   1.618  	return sqrt(x*x + y*y + z*z);
   1.619  }
   1.620 -inline scalar_t Vector3::length_sq() const {
   1.621 +VMATH_INLINE scalar_t Vector3::length_sq() const {
   1.622  	return x*x + y*y + z*z;
   1.623  }
   1.624  
   1.625 -inline Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t) {
   1.626 +VMATH_INLINE Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t) {
   1.627  	return a + (b - a) * t;
   1.628  }
   1.629  
   1.630 -inline Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1,
   1.631 +VMATH_INLINE Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1,
   1.632  		const Vector3 &v2, const Vector3 &v3, scalar_t t)
   1.633  {
   1.634  	scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t);
   1.635 @@ -595,23 +595,23 @@
   1.636  
   1.637  /* ----------- Vector4 ----------------- */
   1.638  
   1.639 -inline scalar_t &Vector4::operator [](int elem) {
   1.640 +VMATH_INLINE scalar_t &Vector4::operator [](int elem) {
   1.641  	return elem ? (elem == 1 ? y : (elem == 2 ? z : w)) : x;
   1.642  }
   1.643  
   1.644 -inline const scalar_t &Vector4::operator [](int elem) const {
   1.645 +VMATH_INLINE const scalar_t &Vector4::operator [](int elem) const {
   1.646  	return elem ? (elem == 1 ? y : (elem == 2 ? z : w)) : x;
   1.647  }
   1.648  
   1.649 -inline Vector4 operator -(const Vector4 &vec) {
   1.650 +VMATH_INLINE Vector4 operator -(const Vector4 &vec) {
   1.651  	return Vector4(-vec.x, -vec.y, -vec.z, -vec.w);
   1.652  }
   1.653  
   1.654 -inline scalar_t dot_product(const Vector4 &v1, const Vector4 &v2) {
   1.655 +VMATH_INLINE scalar_t dot_product(const Vector4 &v1, const Vector4 &v2) {
   1.656  	return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
   1.657  }
   1.658  
   1.659 -inline Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3) {
   1.660 +VMATH_INLINE Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3) {
   1.661  	scalar_t a, b, c, d, e, f;       /* Intermediate Values */
   1.662      Vector4 result;
   1.663  
   1.664 @@ -631,51 +631,51 @@
   1.665      return result;
   1.666  }
   1.667  
   1.668 -inline Vector4 operator +(const Vector4 &v1, const Vector4 &v2) {
   1.669 +VMATH_INLINE Vector4 operator +(const Vector4 &v1, const Vector4 &v2) {
   1.670  	return Vector4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
   1.671  }
   1.672  
   1.673 -inline Vector4 operator -(const Vector4 &v1, const Vector4 &v2) {
   1.674 +VMATH_INLINE Vector4 operator -(const Vector4 &v1, const Vector4 &v2) {
   1.675  	return Vector4(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w);
   1.676  }
   1.677  
   1.678 -inline Vector4 operator *(const Vector4 &v1, const Vector4 &v2) {
   1.679 +VMATH_INLINE Vector4 operator *(const Vector4 &v1, const Vector4 &v2) {
   1.680  	return Vector4(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w);
   1.681  }
   1.682  
   1.683 -inline Vector4 operator /(const Vector4 &v1, const Vector4 &v2) {
   1.684 +VMATH_INLINE Vector4 operator /(const Vector4 &v1, const Vector4 &v2) {
   1.685  	return Vector4(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w);
   1.686  }
   1.687  
   1.688 -inline bool operator ==(const Vector4 &v1, const Vector4 &v2) {
   1.689 +VMATH_INLINE bool operator ==(const Vector4 &v1, const Vector4 &v2) {
   1.690  	return	(fabs(v1.x - v2.x) < XSMALL_NUMBER) &&
   1.691  			(fabs(v1.y - v2.y) < XSMALL_NUMBER) &&
   1.692  			(fabs(v1.z - v2.z) < XSMALL_NUMBER) &&
   1.693  			(fabs(v1.w - v2.w) < XSMALL_NUMBER);
   1.694  }
   1.695  
   1.696 -inline void operator +=(Vector4 &v1, const Vector4 &v2) {
   1.697 +VMATH_INLINE void operator +=(Vector4 &v1, const Vector4 &v2) {
   1.698  	v1.x += v2.x;
   1.699  	v1.y += v2.y;
   1.700  	v1.z += v2.z;
   1.701  	v1.w += v2.w;
   1.702  }
   1.703  
   1.704 -inline void operator -=(Vector4 &v1, const Vector4 &v2) {
   1.705 +VMATH_INLINE void operator -=(Vector4 &v1, const Vector4 &v2) {
   1.706  	v1.x -= v2.x;
   1.707  	v1.y -= v2.y;
   1.708  	v1.z -= v2.z;
   1.709  	v1.w -= v2.w;
   1.710  }
   1.711  
   1.712 -inline void operator *=(Vector4 &v1, const Vector4 &v2) {
   1.713 +VMATH_INLINE void operator *=(Vector4 &v1, const Vector4 &v2) {
   1.714  	v1.x *= v2.x;
   1.715  	v1.y *= v2.y;
   1.716  	v1.z *= v2.z;
   1.717  	v1.w *= v2.w;
   1.718  }
   1.719  
   1.720 -inline void operator /=(Vector4 &v1, const Vector4 &v2) {
   1.721 +VMATH_INLINE void operator /=(Vector4 &v1, const Vector4 &v2) {
   1.722  	v1.x /= v2.x;
   1.723  	v1.y /= v2.y;
   1.724  	v1.z /= v2.z;
   1.725 @@ -683,71 +683,71 @@
   1.726  }
   1.727  
   1.728  /* binary vector (op) scalar and scalar (op) vector operations */
   1.729 -inline Vector4 operator +(const Vector4 &vec, scalar_t scalar) {
   1.730 +VMATH_INLINE Vector4 operator +(const Vector4 &vec, scalar_t scalar) {
   1.731  	return Vector4(vec.x + scalar, vec.y + scalar, vec.z + scalar, vec.w + scalar);
   1.732  }
   1.733  
   1.734 -inline Vector4 operator +(scalar_t scalar, const Vector4 &vec) {
   1.735 +VMATH_INLINE Vector4 operator +(scalar_t scalar, const Vector4 &vec) {
   1.736  	return Vector4(vec.x + scalar, vec.y + scalar, vec.z + scalar, vec.w + scalar);
   1.737  }
   1.738  
   1.739 -inline Vector4 operator -(const Vector4 &vec, scalar_t scalar) {
   1.740 +VMATH_INLINE Vector4 operator -(const Vector4 &vec, scalar_t scalar) {
   1.741  	return Vector4(vec.x - scalar, vec.y - scalar, vec.z - scalar, vec.w - scalar);
   1.742  }
   1.743  
   1.744 -inline Vector4 operator *(const Vector4 &vec, scalar_t scalar) {
   1.745 +VMATH_INLINE Vector4 operator *(const Vector4 &vec, scalar_t scalar) {
   1.746  	return Vector4(vec.x * scalar, vec.y * scalar, vec.z * scalar, vec.w * scalar);
   1.747  }
   1.748  
   1.749 -inline Vector4 operator *(scalar_t scalar, const Vector4 &vec) {
   1.750 +VMATH_INLINE Vector4 operator *(scalar_t scalar, const Vector4 &vec) {
   1.751  	return Vector4(vec.x * scalar, vec.y * scalar, vec.z * scalar, vec.w * scalar);
   1.752  }
   1.753  
   1.754 -inline Vector4 operator /(const Vector4 &vec, scalar_t scalar) {
   1.755 +VMATH_INLINE Vector4 operator /(const Vector4 &vec, scalar_t scalar) {
   1.756  	return Vector4(vec.x / scalar, vec.y / scalar, vec.z / scalar, vec.w / scalar);
   1.757  }
   1.758  
   1.759 -inline void operator +=(Vector4 &vec, scalar_t scalar) {
   1.760 +VMATH_INLINE void operator +=(Vector4 &vec, scalar_t scalar) {
   1.761  	vec.x += scalar;
   1.762  	vec.y += scalar;
   1.763  	vec.z += scalar;
   1.764  	vec.w += scalar;
   1.765  }
   1.766  
   1.767 -inline void operator -=(Vector4 &vec, scalar_t scalar) {
   1.768 +VMATH_INLINE void operator -=(Vector4 &vec, scalar_t scalar) {
   1.769  	vec.x -= scalar;
   1.770  	vec.y -= scalar;
   1.771  	vec.z -= scalar;
   1.772  	vec.w -= scalar;
   1.773  }
   1.774  
   1.775 -inline void operator *=(Vector4 &vec, scalar_t scalar) {
   1.776 +VMATH_INLINE void operator *=(Vector4 &vec, scalar_t scalar) {
   1.777  	vec.x *= scalar;
   1.778  	vec.y *= scalar;
   1.779  	vec.z *= scalar;
   1.780  	vec.w *= scalar;
   1.781  }
   1.782  
   1.783 -inline void operator /=(Vector4 &vec, scalar_t scalar) {
   1.784 +VMATH_INLINE void operator /=(Vector4 &vec, scalar_t scalar) {
   1.785  	vec.x /= scalar;
   1.786  	vec.y /= scalar;
   1.787  	vec.z /= scalar;
   1.788  	vec.w /= scalar;
   1.789  }
   1.790  
   1.791 -inline scalar_t Vector4::length() const {
   1.792 +VMATH_INLINE scalar_t Vector4::length() const {
   1.793  	return sqrt(x*x + y*y + z*z + w*w);
   1.794  }
   1.795 -inline scalar_t Vector4::length_sq() const {
   1.796 +VMATH_INLINE scalar_t Vector4::length_sq() const {
   1.797  	return x*x + y*y + z*z + w*w;
   1.798  }
   1.799  
   1.800 -inline Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t)
   1.801 +VMATH_INLINE Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t)
   1.802  {
   1.803  	return v0 + (v1 - v0) * t;
   1.804  }
   1.805  
   1.806 -inline Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1,
   1.807 +VMATH_INLINE Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1,
   1.808  		const Vector4 &v2, const Vector4 &v3, scalar_t t)
   1.809  {
   1.810  	scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t);