goat3d
changeset 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 | 3d669155709d |
files | exporters/maxgoat/src/maxgoat.cc libs/vmath/matrix.h libs/vmath/matrix.inl libs/vmath/quat.h libs/vmath/quat.inl libs/vmath/ray.h libs/vmath/ray.inl libs/vmath/vector.h libs/vmath/vector.inl libs/vmath/vmath.h libs/vmath/vmath.inl libs/vmath/vmath_config.h |
diffstat | 12 files changed, 325 insertions(+), 323 deletions(-) [+] |
line diff
1.1 --- a/exporters/maxgoat/src/maxgoat.cc Sun Sep 29 08:20:19 2013 +0300 1.2 +++ b/exporters/maxgoat/src/maxgoat.cc Sun Sep 29 08:46:19 2013 +0300 1.3 @@ -36,8 +36,8 @@ 1.4 1.5 class GoatExporter : public SceneExport { 1.6 private: 1.7 - //std::map<IGameMaterial*, goat3d_material*> mtlmap; 1.8 - //std::map<IGameNode*, goat3d_node*> nodemap; 1.9 + std::map<IGameMaterial*, goat3d_material*> mtlmap; 1.10 + std::map<IGameNode*, goat3d_node*> nodemap; 1.11 1.12 public: 1.13 IGameScene *igame; 1.14 @@ -118,8 +118,8 @@ 1.15 int GoatExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 1.16 BOOL non_interactive, DWORD opt) 1.17 { 1.18 - //mtlmap.clear(); 1.19 - //nodemap.clear(); 1.20 + mtlmap.clear(); 1.21 + nodemap.clear(); 1.22 1.23 char fname[512]; 1.24 wcstombs(fname, name, sizeof fname - 1); 1.25 @@ -243,7 +243,7 @@ 1.26 } 1.27 1.28 goat3d_add_mtl(goat, mtl); 1.29 - //mtlmap[maxmtl] = mtl; 1.30 + mtlmap[maxmtl] = mtl; 1.31 } 1.32 } 1.33 } 1.34 @@ -280,7 +280,7 @@ 1.35 1.36 // get the node material and assign it to the mesh 1.37 IGameMaterial *maxmtl = maxnode->GetNodeMaterial(); 1.38 - goat3d_material *mtl = 0;//mtlmap[maxmtl]; 1.39 + goat3d_material *mtl = mtlmap[maxmtl]; 1.40 if(mtl) { 1.41 goat3d_set_mesh_mtl(mesh, mtl); 1.42 } 1.43 @@ -328,11 +328,11 @@ 1.44 maxobj->InitializeData(); 1.45 1.46 int num_verts = maxmesh->GetNumberOfVerts(); 1.47 - assert(maxmesh->GetNumberOfTexVerts() == num_verts); 1.48 + //assert(maxmesh->GetNumberOfTexVerts() == num_verts); 1.49 1.50 float *vertices = new float[num_verts * 3]; 1.51 float *normals = new float[num_verts * 3]; 1.52 - float *texcoords = new float[num_verts * 2]; 1.53 + //float *texcoords = new float[num_verts * 2]; 1.54 1.55 for(int i=0; i<num_verts; i++) { 1.56 Point3 v = maxmesh->GetVertex(i, true); 1.57 @@ -350,20 +350,20 @@ 1.58 normals[vidx * 3 + 2] = norm.z; 1.59 } 1.60 1.61 - for(int i=0; i<maxmesh->GetNumberOfTexVerts(); i++) { 1.62 + /*for(int i=0; i<maxmesh->GetNumberOfTexVerts(); i++) { 1.63 Point3 tex = maxmesh->GetTexVertex(i); 1.64 1.65 texcoords[i * 2] = tex.x; 1.66 texcoords[i * 2 + 1] = tex.y; 1.67 - } 1.68 + }*/ 1.69 1.70 goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX, vertices, num_verts); 1.71 goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL, normals, num_verts); 1.72 - goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD, texcoords, num_verts); 1.73 + //goat3d_set_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD, texcoords, num_verts); 1.74 1.75 delete [] vertices; 1.76 delete [] normals; 1.77 - delete [] texcoords; 1.78 + //delete [] texcoords; 1.79 } 1.80 1.81 void GoatExporter::process_light(goat3d *goat, goat3d_light *light, IGameObject *maxobj)
2.1 --- a/libs/vmath/matrix.h Sun Sep 29 08:20:19 2013 +0300 2.2 +++ b/libs/vmath/matrix.h Sun Sep 29 08:46:19 2013 +0300 2.3 @@ -27,27 +27,27 @@ 2.4 #endif /* __cplusplus */ 2.5 2.6 /* C matrix 3x3 functions */ 2.7 -static inline void m3_identity(mat3_t m); 2.8 -static inline void m3_cons(mat3_t m, 2.9 +static VMATH_INLINE void m3_identity(mat3_t m); 2.10 +static VMATH_INLINE void m3_cons(mat3_t m, 2.11 scalar_t m11, scalar_t m12, scalar_t m13, 2.12 scalar_t m21, scalar_t m22, scalar_t m23, 2.13 scalar_t m31, scalar_t m32, scalar_t m33); 2.14 -static inline void m3_copy(mat3_t dest, mat3_t src); 2.15 +static VMATH_INLINE void m3_copy(mat3_t dest, mat3_t src); 2.16 void m3_to_m4(mat4_t dest, mat3_t src); 2.17 2.18 void m3_print(FILE *fp, mat3_t m); 2.19 2.20 /* C matrix 4x4 functions */ 2.21 -static inline void m4_identity(mat4_t m); 2.22 -static inline void m4_cons(mat4_t m, 2.23 +static VMATH_INLINE void m4_identity(mat4_t m); 2.24 +static VMATH_INLINE void m4_cons(mat4_t m, 2.25 scalar_t m11, scalar_t m12, scalar_t m13, scalar_t m14, 2.26 scalar_t m21, scalar_t m22, scalar_t m23, scalar_t m24, 2.27 scalar_t m31, scalar_t m32, scalar_t m33, scalar_t m34, 2.28 scalar_t m41, scalar_t m42, scalar_t m43, scalar_t m44); 2.29 -static inline void m4_copy(mat4_t dest, mat4_t src); 2.30 +static VMATH_INLINE void m4_copy(mat4_t dest, mat4_t src); 2.31 void m4_to_m3(mat3_t dest, mat4_t src); 2.32 2.33 -static inline void m4_mult(mat4_t res, mat4_t m1, mat4_t m2); 2.34 +static VMATH_INLINE void m4_mult(mat4_t res, mat4_t m1, mat4_t m2); 2.35 2.36 void m4_set_translation(mat4_t m, scalar_t x, scalar_t y, scalar_t z); 2.37 void m4_translate(mat4_t m, scalar_t x, scalar_t y, scalar_t z); 2.38 @@ -69,8 +69,8 @@ 2.39 void m4_set_scaling(mat4_t m, scalar_t x, scalar_t y, scalar_t z); 2.40 void m4_scale(mat4_t m, scalar_t x, scalar_t y, scalar_t z); 2.41 2.42 -static inline void m4_set_column(mat4_t m, vec4_t v, int idx); 2.43 -static inline void m4_set_row(mat4_t m, vec4_t v, int idx); 2.44 +static VMATH_INLINE void m4_set_column(mat4_t m, vec4_t v, int idx); 2.45 +static VMATH_INLINE void m4_set_row(mat4_t m, vec4_t v, int idx); 2.46 2.47 void m4_transpose(mat4_t res, mat4_t m); 2.48 scalar_t m4_determinant(mat4_t m); 2.49 @@ -116,10 +116,10 @@ 2.50 2.51 friend void operator *=(Matrix3x3 &mat, scalar_t scalar); 2.52 2.53 - inline scalar_t *operator [](int index); 2.54 - inline const scalar_t *operator [](int index) const; 2.55 + VMATH_INLINE scalar_t *operator [](int index); 2.56 + VMATH_INLINE const scalar_t *operator [](int index) const; 2.57 2.58 - inline void reset_identity(); 2.59 + VMATH_INLINE void reset_identity(); 2.60 2.61 void translate(const Vector2 &trans); 2.62 void set_translation(const Vector2 &trans); 2.63 @@ -190,7 +190,7 @@ 2.64 2.65 friend void operator +=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.66 friend void operator -=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.67 - friend inline void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.68 + friend VMATH_INLINE void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.69 2.70 /* binary operations matrix (op) scalar and scalar (op) matrix */ 2.71 friend Matrix4x4 operator *(const Matrix4x4 &mat, scalar_t scalar); 2.72 @@ -198,10 +198,10 @@ 2.73 2.74 friend void operator *=(Matrix4x4 &mat, scalar_t scalar); 2.75 2.76 - inline scalar_t *operator [](int index); 2.77 - inline const scalar_t *operator [](int index) const; 2.78 + VMATH_INLINE scalar_t *operator [](int index); 2.79 + VMATH_INLINE const scalar_t *operator [](int index) const; 2.80 2.81 - inline void reset_identity(); 2.82 + VMATH_INLINE void reset_identity(); 2.83 2.84 void translate(const Vector3 &trans); 2.85 void set_translation(const Vector3 &trans); 2.86 @@ -239,11 +239,11 @@ 2.87 /* binary operations matrix (op) matrix */ 2.88 Matrix4x4 operator +(const Matrix4x4 &m1, const Matrix4x4 &m2); 2.89 Matrix4x4 operator -(const Matrix4x4 &m1, const Matrix4x4 &m2); 2.90 -inline Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2); 2.91 +VMATH_INLINE Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2); 2.92 2.93 void operator +=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.94 void operator -=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.95 -inline void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.96 +VMATH_INLINE void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2); 2.97 2.98 /* binary operations matrix (op) scalar and scalar (op) matrix */ 2.99 Matrix4x4 operator *(const Matrix4x4 &mat, scalar_t scalar);
3.1 --- a/libs/vmath/matrix.inl Sun Sep 29 08:20:19 2013 +0300 3.2 +++ b/libs/vmath/matrix.inl Sun Sep 29 08:46:19 2013 +0300 3.3 @@ -23,13 +23,13 @@ 3.4 #endif /* __cplusplus */ 3.5 3.6 /* C matrix 3x3 functions */ 3.7 -static inline void m3_identity(mat3_t m) 3.8 +static VMATH_INLINE void m3_identity(mat3_t m) 3.9 { 3.10 static const mat3_t id = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; 3.11 memcpy(m, id, sizeof id); 3.12 } 3.13 3.14 -static inline void m3_cons(mat3_t m, 3.15 +static VMATH_INLINE void m3_cons(mat3_t m, 3.16 scalar_t m11, scalar_t m12, scalar_t m13, 3.17 scalar_t m21, scalar_t m22, scalar_t m23, 3.18 scalar_t m31, scalar_t m32, scalar_t m33) 3.19 @@ -39,20 +39,20 @@ 3.20 m[2][0] = m31; m[2][1] = m32; m[2][2] = m33; 3.21 } 3.22 3.23 -static inline void m3_copy(mat3_t dest, mat3_t src) 3.24 +static VMATH_INLINE void m3_copy(mat3_t dest, mat3_t src) 3.25 { 3.26 memcpy(dest, src, sizeof(mat3_t)); 3.27 } 3.28 3.29 3.30 /* C matrix 4x4 functions */ 3.31 -static inline void m4_identity(mat4_t m) 3.32 +static VMATH_INLINE void m4_identity(mat4_t m) 3.33 { 3.34 static const mat4_t id = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}; 3.35 memcpy(m, id, sizeof id); 3.36 } 3.37 3.38 -static inline void m4_cons(mat4_t m, 3.39 +static VMATH_INLINE void m4_cons(mat4_t m, 3.40 scalar_t m11, scalar_t m12, scalar_t m13, scalar_t m14, 3.41 scalar_t m21, scalar_t m22, scalar_t m23, scalar_t m24, 3.42 scalar_t m31, scalar_t m32, scalar_t m33, scalar_t m34, 3.43 @@ -64,12 +64,12 @@ 3.44 m[3][0] = m41; m[3][1] = m42; m[3][2] = m43; m[3][3] = m44; 3.45 } 3.46 3.47 -static inline void m4_copy(mat4_t dest, mat4_t src) 3.48 +static VMATH_INLINE void m4_copy(mat4_t dest, mat4_t src) 3.49 { 3.50 memcpy(dest, src, sizeof(mat4_t)); 3.51 } 3.52 3.53 -static inline void m4_mult(mat4_t res, mat4_t m1, mat4_t m2) 3.54 +static VMATH_INLINE void m4_mult(mat4_t res, mat4_t m1, mat4_t m2) 3.55 { 3.56 mat4_t tmp; 3.57 3.58 @@ -105,7 +105,7 @@ 3.59 m4_copy(res, tmp); 3.60 } 3.61 3.62 -static inline void m4_set_column(mat4_t m, vec4_t v, int idx) 3.63 +static VMATH_INLINE void m4_set_column(mat4_t m, vec4_t v, int idx) 3.64 { 3.65 m[0][idx] = v.x; 3.66 m[1][idx] = v.y; 3.67 @@ -113,7 +113,7 @@ 3.68 m[3][idx] = v.w; 3.69 } 3.70 3.71 -static inline void m4_set_row(mat4_t m, vec4_t v, int idx) 3.72 +static VMATH_INLINE void m4_set_row(mat4_t m, vec4_t v, int idx) 3.73 { 3.74 m[idx][0] = v.x; 3.75 m[idx][1] = v.y; 3.76 @@ -125,8 +125,8 @@ 3.77 } /* extern "C" */ 3.78 3.79 3.80 -/* unrolled to hell and inline */ 3.81 -inline Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2) 3.82 +/* unrolled to hell and VMATH_INLINE */ 3.83 +VMATH_INLINE Matrix4x4 operator *(const Matrix4x4 &m1, const Matrix4x4 &m2) 3.84 { 3.85 Matrix4x4 res; 3.86 3.87 @@ -161,39 +161,39 @@ 3.88 return res; 3.89 } 3.90 3.91 -inline void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2) 3.92 +VMATH_INLINE void operator *=(Matrix4x4 &m1, const Matrix4x4 &m2) 3.93 { 3.94 Matrix4x4 res = m1 * m2; 3.95 m1 = res; 3.96 } 3.97 3.98 3.99 -inline scalar_t *Matrix3x3::operator [](int index) 3.100 +VMATH_INLINE scalar_t *Matrix3x3::operator [](int index) 3.101 { 3.102 return m[index]; 3.103 } 3.104 3.105 -inline const scalar_t *Matrix3x3::operator [](int index) const 3.106 +VMATH_INLINE const scalar_t *Matrix3x3::operator [](int index) const 3.107 { 3.108 return m[index]; 3.109 } 3.110 3.111 -inline void Matrix3x3::reset_identity() 3.112 +VMATH_INLINE void Matrix3x3::reset_identity() 3.113 { 3.114 *this = identity; 3.115 } 3.116 3.117 -inline scalar_t *Matrix4x4::operator [](int index) 3.118 +VMATH_INLINE scalar_t *Matrix4x4::operator [](int index) 3.119 { 3.120 return m[index]; 3.121 } 3.122 3.123 -inline const scalar_t *Matrix4x4::operator [](int index) const 3.124 +VMATH_INLINE const scalar_t *Matrix4x4::operator [](int index) const 3.125 { 3.126 return m[index]; 3.127 } 3.128 3.129 -inline void Matrix4x4::reset_identity() 3.130 +VMATH_INLINE void Matrix4x4::reset_identity() 3.131 { 3.132 *this = identity; 3.133 }
4.1 --- a/libs/vmath/quat.h Sun Sep 29 08:20:19 2013 +0300 4.2 +++ b/libs/vmath/quat.h Sun Sep 29 08:46:19 2013 +0300 4.3 @@ -37,21 +37,21 @@ 4.4 #define quat_sub v4_sub 4.5 #define quat_neg v4_neg 4.6 4.7 -static inline quat_t quat_mul(quat_t q1, quat_t q2); 4.8 +static VMATH_INLINE quat_t quat_mul(quat_t q1, quat_t q2); 4.9 4.10 -static inline quat_t quat_conjugate(quat_t q); 4.11 +static VMATH_INLINE quat_t quat_conjugate(quat_t q); 4.12 4.13 #define quat_length v4_length 4.14 #define quat_length_sq v4_length_sq 4.15 4.16 #define quat_normalize v4_normalize 4.17 -static inline quat_t quat_inverse(quat_t q); 4.18 +static VMATH_INLINE quat_t quat_inverse(quat_t q); 4.19 4.20 quat_t quat_rotate(quat_t q, scalar_t angle, scalar_t x, scalar_t y, scalar_t z); 4.21 quat_t quat_rotate_quat(quat_t q, quat_t rotq); 4.22 4.23 -static inline void quat_to_mat3(mat3_t res, quat_t q); 4.24 -static inline void quat_to_mat4(mat4_t res, quat_t q); 4.25 +static VMATH_INLINE void quat_to_mat3(mat3_t res, quat_t q); 4.26 +static VMATH_INLINE void quat_to_mat4(mat4_t res, quat_t q); 4.27 4.28 #define quat_lerp quat_slerp 4.29 quat_t quat_slerp(quat_t q1, quat_t q2, scalar_t t); 4.30 @@ -107,7 +107,7 @@ 4.31 }; 4.32 4.33 Quaternion slerp(const Quaternion &q1, const Quaternion &q2, scalar_t t); 4.34 -inline Quaternion lerp(const Quaternion &q1, const Quaternion &q2, scalar_t t); 4.35 +VMATH_INLINE Quaternion lerp(const Quaternion &q1, const Quaternion &q2, scalar_t t); 4.36 4.37 std::ostream &operator <<(std::ostream &out, const Quaternion &q); 4.38
5.1 --- a/libs/vmath/quat.inl Sun Sep 29 08:20:19 2013 +0300 5.2 +++ b/libs/vmath/quat.inl Sun Sep 29 08:46:19 2013 +0300 5.3 @@ -23,7 +23,7 @@ 5.4 extern "C" { 5.5 #endif /* __cplusplus */ 5.6 5.7 -static inline quat_t quat_mul(quat_t q1, quat_t q2) 5.8 +static VMATH_INLINE quat_t quat_mul(quat_t q1, quat_t q2) 5.9 { 5.10 quat_t res; 5.11 vec3_t v1 = quat_vec(q1); 5.12 @@ -37,7 +37,7 @@ 5.13 return res; 5.14 } 5.15 5.16 -static inline quat_t quat_conjugate(quat_t q) 5.17 +static VMATH_INLINE quat_t quat_conjugate(quat_t q) 5.18 { 5.19 q.x = -q.x; 5.20 q.y = -q.y; 5.21 @@ -45,7 +45,7 @@ 5.22 return q; 5.23 } 5.24 5.25 -static inline quat_t quat_inverse(quat_t q) 5.26 +static VMATH_INLINE quat_t quat_inverse(quat_t q) 5.27 { 5.28 scalar_t lensq = quat_length_sq(q); 5.29 q = quat_conjugate(q); 5.30 @@ -56,14 +56,14 @@ 5.31 return q; 5.32 } 5.33 5.34 -static inline void quat_to_mat3(mat3_t res, quat_t q) 5.35 +static VMATH_INLINE void quat_to_mat3(mat3_t res, quat_t q) 5.36 { 5.37 m3_cons(res, 1.0 - 2.0 * q.y*q.y - 2.0 * q.z*q.z, 2.0 * q.x * q.y - 2.0 * q.w * q.z, 2.0 * q.z * q.x + 2.0 * q.w * q.y, 5.38 2.0 * q.x * q.y + 2.0 * q.w * q.z, 1.0 - 2.0 * q.x*q.x - 2.0 * q.z*q.z, 2.0 * q.y * q.z - 2.0 * q.w * q.x, 5.39 2.0 * q.z * q.x - 2.0 * q.w * q.y, 2.0 * q.y * q.z + 2.0 * q.w * q.x, 1.0 - 2.0 * q.x*q.x - 2.0 * q.y*q.y); 5.40 } 5.41 5.42 -static inline void quat_to_mat4(mat4_t res, quat_t q) 5.43 +static VMATH_INLINE void quat_to_mat4(mat4_t res, quat_t q) 5.44 { 5.45 m4_cons(res, 1.0 - 2.0 * q.y*q.y - 2.0 * q.z*q.z, 2.0 * q.x * q.y - 2.0 * q.w * q.z, 2.0 * q.z * q.x + 2.0 * q.w * q.y, 0, 5.46 2.0 * q.x * q.y + 2.0 * q.w * q.z, 1.0 - 2.0 * q.x*q.x - 2.0 * q.z*q.z, 2.0 * q.y * q.z - 2.0 * q.w * q.x, 0, 5.47 @@ -74,7 +74,7 @@ 5.48 #ifdef __cplusplus 5.49 } /* extern "C" */ 5.50 5.51 -inline Quaternion lerp(const Quaternion &a, const Quaternion &b, scalar_t t) 5.52 +VMATH_INLINE Quaternion lerp(const Quaternion &a, const Quaternion &b, scalar_t t) 5.53 { 5.54 return slerp(a, b, t); 5.55 }
6.1 --- a/libs/vmath/ray.h Sun Sep 29 08:20:19 2013 +0300 6.2 +++ b/libs/vmath/ray.h Sun Sep 29 08:46:19 2013 +0300 6.3 @@ -30,7 +30,7 @@ 6.4 extern "C" { 6.5 #endif /* __cplusplus */ 6.6 6.7 -static inline ray_t ray_cons(vec3_t origin, vec3_t dir); 6.8 +static VMATH_INLINE ray_t ray_cons(vec3_t origin, vec3_t dir); 6.9 ray_t ray_transform(ray_t r, mat4_t m); 6.10 6.11 #ifdef __cplusplus 6.12 @@ -55,8 +55,8 @@ 6.13 Ray transformed(const Matrix4x4 &xform) const; 6.14 }; 6.15 6.16 -inline Ray reflect_ray(const Ray &inray, const Vector3 &norm); 6.17 -inline Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t from_ior, scalar_t to_ior); 6.18 +VMATH_INLINE Ray reflect_ray(const Ray &inray, const Vector3 &norm); 6.19 +VMATH_INLINE Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t from_ior, scalar_t to_ior); 6.20 #endif /* __cplusplus */ 6.21 6.22 #include "ray.inl"
7.1 --- a/libs/vmath/ray.inl Sun Sep 29 08:20:19 2013 +0300 7.2 +++ b/libs/vmath/ray.inl Sun Sep 29 08:46:19 2013 +0300 7.3 @@ -20,7 +20,7 @@ 7.4 extern "C" { 7.5 #endif /* __cplusplus */ 7.6 7.7 -static inline ray_t ray_cons(vec3_t origin, vec3_t dir) 7.8 +static VMATH_INLINE ray_t ray_cons(vec3_t origin, vec3_t dir) 7.9 { 7.10 ray_t r; 7.11 r.origin = origin; 7.12 @@ -31,14 +31,14 @@ 7.13 #ifdef __cplusplus 7.14 } 7.15 7.16 -inline Ray reflect_ray(const Ray &inray, const Vector3 &norm) 7.17 +VMATH_INLINE Ray reflect_ray(const Ray &inray, const Vector3 &norm) 7.18 { 7.19 Ray ray = inray; 7.20 ray.dir = ray.dir.reflection(norm); 7.21 return ray; 7.22 } 7.23 7.24 -inline Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t from_ior, scalar_t to_ior) 7.25 +VMATH_INLINE Ray refract_ray(const Ray &inray, const Vector3 &norm, scalar_t from_ior, scalar_t to_ior) 7.26 { 7.27 Ray ray = inray; 7.28 ray.dir = ray.dir.refraction(norm, from_ior, to_ior);
8.1 --- a/libs/vmath/vector.h Sun Sep 29 08:20:19 2013 +0300 8.2 +++ b/libs/vmath/vector.h Sun Sep 29 08:46:19 2013 +0300 8.3 @@ -27,57 +27,57 @@ 8.4 #endif /* __cplusplus */ 8.5 8.6 /* C 2D vector functions */ 8.7 -static inline vec2_t v2_cons(scalar_t x, scalar_t y); 8.8 -static inline void v2_print(FILE *fp, vec2_t v); 8.9 +static VMATH_INLINE vec2_t v2_cons(scalar_t x, scalar_t y); 8.10 +static VMATH_INLINE void v2_print(FILE *fp, vec2_t v); 8.11 8.12 -static inline vec2_t v2_add(vec2_t v1, vec2_t v2); 8.13 -static inline vec2_t v2_sub(vec2_t v1, vec2_t v2); 8.14 -static inline vec2_t v2_scale(vec2_t v, scalar_t s); 8.15 -static inline scalar_t v2_dot(vec2_t v1, vec2_t v2); 8.16 -static inline scalar_t v2_length(vec2_t v); 8.17 -static inline scalar_t v2_length_sq(vec2_t v); 8.18 -static inline vec2_t v2_normalize(vec2_t v); 8.19 +static VMATH_INLINE vec2_t v2_add(vec2_t v1, vec2_t v2); 8.20 +static VMATH_INLINE vec2_t v2_sub(vec2_t v1, vec2_t v2); 8.21 +static VMATH_INLINE vec2_t v2_scale(vec2_t v, scalar_t s); 8.22 +static VMATH_INLINE scalar_t v2_dot(vec2_t v1, vec2_t v2); 8.23 +static VMATH_INLINE scalar_t v2_length(vec2_t v); 8.24 +static VMATH_INLINE scalar_t v2_length_sq(vec2_t v); 8.25 +static VMATH_INLINE vec2_t v2_normalize(vec2_t v); 8.26 8.27 -static inline vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t); 8.28 +static VMATH_INLINE vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t); 8.29 8.30 /* C 3D vector functions */ 8.31 -static inline vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z); 8.32 -static inline void v3_print(FILE *fp, vec3_t v); 8.33 +static VMATH_INLINE vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z); 8.34 +static VMATH_INLINE void v3_print(FILE *fp, vec3_t v); 8.35 8.36 -static inline vec3_t v3_add(vec3_t v1, vec3_t v2); 8.37 -static inline vec3_t v3_sub(vec3_t v1, vec3_t v2); 8.38 -static inline vec3_t v3_neg(vec3_t v); 8.39 -static inline vec3_t v3_mul(vec3_t v1, vec3_t v2); 8.40 -static inline vec3_t v3_scale(vec3_t v1, scalar_t s); 8.41 -static inline scalar_t v3_dot(vec3_t v1, vec3_t v2); 8.42 -static inline vec3_t v3_cross(vec3_t v1, vec3_t v2); 8.43 -static inline scalar_t v3_length(vec3_t v); 8.44 -static inline scalar_t v3_length_sq(vec3_t v); 8.45 -static inline vec3_t v3_normalize(vec3_t v); 8.46 -static inline vec3_t v3_transform(vec3_t v, mat4_t m); 8.47 +static VMATH_INLINE vec3_t v3_add(vec3_t v1, vec3_t v2); 8.48 +static VMATH_INLINE vec3_t v3_sub(vec3_t v1, vec3_t v2); 8.49 +static VMATH_INLINE vec3_t v3_neg(vec3_t v); 8.50 +static VMATH_INLINE vec3_t v3_mul(vec3_t v1, vec3_t v2); 8.51 +static VMATH_INLINE vec3_t v3_scale(vec3_t v1, scalar_t s); 8.52 +static VMATH_INLINE scalar_t v3_dot(vec3_t v1, vec3_t v2); 8.53 +static VMATH_INLINE vec3_t v3_cross(vec3_t v1, vec3_t v2); 8.54 +static VMATH_INLINE scalar_t v3_length(vec3_t v); 8.55 +static VMATH_INLINE scalar_t v3_length_sq(vec3_t v); 8.56 +static VMATH_INLINE vec3_t v3_normalize(vec3_t v); 8.57 +static VMATH_INLINE vec3_t v3_transform(vec3_t v, mat4_t m); 8.58 8.59 -static inline vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z); 8.60 -static inline vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z); 8.61 -static inline vec3_t v3_rotate_quat(vec3_t v, quat_t q); 8.62 +static VMATH_INLINE vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z); 8.63 +static VMATH_INLINE vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z); 8.64 +static VMATH_INLINE vec3_t v3_rotate_quat(vec3_t v, quat_t q); 8.65 8.66 -static inline vec3_t v3_reflect(vec3_t v, vec3_t n); 8.67 +static VMATH_INLINE vec3_t v3_reflect(vec3_t v, vec3_t n); 8.68 8.69 -static inline vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t); 8.70 +static VMATH_INLINE vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t); 8.71 8.72 /* C 4D vector functions */ 8.73 -static inline vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w); 8.74 -static inline void v4_print(FILE *fp, vec4_t v); 8.75 +static VMATH_INLINE vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w); 8.76 +static VMATH_INLINE void v4_print(FILE *fp, vec4_t v); 8.77 8.78 -static inline vec4_t v4_add(vec4_t v1, vec4_t v2); 8.79 -static inline vec4_t v4_sub(vec4_t v1, vec4_t v2); 8.80 -static inline vec4_t v4_neg(vec4_t v); 8.81 -static inline vec4_t v4_mul(vec4_t v1, vec4_t v2); 8.82 -static inline vec4_t v4_scale(vec4_t v, scalar_t s); 8.83 -static inline scalar_t v4_dot(vec4_t v1, vec4_t v2); 8.84 -static inline scalar_t v4_length(vec4_t v); 8.85 -static inline scalar_t v4_length_sq(vec4_t v); 8.86 -static inline vec4_t v4_normalize(vec4_t v); 8.87 -static inline vec4_t v4_transform(vec4_t v, mat4_t m); 8.88 +static VMATH_INLINE vec4_t v4_add(vec4_t v1, vec4_t v2); 8.89 +static VMATH_INLINE vec4_t v4_sub(vec4_t v1, vec4_t v2); 8.90 +static VMATH_INLINE vec4_t v4_neg(vec4_t v); 8.91 +static VMATH_INLINE vec4_t v4_mul(vec4_t v1, vec4_t v2); 8.92 +static VMATH_INLINE vec4_t v4_scale(vec4_t v, scalar_t s); 8.93 +static VMATH_INLINE scalar_t v4_dot(vec4_t v1, vec4_t v2); 8.94 +static VMATH_INLINE scalar_t v4_length(vec4_t v); 8.95 +static VMATH_INLINE scalar_t v4_length_sq(vec4_t v); 8.96 +static VMATH_INLINE vec4_t v4_normalize(vec4_t v); 8.97 +static VMATH_INLINE vec4_t v4_transform(vec4_t v, mat4_t m); 8.98 8.99 #ifdef __cplusplus 8.100 } /* extern "C" */ 8.101 @@ -95,11 +95,11 @@ 8.102 Vector2(const Vector3 &vec); 8.103 Vector2(const Vector4 &vec); 8.104 8.105 - inline scalar_t &operator [](int elem); 8.106 - inline const scalar_t &operator [](int elem) const; 8.107 + VMATH_INLINE scalar_t &operator [](int elem); 8.108 + VMATH_INLINE const scalar_t &operator [](int elem) const; 8.109 8.110 - inline scalar_t length() const; 8.111 - inline scalar_t length_sq() const; 8.112 + VMATH_INLINE scalar_t length() const; 8.113 + VMATH_INLINE scalar_t length_sq() const; 8.114 void normalize(); 8.115 Vector2 normalized() const; 8.116 8.117 @@ -114,39 +114,39 @@ 8.118 }; 8.119 8.120 /* unary operations */ 8.121 -inline Vector2 operator -(const Vector2 &vec); 8.122 +VMATH_INLINE Vector2 operator -(const Vector2 &vec); 8.123 8.124 /* binary vector (op) vector operations */ 8.125 -inline scalar_t dot_product(const Vector2 &v1, const Vector2 &v2); 8.126 +VMATH_INLINE scalar_t dot_product(const Vector2 &v1, const Vector2 &v2); 8.127 8.128 -inline Vector2 operator +(const Vector2 &v1, const Vector2 &v2); 8.129 -inline Vector2 operator -(const Vector2 &v1, const Vector2 &v2); 8.130 -inline Vector2 operator *(const Vector2 &v1, const Vector2 &v2); 8.131 -inline Vector2 operator /(const Vector2 &v1, const Vector2 &v2); 8.132 -inline bool operator ==(const Vector2 &v1, const Vector2 &v2); 8.133 +VMATH_INLINE Vector2 operator +(const Vector2 &v1, const Vector2 &v2); 8.134 +VMATH_INLINE Vector2 operator -(const Vector2 &v1, const Vector2 &v2); 8.135 +VMATH_INLINE Vector2 operator *(const Vector2 &v1, const Vector2 &v2); 8.136 +VMATH_INLINE Vector2 operator /(const Vector2 &v1, const Vector2 &v2); 8.137 +VMATH_INLINE bool operator ==(const Vector2 &v1, const Vector2 &v2); 8.138 8.139 -inline void operator +=(Vector2 &v1, const Vector2 &v2); 8.140 -inline void operator -=(Vector2 &v1, const Vector2 &v2); 8.141 -inline void operator *=(Vector2 &v1, const Vector2 &v2); 8.142 -inline void operator /=(Vector2 &v1, const Vector2 &v2); 8.143 +VMATH_INLINE void operator +=(Vector2 &v1, const Vector2 &v2); 8.144 +VMATH_INLINE void operator -=(Vector2 &v1, const Vector2 &v2); 8.145 +VMATH_INLINE void operator *=(Vector2 &v1, const Vector2 &v2); 8.146 +VMATH_INLINE void operator /=(Vector2 &v1, const Vector2 &v2); 8.147 8.148 /* binary vector (op) scalar and scalar (op) vector operations */ 8.149 -inline Vector2 operator +(const Vector2 &vec, scalar_t scalar); 8.150 -inline Vector2 operator +(scalar_t scalar, const Vector2 &vec); 8.151 -inline Vector2 operator -(const Vector2 &vec, scalar_t scalar); 8.152 -inline Vector2 operator *(const Vector2 &vec, scalar_t scalar); 8.153 -inline Vector2 operator *(scalar_t scalar, const Vector2 &vec); 8.154 -inline Vector2 operator /(const Vector2 &vec, scalar_t scalar); 8.155 +VMATH_INLINE Vector2 operator +(const Vector2 &vec, scalar_t scalar); 8.156 +VMATH_INLINE Vector2 operator +(scalar_t scalar, const Vector2 &vec); 8.157 +VMATH_INLINE Vector2 operator -(const Vector2 &vec, scalar_t scalar); 8.158 +VMATH_INLINE Vector2 operator *(const Vector2 &vec, scalar_t scalar); 8.159 +VMATH_INLINE Vector2 operator *(scalar_t scalar, const Vector2 &vec); 8.160 +VMATH_INLINE Vector2 operator /(const Vector2 &vec, scalar_t scalar); 8.161 8.162 -inline void operator +=(Vector2 &vec, scalar_t scalar); 8.163 -inline void operator -=(Vector2 &vec, scalar_t scalar); 8.164 -inline void operator *=(Vector2 &vec, scalar_t scalar); 8.165 -inline void operator /=(Vector2 &vec, scalar_t scalar); 8.166 +VMATH_INLINE void operator +=(Vector2 &vec, scalar_t scalar); 8.167 +VMATH_INLINE void operator -=(Vector2 &vec, scalar_t scalar); 8.168 +VMATH_INLINE void operator *=(Vector2 &vec, scalar_t scalar); 8.169 +VMATH_INLINE void operator /=(Vector2 &vec, scalar_t scalar); 8.170 8.171 std::ostream &operator <<(std::ostream &out, const Vector2 &vec); 8.172 8.173 -inline Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t); 8.174 -inline Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1, 8.175 +VMATH_INLINE Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t); 8.176 +VMATH_INLINE Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1, 8.177 const Vector2 &v2, const Vector2 &v3, scalar_t t); 8.178 8.179 /* 3D Vector */ 8.180 @@ -162,11 +162,11 @@ 8.181 8.182 Vector3 &operator =(const SphVector &sph); 8.183 8.184 - inline scalar_t &operator [](int elem); 8.185 - inline const scalar_t &operator [](int elem) const; 8.186 + VMATH_INLINE scalar_t &operator [](int elem); 8.187 + VMATH_INLINE const scalar_t &operator [](int elem) const; 8.188 8.189 - inline scalar_t length() const; 8.190 - inline scalar_t length_sq() const; 8.191 + VMATH_INLINE scalar_t length() const; 8.192 + VMATH_INLINE scalar_t length_sq() const; 8.193 void normalize(); 8.194 Vector3 normalized() const; 8.195 8.196 @@ -186,40 +186,40 @@ 8.197 }; 8.198 8.199 /* unary operations */ 8.200 -inline Vector3 operator -(const Vector3 &vec); 8.201 +VMATH_INLINE Vector3 operator -(const Vector3 &vec); 8.202 8.203 /* binary vector (op) vector operations */ 8.204 -inline scalar_t dot_product(const Vector3 &v1, const Vector3 &v2); 8.205 -inline Vector3 cross_product(const Vector3 &v1, const Vector3 &v2); 8.206 +VMATH_INLINE scalar_t dot_product(const Vector3 &v1, const Vector3 &v2); 8.207 +VMATH_INLINE Vector3 cross_product(const Vector3 &v1, const Vector3 &v2); 8.208 8.209 -inline Vector3 operator +(const Vector3 &v1, const Vector3 &v2); 8.210 -inline Vector3 operator -(const Vector3 &v1, const Vector3 &v2); 8.211 -inline Vector3 operator *(const Vector3 &v1, const Vector3 &v2); 8.212 -inline Vector3 operator /(const Vector3 &v1, const Vector3 &v2); 8.213 -inline bool operator ==(const Vector3 &v1, const Vector3 &v2); 8.214 +VMATH_INLINE Vector3 operator +(const Vector3 &v1, const Vector3 &v2); 8.215 +VMATH_INLINE Vector3 operator -(const Vector3 &v1, const Vector3 &v2); 8.216 +VMATH_INLINE Vector3 operator *(const Vector3 &v1, const Vector3 &v2); 8.217 +VMATH_INLINE Vector3 operator /(const Vector3 &v1, const Vector3 &v2); 8.218 +VMATH_INLINE bool operator ==(const Vector3 &v1, const Vector3 &v2); 8.219 8.220 -inline void operator +=(Vector3 &v1, const Vector3 &v2); 8.221 -inline void operator -=(Vector3 &v1, const Vector3 &v2); 8.222 -inline void operator *=(Vector3 &v1, const Vector3 &v2); 8.223 -inline void operator /=(Vector3 &v1, const Vector3 &v2); 8.224 +VMATH_INLINE void operator +=(Vector3 &v1, const Vector3 &v2); 8.225 +VMATH_INLINE void operator -=(Vector3 &v1, const Vector3 &v2); 8.226 +VMATH_INLINE void operator *=(Vector3 &v1, const Vector3 &v2); 8.227 +VMATH_INLINE void operator /=(Vector3 &v1, const Vector3 &v2); 8.228 8.229 /* binary vector (op) scalar and scalar (op) vector operations */ 8.230 -inline Vector3 operator +(const Vector3 &vec, scalar_t scalar); 8.231 -inline Vector3 operator +(scalar_t scalar, const Vector3 &vec); 8.232 -inline Vector3 operator -(const Vector3 &vec, scalar_t scalar); 8.233 -inline Vector3 operator *(const Vector3 &vec, scalar_t scalar); 8.234 -inline Vector3 operator *(scalar_t scalar, const Vector3 &vec); 8.235 -inline Vector3 operator /(const Vector3 &vec, scalar_t scalar); 8.236 +VMATH_INLINE Vector3 operator +(const Vector3 &vec, scalar_t scalar); 8.237 +VMATH_INLINE Vector3 operator +(scalar_t scalar, const Vector3 &vec); 8.238 +VMATH_INLINE Vector3 operator -(const Vector3 &vec, scalar_t scalar); 8.239 +VMATH_INLINE Vector3 operator *(const Vector3 &vec, scalar_t scalar); 8.240 +VMATH_INLINE Vector3 operator *(scalar_t scalar, const Vector3 &vec); 8.241 +VMATH_INLINE Vector3 operator /(const Vector3 &vec, scalar_t scalar); 8.242 8.243 -inline void operator +=(Vector3 &vec, scalar_t scalar); 8.244 -inline void operator -=(Vector3 &vec, scalar_t scalar); 8.245 -inline void operator *=(Vector3 &vec, scalar_t scalar); 8.246 -inline void operator /=(Vector3 &vec, scalar_t scalar); 8.247 +VMATH_INLINE void operator +=(Vector3 &vec, scalar_t scalar); 8.248 +VMATH_INLINE void operator -=(Vector3 &vec, scalar_t scalar); 8.249 +VMATH_INLINE void operator *=(Vector3 &vec, scalar_t scalar); 8.250 +VMATH_INLINE void operator /=(Vector3 &vec, scalar_t scalar); 8.251 8.252 std::ostream &operator <<(std::ostream &out, const Vector3 &vec); 8.253 8.254 -inline Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t); 8.255 -inline Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1, 8.256 +VMATH_INLINE Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t); 8.257 +VMATH_INLINE Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1, 8.258 const Vector3 &v2, const Vector3 &v3, scalar_t t); 8.259 8.260 /* 4D Vector */ 8.261 @@ -232,11 +232,11 @@ 8.262 Vector4(const Vector2 &vec); 8.263 Vector4(const Vector3 &vec); 8.264 8.265 - inline scalar_t &operator [](int elem); 8.266 - inline const scalar_t &operator [](int elem) const; 8.267 + VMATH_INLINE scalar_t &operator [](int elem); 8.268 + VMATH_INLINE const scalar_t &operator [](int elem) const; 8.269 8.270 - inline scalar_t length() const; 8.271 - inline scalar_t length_sq() const; 8.272 + VMATH_INLINE scalar_t length() const; 8.273 + VMATH_INLINE scalar_t length_sq() const; 8.274 void normalize(); 8.275 Vector4 normalized() const; 8.276 8.277 @@ -249,40 +249,40 @@ 8.278 8.279 8.280 /* unary operations */ 8.281 -inline Vector4 operator -(const Vector4 &vec); 8.282 +VMATH_INLINE Vector4 operator -(const Vector4 &vec); 8.283 8.284 /* binary vector (op) vector operations */ 8.285 -inline scalar_t dot_product(const Vector4 &v1, const Vector4 &v2); 8.286 -inline Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3); 8.287 +VMATH_INLINE scalar_t dot_product(const Vector4 &v1, const Vector4 &v2); 8.288 +VMATH_INLINE Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3); 8.289 8.290 -inline Vector4 operator +(const Vector4 &v1, const Vector4 &v2); 8.291 -inline Vector4 operator -(const Vector4 &v1, const Vector4 &v2); 8.292 -inline Vector4 operator *(const Vector4 &v1, const Vector4 &v2); 8.293 -inline Vector4 operator /(const Vector4 &v1, const Vector4 &v2); 8.294 -inline bool operator ==(const Vector4 &v1, const Vector4 &v2); 8.295 +VMATH_INLINE Vector4 operator +(const Vector4 &v1, const Vector4 &v2); 8.296 +VMATH_INLINE Vector4 operator -(const Vector4 &v1, const Vector4 &v2); 8.297 +VMATH_INLINE Vector4 operator *(const Vector4 &v1, const Vector4 &v2); 8.298 +VMATH_INLINE Vector4 operator /(const Vector4 &v1, const Vector4 &v2); 8.299 +VMATH_INLINE bool operator ==(const Vector4 &v1, const Vector4 &v2); 8.300 8.301 -inline void operator +=(Vector4 &v1, const Vector4 &v2); 8.302 -inline void operator -=(Vector4 &v1, const Vector4 &v2); 8.303 -inline void operator *=(Vector4 &v1, const Vector4 &v2); 8.304 -inline void operator /=(Vector4 &v1, const Vector4 &v2); 8.305 +VMATH_INLINE void operator +=(Vector4 &v1, const Vector4 &v2); 8.306 +VMATH_INLINE void operator -=(Vector4 &v1, const Vector4 &v2); 8.307 +VMATH_INLINE void operator *=(Vector4 &v1, const Vector4 &v2); 8.308 +VMATH_INLINE void operator /=(Vector4 &v1, const Vector4 &v2); 8.309 8.310 /* binary vector (op) scalar and scalar (op) vector operations */ 8.311 -inline Vector4 operator +(const Vector4 &vec, scalar_t scalar); 8.312 -inline Vector4 operator +(scalar_t scalar, const Vector4 &vec); 8.313 -inline Vector4 operator -(const Vector4 &vec, scalar_t scalar); 8.314 -inline Vector4 operator *(const Vector4 &vec, scalar_t scalar); 8.315 -inline Vector4 operator *(scalar_t scalar, const Vector4 &vec); 8.316 -inline Vector4 operator /(const Vector4 &vec, scalar_t scalar); 8.317 +VMATH_INLINE Vector4 operator +(const Vector4 &vec, scalar_t scalar); 8.318 +VMATH_INLINE Vector4 operator +(scalar_t scalar, const Vector4 &vec); 8.319 +VMATH_INLINE Vector4 operator -(const Vector4 &vec, scalar_t scalar); 8.320 +VMATH_INLINE Vector4 operator *(const Vector4 &vec, scalar_t scalar); 8.321 +VMATH_INLINE Vector4 operator *(scalar_t scalar, const Vector4 &vec); 8.322 +VMATH_INLINE Vector4 operator /(const Vector4 &vec, scalar_t scalar); 8.323 8.324 -inline void operator +=(Vector4 &vec, scalar_t scalar); 8.325 -inline void operator -=(Vector4 &vec, scalar_t scalar); 8.326 -inline void operator *=(Vector4 &vec, scalar_t scalar); 8.327 -inline void operator /=(Vector4 &vec, scalar_t scalar); 8.328 +VMATH_INLINE void operator +=(Vector4 &vec, scalar_t scalar); 8.329 +VMATH_INLINE void operator -=(Vector4 &vec, scalar_t scalar); 8.330 +VMATH_INLINE void operator *=(Vector4 &vec, scalar_t scalar); 8.331 +VMATH_INLINE void operator /=(Vector4 &vec, scalar_t scalar); 8.332 8.333 std::ostream &operator <<(std::ostream &out, const Vector4 &vec); 8.334 8.335 -inline Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t); 8.336 -inline Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1, 8.337 +VMATH_INLINE Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t); 8.338 +VMATH_INLINE Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1, 8.339 const Vector4 &v2, const Vector4 &v3, scalar_t t); 8.340 8.341 #endif /* __cplusplus */
9.1 --- a/libs/vmath/vector.inl Sun Sep 29 08:20:19 2013 +0300 9.2 +++ b/libs/vmath/vector.inl Sun Sep 29 08:46:19 2013 +0300 9.3 @@ -23,7 +23,7 @@ 9.4 #endif /* __cplusplus */ 9.5 9.6 /* C 2D vector functions */ 9.7 -static inline vec2_t v2_cons(scalar_t x, scalar_t y) 9.8 +static VMATH_INLINE vec2_t v2_cons(scalar_t x, scalar_t y) 9.9 { 9.10 vec2_t v; 9.11 v.x = x; 9.12 @@ -31,12 +31,12 @@ 9.13 return v; 9.14 } 9.15 9.16 -static inline void v2_print(FILE *fp, vec2_t v) 9.17 +static VMATH_INLINE void v2_print(FILE *fp, vec2_t v) 9.18 { 9.19 fprintf(fp, "[ %.4f %.4f ]", v.x, v.y); 9.20 } 9.21 9.22 -static inline vec2_t v2_add(vec2_t v1, vec2_t v2) 9.23 +static VMATH_INLINE vec2_t v2_add(vec2_t v1, vec2_t v2) 9.24 { 9.25 vec2_t res; 9.26 res.x = v1.x + v2.x; 9.27 @@ -44,7 +44,7 @@ 9.28 return res; 9.29 } 9.30 9.31 -static inline vec2_t v2_sub(vec2_t v1, vec2_t v2) 9.32 +static VMATH_INLINE vec2_t v2_sub(vec2_t v1, vec2_t v2) 9.33 { 9.34 vec2_t res; 9.35 res.x = v1.x - v2.x; 9.36 @@ -52,7 +52,7 @@ 9.37 return res; 9.38 } 9.39 9.40 -static inline vec2_t v2_scale(vec2_t v, scalar_t s) 9.41 +static VMATH_INLINE vec2_t v2_scale(vec2_t v, scalar_t s) 9.42 { 9.43 vec2_t res; 9.44 res.x = v.x * s; 9.45 @@ -60,22 +60,22 @@ 9.46 return res; 9.47 } 9.48 9.49 -static inline scalar_t v2_dot(vec2_t v1, vec2_t v2) 9.50 +static VMATH_INLINE scalar_t v2_dot(vec2_t v1, vec2_t v2) 9.51 { 9.52 return v1.x * v2.x + v1.y * v2.y; 9.53 } 9.54 9.55 -static inline scalar_t v2_length(vec2_t v) 9.56 +static VMATH_INLINE scalar_t v2_length(vec2_t v) 9.57 { 9.58 return sqrt(v.x * v.x + v.y * v.y); 9.59 } 9.60 9.61 -static inline scalar_t v2_length_sq(vec2_t v) 9.62 +static VMATH_INLINE scalar_t v2_length_sq(vec2_t v) 9.63 { 9.64 return v.x * v.x + v.y * v.y; 9.65 } 9.66 9.67 -static inline vec2_t v2_normalize(vec2_t v) 9.68 +static VMATH_INLINE vec2_t v2_normalize(vec2_t v) 9.69 { 9.70 scalar_t len = (scalar_t)sqrt(v.x * v.x + v.y * v.y); 9.71 v.x /= len; 9.72 @@ -83,7 +83,7 @@ 9.73 return v; 9.74 } 9.75 9.76 -static inline vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t) 9.77 +static VMATH_INLINE vec2_t v2_lerp(vec2_t v1, vec2_t v2, scalar_t t) 9.78 { 9.79 vec2_t res; 9.80 res.x = v1.x + (v2.x - v1.x) * t; 9.81 @@ -93,7 +93,7 @@ 9.82 9.83 9.84 /* C 3D vector functions */ 9.85 -static inline vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z) 9.86 +static VMATH_INLINE vec3_t v3_cons(scalar_t x, scalar_t y, scalar_t z) 9.87 { 9.88 vec3_t v; 9.89 v.x = x; 9.90 @@ -102,12 +102,12 @@ 9.91 return v; 9.92 } 9.93 9.94 -static inline void v3_print(FILE *fp, vec3_t v) 9.95 +static VMATH_INLINE void v3_print(FILE *fp, vec3_t v) 9.96 { 9.97 fprintf(fp, "[ %.4f %.4f %.4f ]", v.x, v.y, v.z); 9.98 } 9.99 9.100 -static inline vec3_t v3_add(vec3_t v1, vec3_t v2) 9.101 +static VMATH_INLINE vec3_t v3_add(vec3_t v1, vec3_t v2) 9.102 { 9.103 v1.x += v2.x; 9.104 v1.y += v2.y; 9.105 @@ -115,7 +115,7 @@ 9.106 return v1; 9.107 } 9.108 9.109 -static inline vec3_t v3_sub(vec3_t v1, vec3_t v2) 9.110 +static VMATH_INLINE vec3_t v3_sub(vec3_t v1, vec3_t v2) 9.111 { 9.112 v1.x -= v2.x; 9.113 v1.y -= v2.y; 9.114 @@ -123,7 +123,7 @@ 9.115 return v1; 9.116 } 9.117 9.118 -static inline vec3_t v3_neg(vec3_t v) 9.119 +static VMATH_INLINE vec3_t v3_neg(vec3_t v) 9.120 { 9.121 v.x = -v.x; 9.122 v.y = -v.y; 9.123 @@ -131,7 +131,7 @@ 9.124 return v; 9.125 } 9.126 9.127 -static inline vec3_t v3_mul(vec3_t v1, vec3_t v2) 9.128 +static VMATH_INLINE vec3_t v3_mul(vec3_t v1, vec3_t v2) 9.129 { 9.130 v1.x *= v2.x; 9.131 v1.y *= v2.y; 9.132 @@ -139,7 +139,7 @@ 9.133 return v1; 9.134 } 9.135 9.136 -static inline vec3_t v3_scale(vec3_t v1, scalar_t s) 9.137 +static VMATH_INLINE vec3_t v3_scale(vec3_t v1, scalar_t s) 9.138 { 9.139 v1.x *= s; 9.140 v1.y *= s; 9.141 @@ -147,12 +147,12 @@ 9.142 return v1; 9.143 } 9.144 9.145 -static inline scalar_t v3_dot(vec3_t v1, vec3_t v2) 9.146 +static VMATH_INLINE scalar_t v3_dot(vec3_t v1, vec3_t v2) 9.147 { 9.148 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; 9.149 } 9.150 9.151 -static inline vec3_t v3_cross(vec3_t v1, vec3_t v2) 9.152 +static VMATH_INLINE vec3_t v3_cross(vec3_t v1, vec3_t v2) 9.153 { 9.154 vec3_t v; 9.155 v.x = v1.y * v2.z - v1.z * v2.y; 9.156 @@ -161,17 +161,17 @@ 9.157 return v; 9.158 } 9.159 9.160 -static inline scalar_t v3_length(vec3_t v) 9.161 +static VMATH_INLINE scalar_t v3_length(vec3_t v) 9.162 { 9.163 return sqrt(v.x * v.x + v.y * v.y + v.z * v.z); 9.164 } 9.165 9.166 -static inline scalar_t v3_length_sq(vec3_t v) 9.167 +static VMATH_INLINE scalar_t v3_length_sq(vec3_t v) 9.168 { 9.169 return v.x * v.x + v.y * v.y + v.z * v.z; 9.170 } 9.171 9.172 -static inline vec3_t v3_normalize(vec3_t v) 9.173 +static VMATH_INLINE vec3_t v3_normalize(vec3_t v) 9.174 { 9.175 scalar_t len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z); 9.176 v.x /= len; 9.177 @@ -180,7 +180,7 @@ 9.178 return v; 9.179 } 9.180 9.181 -static inline vec3_t v3_transform(vec3_t v, mat4_t m) 9.182 +static VMATH_INLINE vec3_t v3_transform(vec3_t v, mat4_t m) 9.183 { 9.184 vec3_t res; 9.185 res.x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3]; 9.186 @@ -189,7 +189,7 @@ 9.187 return res; 9.188 } 9.189 9.190 -static inline vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z) 9.191 +static VMATH_INLINE vec3_t v3_rotate(vec3_t v, scalar_t x, scalar_t y, scalar_t z) 9.192 { 9.193 void m4_rotate(mat4_t, scalar_t, scalar_t, scalar_t); 9.194 9.195 @@ -198,7 +198,7 @@ 9.196 return v3_transform(v, m); 9.197 } 9.198 9.199 -static inline vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z) 9.200 +static VMATH_INLINE vec3_t v3_rotate_axis(vec3_t v, scalar_t angle, scalar_t x, scalar_t y, scalar_t z) 9.201 { 9.202 void m4_rotate_axis(mat4_t, scalar_t, scalar_t, scalar_t, scalar_t); 9.203 9.204 @@ -207,7 +207,7 @@ 9.205 return v3_transform(v, m); 9.206 } 9.207 9.208 -static inline vec3_t v3_rotate_quat(vec3_t v, quat_t q) 9.209 +static VMATH_INLINE vec3_t v3_rotate_quat(vec3_t v, quat_t q) 9.210 { 9.211 quat_t quat_rotate_quat(quat_t, quat_t); 9.212 9.213 @@ -216,13 +216,13 @@ 9.214 return v3_cons(res.x, res.y, res.z); 9.215 } 9.216 9.217 -static inline vec3_t v3_reflect(vec3_t v, vec3_t n) 9.218 +static VMATH_INLINE vec3_t v3_reflect(vec3_t v, vec3_t n) 9.219 { 9.220 scalar_t dot = v3_dot(v, n); 9.221 return v3_sub(v3_scale(n, dot * 2.0), v); 9.222 } 9.223 9.224 -static inline vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t) 9.225 +static VMATH_INLINE vec3_t v3_lerp(vec3_t v1, vec3_t v2, scalar_t t) 9.226 { 9.227 v1.x += (v2.x - v1.x) * t; 9.228 v1.y += (v2.y - v1.y) * t; 9.229 @@ -231,7 +231,7 @@ 9.230 } 9.231 9.232 /* C 4D vector functions */ 9.233 -static inline vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w) 9.234 +static VMATH_INLINE vec4_t v4_cons(scalar_t x, scalar_t y, scalar_t z, scalar_t w) 9.235 { 9.236 vec4_t v; 9.237 v.x = x; 9.238 @@ -241,12 +241,12 @@ 9.239 return v; 9.240 } 9.241 9.242 -static inline void v4_print(FILE *fp, vec4_t v) 9.243 +static VMATH_INLINE void v4_print(FILE *fp, vec4_t v) 9.244 { 9.245 fprintf(fp, "[ %.4f %.4f %.4f %.4f ]", v.x, v.y, v.z, v.w); 9.246 } 9.247 9.248 -static inline vec4_t v4_add(vec4_t v1, vec4_t v2) 9.249 +static VMATH_INLINE vec4_t v4_add(vec4_t v1, vec4_t v2) 9.250 { 9.251 v1.x += v2.x; 9.252 v1.y += v2.y; 9.253 @@ -255,7 +255,7 @@ 9.254 return v1; 9.255 } 9.256 9.257 -static inline vec4_t v4_sub(vec4_t v1, vec4_t v2) 9.258 +static VMATH_INLINE vec4_t v4_sub(vec4_t v1, vec4_t v2) 9.259 { 9.260 v1.x -= v2.x; 9.261 v1.y -= v2.y; 9.262 @@ -264,7 +264,7 @@ 9.263 return v1; 9.264 } 9.265 9.266 -static inline vec4_t v4_neg(vec4_t v) 9.267 +static VMATH_INLINE vec4_t v4_neg(vec4_t v) 9.268 { 9.269 v.x = -v.x; 9.270 v.y = -v.y; 9.271 @@ -273,7 +273,7 @@ 9.272 return v; 9.273 } 9.274 9.275 -static inline vec4_t v4_mul(vec4_t v1, vec4_t v2) 9.276 +static VMATH_INLINE vec4_t v4_mul(vec4_t v1, vec4_t v2) 9.277 { 9.278 v1.x *= v2.x; 9.279 v1.y *= v2.y; 9.280 @@ -282,7 +282,7 @@ 9.281 return v1; 9.282 } 9.283 9.284 -static inline vec4_t v4_scale(vec4_t v, scalar_t s) 9.285 +static VMATH_INLINE vec4_t v4_scale(vec4_t v, scalar_t s) 9.286 { 9.287 v.x *= s; 9.288 v.y *= s; 9.289 @@ -291,22 +291,22 @@ 9.290 return v; 9.291 } 9.292 9.293 -static inline scalar_t v4_dot(vec4_t v1, vec4_t v2) 9.294 +static VMATH_INLINE scalar_t v4_dot(vec4_t v1, vec4_t v2) 9.295 { 9.296 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w; 9.297 } 9.298 9.299 -static inline scalar_t v4_length(vec4_t v) 9.300 +static VMATH_INLINE scalar_t v4_length(vec4_t v) 9.301 { 9.302 return sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w); 9.303 } 9.304 9.305 -static inline scalar_t v4_length_sq(vec4_t v) 9.306 +static VMATH_INLINE scalar_t v4_length_sq(vec4_t v) 9.307 { 9.308 return v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w; 9.309 } 9.310 9.311 -static inline vec4_t v4_normalize(vec4_t v) 9.312 +static VMATH_INLINE vec4_t v4_normalize(vec4_t v) 9.313 { 9.314 scalar_t len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w); 9.315 v.x /= len; 9.316 @@ -316,7 +316,7 @@ 9.317 return v; 9.318 } 9.319 9.320 -static inline vec4_t v4_transform(vec4_t v, mat4_t m) 9.321 +static VMATH_INLINE vec4_t v4_transform(vec4_t v, mat4_t m) 9.322 { 9.323 vec4_t res; 9.324 res.x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w; 9.325 @@ -332,120 +332,120 @@ 9.326 9.327 /* --------------- C++ part -------------- */ 9.328 9.329 -inline scalar_t &Vector2::operator [](int elem) { 9.330 +VMATH_INLINE scalar_t &Vector2::operator [](int elem) { 9.331 return elem ? y : x; 9.332 } 9.333 9.334 -inline const scalar_t &Vector2::operator [](int elem) const { 9.335 +VMATH_INLINE const scalar_t &Vector2::operator [](int elem) const { 9.336 return elem ? y : x; 9.337 } 9.338 9.339 -inline Vector2 operator -(const Vector2 &vec) { 9.340 +VMATH_INLINE Vector2 operator -(const Vector2 &vec) { 9.341 return Vector2(-vec.x, -vec.y); 9.342 } 9.343 9.344 -inline scalar_t dot_product(const Vector2 &v1, const Vector2 &v2) { 9.345 +VMATH_INLINE scalar_t dot_product(const Vector2 &v1, const Vector2 &v2) { 9.346 return v1.x * v2.x + v1.y * v2.y; 9.347 } 9.348 9.349 -inline Vector2 operator +(const Vector2 &v1, const Vector2 &v2) { 9.350 +VMATH_INLINE Vector2 operator +(const Vector2 &v1, const Vector2 &v2) { 9.351 return Vector2(v1.x + v2.x, v1.y + v2.y); 9.352 } 9.353 9.354 -inline Vector2 operator -(const Vector2 &v1, const Vector2 &v2) { 9.355 +VMATH_INLINE Vector2 operator -(const Vector2 &v1, const Vector2 &v2) { 9.356 return Vector2(v1.x - v2.x, v1.y - v2.y); 9.357 } 9.358 9.359 -inline Vector2 operator *(const Vector2 &v1, const Vector2 &v2) { 9.360 +VMATH_INLINE Vector2 operator *(const Vector2 &v1, const Vector2 &v2) { 9.361 return Vector2(v1.x * v2.x, v1.y * v2.y); 9.362 } 9.363 9.364 -inline Vector2 operator /(const Vector2 &v1, const Vector2 &v2) { 9.365 +VMATH_INLINE Vector2 operator /(const Vector2 &v1, const Vector2 &v2) { 9.366 return Vector2(v1.x / v2.x, v1.y / v2.y); 9.367 } 9.368 9.369 -inline bool operator ==(const Vector2 &v1, const Vector2 &v2) { 9.370 +VMATH_INLINE bool operator ==(const Vector2 &v1, const Vector2 &v2) { 9.371 return (fabs(v1.x - v2.x) < XSMALL_NUMBER) && (fabs(v1.y - v2.x) < XSMALL_NUMBER); 9.372 } 9.373 9.374 -inline void operator +=(Vector2 &v1, const Vector2 &v2) { 9.375 +VMATH_INLINE void operator +=(Vector2 &v1, const Vector2 &v2) { 9.376 v1.x += v2.x; 9.377 v1.y += v2.y; 9.378 } 9.379 9.380 -inline void operator -=(Vector2 &v1, const Vector2 &v2) { 9.381 +VMATH_INLINE void operator -=(Vector2 &v1, const Vector2 &v2) { 9.382 v1.x -= v2.x; 9.383 v1.y -= v2.y; 9.384 } 9.385 9.386 -inline void operator *=(Vector2 &v1, const Vector2 &v2) { 9.387 +VMATH_INLINE void operator *=(Vector2 &v1, const Vector2 &v2) { 9.388 v1.x *= v2.x; 9.389 v1.y *= v2.y; 9.390 } 9.391 9.392 -inline void operator /=(Vector2 &v1, const Vector2 &v2) { 9.393 +VMATH_INLINE void operator /=(Vector2 &v1, const Vector2 &v2) { 9.394 v1.x /= v2.x; 9.395 v1.y /= v2.y; 9.396 } 9.397 9.398 -inline Vector2 operator +(const Vector2 &vec, scalar_t scalar) { 9.399 +VMATH_INLINE Vector2 operator +(const Vector2 &vec, scalar_t scalar) { 9.400 return Vector2(vec.x + scalar, vec.y + scalar); 9.401 } 9.402 9.403 -inline Vector2 operator +(scalar_t scalar, const Vector2 &vec) { 9.404 +VMATH_INLINE Vector2 operator +(scalar_t scalar, const Vector2 &vec) { 9.405 return Vector2(vec.x + scalar, vec.y + scalar); 9.406 } 9.407 9.408 -inline Vector2 operator -(scalar_t scalar, const Vector2 &vec) { 9.409 +VMATH_INLINE Vector2 operator -(scalar_t scalar, const Vector2 &vec) { 9.410 return Vector2(vec.x - scalar, vec.y - scalar); 9.411 } 9.412 9.413 -inline Vector2 operator *(const Vector2 &vec, scalar_t scalar) { 9.414 +VMATH_INLINE Vector2 operator *(const Vector2 &vec, scalar_t scalar) { 9.415 return Vector2(vec.x * scalar, vec.y * scalar); 9.416 } 9.417 9.418 -inline Vector2 operator *(scalar_t scalar, const Vector2 &vec) { 9.419 +VMATH_INLINE Vector2 operator *(scalar_t scalar, const Vector2 &vec) { 9.420 return Vector2(vec.x * scalar, vec.y * scalar); 9.421 } 9.422 9.423 -inline Vector2 operator /(const Vector2 &vec, scalar_t scalar) { 9.424 +VMATH_INLINE Vector2 operator /(const Vector2 &vec, scalar_t scalar) { 9.425 return Vector2(vec.x / scalar, vec.y / scalar); 9.426 } 9.427 9.428 -inline void operator +=(Vector2 &vec, scalar_t scalar) { 9.429 +VMATH_INLINE void operator +=(Vector2 &vec, scalar_t scalar) { 9.430 vec.x += scalar; 9.431 vec.y += scalar; 9.432 } 9.433 9.434 -inline void operator -=(Vector2 &vec, scalar_t scalar) { 9.435 +VMATH_INLINE void operator -=(Vector2 &vec, scalar_t scalar) { 9.436 vec.x -= scalar; 9.437 vec.y -= scalar; 9.438 } 9.439 9.440 -inline void operator *=(Vector2 &vec, scalar_t scalar) { 9.441 +VMATH_INLINE void operator *=(Vector2 &vec, scalar_t scalar) { 9.442 vec.x *= scalar; 9.443 vec.y *= scalar; 9.444 } 9.445 9.446 -inline void operator /=(Vector2 &vec, scalar_t scalar) { 9.447 +VMATH_INLINE void operator /=(Vector2 &vec, scalar_t scalar) { 9.448 vec.x /= scalar; 9.449 vec.y /= scalar; 9.450 } 9.451 9.452 -inline scalar_t Vector2::length() const { 9.453 +VMATH_INLINE scalar_t Vector2::length() const { 9.454 return sqrt(x*x + y*y); 9.455 } 9.456 9.457 -inline scalar_t Vector2::length_sq() const { 9.458 +VMATH_INLINE scalar_t Vector2::length_sq() const { 9.459 return x*x + y*y; 9.460 } 9.461 9.462 -inline Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t) 9.463 +VMATH_INLINE Vector2 lerp(const Vector2 &a, const Vector2 &b, scalar_t t) 9.464 { 9.465 return a + (b - a) * t; 9.466 } 9.467 9.468 -inline Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1, 9.469 +VMATH_INLINE Vector2 catmull_rom_spline(const Vector2 &v0, const Vector2 &v1, 9.470 const Vector2 &v2, const Vector2 &v3, scalar_t t) 9.471 { 9.472 scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t); 9.473 @@ -457,133 +457,133 @@ 9.474 9.475 /* ------------- Vector3 -------------- */ 9.476 9.477 -inline scalar_t &Vector3::operator [](int elem) { 9.478 +VMATH_INLINE scalar_t &Vector3::operator [](int elem) { 9.479 return elem ? (elem == 1 ? y : z) : x; 9.480 } 9.481 9.482 -inline const scalar_t &Vector3::operator [](int elem) const { 9.483 +VMATH_INLINE const scalar_t &Vector3::operator [](int elem) const { 9.484 return elem ? (elem == 1 ? y : z) : x; 9.485 } 9.486 9.487 /* unary operations */ 9.488 -inline Vector3 operator -(const Vector3 &vec) { 9.489 +VMATH_INLINE Vector3 operator -(const Vector3 &vec) { 9.490 return Vector3(-vec.x, -vec.y, -vec.z); 9.491 } 9.492 9.493 /* binary vector (op) vector operations */ 9.494 -inline scalar_t dot_product(const Vector3 &v1, const Vector3 &v2) { 9.495 +VMATH_INLINE scalar_t dot_product(const Vector3 &v1, const Vector3 &v2) { 9.496 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; 9.497 } 9.498 9.499 -inline Vector3 cross_product(const Vector3 &v1, const Vector3 &v2) { 9.500 +VMATH_INLINE Vector3 cross_product(const Vector3 &v1, const Vector3 &v2) { 9.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); 9.502 } 9.503 9.504 9.505 -inline Vector3 operator +(const Vector3 &v1, const Vector3 &v2) { 9.506 +VMATH_INLINE Vector3 operator +(const Vector3 &v1, const Vector3 &v2) { 9.507 return Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); 9.508 } 9.509 9.510 -inline Vector3 operator -(const Vector3 &v1, const Vector3 &v2) { 9.511 +VMATH_INLINE Vector3 operator -(const Vector3 &v1, const Vector3 &v2) { 9.512 return Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); 9.513 } 9.514 9.515 -inline Vector3 operator *(const Vector3 &v1, const Vector3 &v2) { 9.516 +VMATH_INLINE Vector3 operator *(const Vector3 &v1, const Vector3 &v2) { 9.517 return Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); 9.518 } 9.519 9.520 -inline Vector3 operator /(const Vector3 &v1, const Vector3 &v2) { 9.521 +VMATH_INLINE Vector3 operator /(const Vector3 &v1, const Vector3 &v2) { 9.522 return Vector3(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); 9.523 } 9.524 9.525 -inline bool operator ==(const Vector3 &v1, const Vector3 &v2) { 9.526 +VMATH_INLINE bool operator ==(const Vector3 &v1, const Vector3 &v2) { 9.527 return (fabs(v1.x - v2.x) < XSMALL_NUMBER) && (fabs(v1.y - v2.y) < XSMALL_NUMBER) && (fabs(v1.z - v2.z) < XSMALL_NUMBER); 9.528 } 9.529 9.530 -inline void operator +=(Vector3 &v1, const Vector3 &v2) { 9.531 +VMATH_INLINE void operator +=(Vector3 &v1, const Vector3 &v2) { 9.532 v1.x += v2.x; 9.533 v1.y += v2.y; 9.534 v1.z += v2.z; 9.535 } 9.536 9.537 -inline void operator -=(Vector3 &v1, const Vector3 &v2) { 9.538 +VMATH_INLINE void operator -=(Vector3 &v1, const Vector3 &v2) { 9.539 v1.x -= v2.x; 9.540 v1.y -= v2.y; 9.541 v1.z -= v2.z; 9.542 } 9.543 9.544 -inline void operator *=(Vector3 &v1, const Vector3 &v2) { 9.545 +VMATH_INLINE void operator *=(Vector3 &v1, const Vector3 &v2) { 9.546 v1.x *= v2.x; 9.547 v1.y *= v2.y; 9.548 v1.z *= v2.z; 9.549 } 9.550 9.551 -inline void operator /=(Vector3 &v1, const Vector3 &v2) { 9.552 +VMATH_INLINE void operator /=(Vector3 &v1, const Vector3 &v2) { 9.553 v1.x /= v2.x; 9.554 v1.y /= v2.y; 9.555 v1.z /= v2.z; 9.556 } 9.557 /* binary vector (op) scalar and scalar (op) vector operations */ 9.558 -inline Vector3 operator +(const Vector3 &vec, scalar_t scalar) { 9.559 +VMATH_INLINE Vector3 operator +(const Vector3 &vec, scalar_t scalar) { 9.560 return Vector3(vec.x + scalar, vec.y + scalar, vec.z + scalar); 9.561 } 9.562 9.563 -inline Vector3 operator +(scalar_t scalar, const Vector3 &vec) { 9.564 +VMATH_INLINE Vector3 operator +(scalar_t scalar, const Vector3 &vec) { 9.565 return Vector3(vec.x + scalar, vec.y + scalar, vec.z + scalar); 9.566 } 9.567 9.568 -inline Vector3 operator -(const Vector3 &vec, scalar_t scalar) { 9.569 +VMATH_INLINE Vector3 operator -(const Vector3 &vec, scalar_t scalar) { 9.570 return Vector3(vec.x - scalar, vec.y - scalar, vec.z - scalar); 9.571 } 9.572 9.573 -inline Vector3 operator *(const Vector3 &vec, scalar_t scalar) { 9.574 +VMATH_INLINE Vector3 operator *(const Vector3 &vec, scalar_t scalar) { 9.575 return Vector3(vec.x * scalar, vec.y * scalar, vec.z * scalar); 9.576 } 9.577 9.578 -inline Vector3 operator *(scalar_t scalar, const Vector3 &vec) { 9.579 +VMATH_INLINE Vector3 operator *(scalar_t scalar, const Vector3 &vec) { 9.580 return Vector3(vec.x * scalar, vec.y * scalar, vec.z * scalar); 9.581 } 9.582 9.583 -inline Vector3 operator /(const Vector3 &vec, scalar_t scalar) { 9.584 +VMATH_INLINE Vector3 operator /(const Vector3 &vec, scalar_t scalar) { 9.585 return Vector3(vec.x / scalar, vec.y / scalar, vec.z / scalar); 9.586 } 9.587 9.588 -inline void operator +=(Vector3 &vec, scalar_t scalar) { 9.589 +VMATH_INLINE void operator +=(Vector3 &vec, scalar_t scalar) { 9.590 vec.x += scalar; 9.591 vec.y += scalar; 9.592 vec.z += scalar; 9.593 } 9.594 9.595 -inline void operator -=(Vector3 &vec, scalar_t scalar) { 9.596 +VMATH_INLINE void operator -=(Vector3 &vec, scalar_t scalar) { 9.597 vec.x -= scalar; 9.598 vec.y -= scalar; 9.599 vec.z -= scalar; 9.600 } 9.601 9.602 -inline void operator *=(Vector3 &vec, scalar_t scalar) { 9.603 +VMATH_INLINE void operator *=(Vector3 &vec, scalar_t scalar) { 9.604 vec.x *= scalar; 9.605 vec.y *= scalar; 9.606 vec.z *= scalar; 9.607 } 9.608 9.609 -inline void operator /=(Vector3 &vec, scalar_t scalar) { 9.610 +VMATH_INLINE void operator /=(Vector3 &vec, scalar_t scalar) { 9.611 vec.x /= scalar; 9.612 vec.y /= scalar; 9.613 vec.z /= scalar; 9.614 } 9.615 9.616 -inline scalar_t Vector3::length() const { 9.617 +VMATH_INLINE scalar_t Vector3::length() const { 9.618 return sqrt(x*x + y*y + z*z); 9.619 } 9.620 -inline scalar_t Vector3::length_sq() const { 9.621 +VMATH_INLINE scalar_t Vector3::length_sq() const { 9.622 return x*x + y*y + z*z; 9.623 } 9.624 9.625 -inline Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t) { 9.626 +VMATH_INLINE Vector3 lerp(const Vector3 &a, const Vector3 &b, scalar_t t) { 9.627 return a + (b - a) * t; 9.628 } 9.629 9.630 -inline Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1, 9.631 +VMATH_INLINE Vector3 catmull_rom_spline(const Vector3 &v0, const Vector3 &v1, 9.632 const Vector3 &v2, const Vector3 &v3, scalar_t t) 9.633 { 9.634 scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t); 9.635 @@ -595,23 +595,23 @@ 9.636 9.637 /* ----------- Vector4 ----------------- */ 9.638 9.639 -inline scalar_t &Vector4::operator [](int elem) { 9.640 +VMATH_INLINE scalar_t &Vector4::operator [](int elem) { 9.641 return elem ? (elem == 1 ? y : (elem == 2 ? z : w)) : x; 9.642 } 9.643 9.644 -inline const scalar_t &Vector4::operator [](int elem) const { 9.645 +VMATH_INLINE const scalar_t &Vector4::operator [](int elem) const { 9.646 return elem ? (elem == 1 ? y : (elem == 2 ? z : w)) : x; 9.647 } 9.648 9.649 -inline Vector4 operator -(const Vector4 &vec) { 9.650 +VMATH_INLINE Vector4 operator -(const Vector4 &vec) { 9.651 return Vector4(-vec.x, -vec.y, -vec.z, -vec.w); 9.652 } 9.653 9.654 -inline scalar_t dot_product(const Vector4 &v1, const Vector4 &v2) { 9.655 +VMATH_INLINE scalar_t dot_product(const Vector4 &v1, const Vector4 &v2) { 9.656 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w; 9.657 } 9.658 9.659 -inline Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3) { 9.660 +VMATH_INLINE Vector4 cross_product(const Vector4 &v1, const Vector4 &v2, const Vector4 &v3) { 9.661 scalar_t a, b, c, d, e, f; /* Intermediate Values */ 9.662 Vector4 result; 9.663 9.664 @@ -631,51 +631,51 @@ 9.665 return result; 9.666 } 9.667 9.668 -inline Vector4 operator +(const Vector4 &v1, const Vector4 &v2) { 9.669 +VMATH_INLINE Vector4 operator +(const Vector4 &v1, const Vector4 &v2) { 9.670 return Vector4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); 9.671 } 9.672 9.673 -inline Vector4 operator -(const Vector4 &v1, const Vector4 &v2) { 9.674 +VMATH_INLINE Vector4 operator -(const Vector4 &v1, const Vector4 &v2) { 9.675 return Vector4(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w); 9.676 } 9.677 9.678 -inline Vector4 operator *(const Vector4 &v1, const Vector4 &v2) { 9.679 +VMATH_INLINE Vector4 operator *(const Vector4 &v1, const Vector4 &v2) { 9.680 return Vector4(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w); 9.681 } 9.682 9.683 -inline Vector4 operator /(const Vector4 &v1, const Vector4 &v2) { 9.684 +VMATH_INLINE Vector4 operator /(const Vector4 &v1, const Vector4 &v2) { 9.685 return Vector4(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w); 9.686 } 9.687 9.688 -inline bool operator ==(const Vector4 &v1, const Vector4 &v2) { 9.689 +VMATH_INLINE bool operator ==(const Vector4 &v1, const Vector4 &v2) { 9.690 return (fabs(v1.x - v2.x) < XSMALL_NUMBER) && 9.691 (fabs(v1.y - v2.y) < XSMALL_NUMBER) && 9.692 (fabs(v1.z - v2.z) < XSMALL_NUMBER) && 9.693 (fabs(v1.w - v2.w) < XSMALL_NUMBER); 9.694 } 9.695 9.696 -inline void operator +=(Vector4 &v1, const Vector4 &v2) { 9.697 +VMATH_INLINE void operator +=(Vector4 &v1, const Vector4 &v2) { 9.698 v1.x += v2.x; 9.699 v1.y += v2.y; 9.700 v1.z += v2.z; 9.701 v1.w += v2.w; 9.702 } 9.703 9.704 -inline void operator -=(Vector4 &v1, const Vector4 &v2) { 9.705 +VMATH_INLINE void operator -=(Vector4 &v1, const Vector4 &v2) { 9.706 v1.x -= v2.x; 9.707 v1.y -= v2.y; 9.708 v1.z -= v2.z; 9.709 v1.w -= v2.w; 9.710 } 9.711 9.712 -inline void operator *=(Vector4 &v1, const Vector4 &v2) { 9.713 +VMATH_INLINE void operator *=(Vector4 &v1, const Vector4 &v2) { 9.714 v1.x *= v2.x; 9.715 v1.y *= v2.y; 9.716 v1.z *= v2.z; 9.717 v1.w *= v2.w; 9.718 } 9.719 9.720 -inline void operator /=(Vector4 &v1, const Vector4 &v2) { 9.721 +VMATH_INLINE void operator /=(Vector4 &v1, const Vector4 &v2) { 9.722 v1.x /= v2.x; 9.723 v1.y /= v2.y; 9.724 v1.z /= v2.z; 9.725 @@ -683,71 +683,71 @@ 9.726 } 9.727 9.728 /* binary vector (op) scalar and scalar (op) vector operations */ 9.729 -inline Vector4 operator +(const Vector4 &vec, scalar_t scalar) { 9.730 +VMATH_INLINE Vector4 operator +(const Vector4 &vec, scalar_t scalar) { 9.731 return Vector4(vec.x + scalar, vec.y + scalar, vec.z + scalar, vec.w + scalar); 9.732 } 9.733 9.734 -inline Vector4 operator +(scalar_t scalar, const Vector4 &vec) { 9.735 +VMATH_INLINE Vector4 operator +(scalar_t scalar, const Vector4 &vec) { 9.736 return Vector4(vec.x + scalar, vec.y + scalar, vec.z + scalar, vec.w + scalar); 9.737 } 9.738 9.739 -inline Vector4 operator -(const Vector4 &vec, scalar_t scalar) { 9.740 +VMATH_INLINE Vector4 operator -(const Vector4 &vec, scalar_t scalar) { 9.741 return Vector4(vec.x - scalar, vec.y - scalar, vec.z - scalar, vec.w - scalar); 9.742 } 9.743 9.744 -inline Vector4 operator *(const Vector4 &vec, scalar_t scalar) { 9.745 +VMATH_INLINE Vector4 operator *(const Vector4 &vec, scalar_t scalar) { 9.746 return Vector4(vec.x * scalar, vec.y * scalar, vec.z * scalar, vec.w * scalar); 9.747 } 9.748 9.749 -inline Vector4 operator *(scalar_t scalar, const Vector4 &vec) { 9.750 +VMATH_INLINE Vector4 operator *(scalar_t scalar, const Vector4 &vec) { 9.751 return Vector4(vec.x * scalar, vec.y * scalar, vec.z * scalar, vec.w * scalar); 9.752 } 9.753 9.754 -inline Vector4 operator /(const Vector4 &vec, scalar_t scalar) { 9.755 +VMATH_INLINE Vector4 operator /(const Vector4 &vec, scalar_t scalar) { 9.756 return Vector4(vec.x / scalar, vec.y / scalar, vec.z / scalar, vec.w / scalar); 9.757 } 9.758 9.759 -inline void operator +=(Vector4 &vec, scalar_t scalar) { 9.760 +VMATH_INLINE void operator +=(Vector4 &vec, scalar_t scalar) { 9.761 vec.x += scalar; 9.762 vec.y += scalar; 9.763 vec.z += scalar; 9.764 vec.w += scalar; 9.765 } 9.766 9.767 -inline void operator -=(Vector4 &vec, scalar_t scalar) { 9.768 +VMATH_INLINE void operator -=(Vector4 &vec, scalar_t scalar) { 9.769 vec.x -= scalar; 9.770 vec.y -= scalar; 9.771 vec.z -= scalar; 9.772 vec.w -= scalar; 9.773 } 9.774 9.775 -inline void operator *=(Vector4 &vec, scalar_t scalar) { 9.776 +VMATH_INLINE void operator *=(Vector4 &vec, scalar_t scalar) { 9.777 vec.x *= scalar; 9.778 vec.y *= scalar; 9.779 vec.z *= scalar; 9.780 vec.w *= scalar; 9.781 } 9.782 9.783 -inline void operator /=(Vector4 &vec, scalar_t scalar) { 9.784 +VMATH_INLINE void operator /=(Vector4 &vec, scalar_t scalar) { 9.785 vec.x /= scalar; 9.786 vec.y /= scalar; 9.787 vec.z /= scalar; 9.788 vec.w /= scalar; 9.789 } 9.790 9.791 -inline scalar_t Vector4::length() const { 9.792 +VMATH_INLINE scalar_t Vector4::length() const { 9.793 return sqrt(x*x + y*y + z*z + w*w); 9.794 } 9.795 -inline scalar_t Vector4::length_sq() const { 9.796 +VMATH_INLINE scalar_t Vector4::length_sq() const { 9.797 return x*x + y*y + z*z + w*w; 9.798 } 9.799 9.800 -inline Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t) 9.801 +VMATH_INLINE Vector4 lerp(const Vector4 &v0, const Vector4 &v1, scalar_t t) 9.802 { 9.803 return v0 + (v1 - v0) * t; 9.804 } 9.805 9.806 -inline Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1, 9.807 +VMATH_INLINE Vector4 catmull_rom_spline(const Vector4 &v0, const Vector4 &v1, 9.808 const Vector4 &v2, const Vector4 &v3, scalar_t t) 9.809 { 9.810 scalar_t spline(scalar_t, scalar_t, scalar_t, scalar_t, scalar_t);
10.1 --- a/libs/vmath/vmath.h Sun Sep 29 08:20:19 2013 +0300 10.2 +++ b/libs/vmath/vmath.h Sun Sep 29 08:46:19 2013 +0300 10.3 @@ -52,15 +52,15 @@ 10.4 extern "C" { 10.5 #endif /* __cplusplus */ 10.6 10.7 -static inline scalar_t smoothstep(float a, float b, float x); 10.8 +static VMATH_INLINE scalar_t smoothstep(float a, float b, float x); 10.9 10.10 -static inline scalar_t frand(scalar_t range); 10.11 -static inline vec3_t sphrand(scalar_t rad); 10.12 +static VMATH_INLINE scalar_t frand(scalar_t range); 10.13 +static VMATH_INLINE vec3_t sphrand(scalar_t rad); 10.14 10.15 scalar_t integral(scalar_t (*f)(scalar_t), scalar_t low, scalar_t high, int samples); 10.16 scalar_t gaussian(scalar_t x, scalar_t mean, scalar_t sdev); 10.17 10.18 -static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t); 10.19 +static VMATH_INLINE scalar_t lerp(scalar_t a, scalar_t b, scalar_t t); 10.20 10.21 scalar_t bspline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t); 10.22 scalar_t spline(scalar_t a, scalar_t b, scalar_t c, scalar_t d, scalar_t t);
11.1 --- a/libs/vmath/vmath.inl Sun Sep 29 08:20:19 2013 +0300 11.2 +++ b/libs/vmath/vmath.inl Sun Sep 29 08:46:19 2013 +0300 11.3 @@ -18,7 +18,7 @@ 11.4 11.5 #include <stdlib.h> 11.6 11.7 -static inline scalar_t smoothstep(float a, float b, float x) 11.8 +static VMATH_INLINE scalar_t smoothstep(float a, float b, float x) 11.9 { 11.10 if(x < a) return 0.0; 11.11 if(x >= b) return 1.0; 11.12 @@ -28,13 +28,13 @@ 11.13 } 11.14 11.15 /** Generates a random number in [0, range) */ 11.16 -static inline scalar_t frand(scalar_t range) 11.17 +static VMATH_INLINE scalar_t frand(scalar_t range) 11.18 { 11.19 return range * (scalar_t)rand() / (scalar_t)RAND_MAX; 11.20 } 11.21 11.22 /** Generates a random vector on the surface of a sphere */ 11.23 -static inline vec3_t sphrand(scalar_t rad) 11.24 +static VMATH_INLINE vec3_t sphrand(scalar_t rad) 11.25 { 11.26 scalar_t u = (scalar_t)rand() / RAND_MAX; 11.27 scalar_t v = (scalar_t)rand() / RAND_MAX; 11.28 @@ -50,7 +50,7 @@ 11.29 } 11.30 11.31 /** linear interpolation */ 11.32 -static inline scalar_t lerp(scalar_t a, scalar_t b, scalar_t t) 11.33 +static VMATH_INLINE scalar_t lerp(scalar_t a, scalar_t b, scalar_t t) 11.34 { 11.35 return a + (b - a) * t; 11.36 }
12.1 --- a/libs/vmath/vmath_config.h Sun Sep 29 08:20:19 2013 +0300 12.2 +++ b/libs/vmath/vmath_config.h Sun Sep 29 08:46:19 2013 +0300 12.3 @@ -1,11 +1,13 @@ 12.4 #ifndef VMATH_CONFIG_H_ 12.5 #define VMATH_CONFIG_H_ 12.6 12.7 -#if (__STDC_VERSION__ < 199999) 12.8 +#ifdef __cplusplus 12.9 +#define VMATH_INLINE inline 12.10 +#elif (__STDC_VERSION__ < 199999) 12.11 #if defined(__GNUC__) || defined(_MSC_VER) 12.12 -#define inline __inline 12.13 +#define VMATH_INLINE __inline 12.14 #else 12.15 -#define inline 12.16 +#define VMATH_INLINE 12.17 12.18 #ifdef VECTOR_H_ 12.19 #warning "compiling vector operations without inline, performance might suffer"