Compare commits

..

11 Commits

Author SHA1 Message Date
Recep Aslantas
059bdfdd4b update docs 2018-05-27 11:54:05 +03:00
Recep Aslantas
ef0653640f update cocoapod version tag 2018-05-27 11:53:48 +03:00
Recep Aslantas
e5d61b3433 update mat4_mulv3 api to include translation 2018-05-27 11:46:27 +03:00
Recep Aslantas
73c073cf32 add missing call functions 2018-05-27 11:44:06 +03:00
Recep Aslantas
1362bef50f fix glm_translate_to 2018-05-23 23:13:41 +03:00
Recep Aslantas
7d783eeace align local variables on stack 2018-05-23 23:04:06 +03:00
Recep Aslantas
e12e79b1a5 improve scale_make 2018-05-23 22:11:44 +03:00
Recep Aslantas
6cd3d52dc5 improve translate_make 2018-05-23 22:08:12 +03:00
Recep Aslantas
fb2cac9816 aabb: center of AABB helper
* it is just wrapper of vec_center but it saves to access min and max values of AABB
2018-05-22 17:45:37 +03:00
Recep Aslantas
4e63325f55 aabb: add missing call versions 2018-05-22 17:44:36 +03:00
Recep Aslantas
96c3e604ff now working on v0.4.6 2018-05-22 17:43:46 +03:00
27 changed files with 441 additions and 103 deletions

View File

@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
# Description
s.name = "cglm"
s.version = "0.4.4"
s.version = "0.4.6"
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
s.description = <<-DESC
cglm is math library for graphics programming for C. It is similar to original glm but it is written for C instead of C++ (you can use here too). See the documentation or README for all features.

View File

@@ -7,7 +7,7 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.4.5], [info@recp.me])
AC_INIT([cglm], [0.4.6], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_MACRO_DIR([m4])

View File

@@ -28,6 +28,7 @@ Functions:
#. :c:func:`glm_aabb_isvalid`
#. :c:func:`glm_aabb_size`
#. :c:func:`glm_aabb_radius`
#. :c:func:`glm_aabb_center`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -131,3 +132,11 @@ Functions documentation
Parameters:
| *[in]* **box** bounding box
.. c:function:: void glm_aabb_center(vec3 box[2], vec3 dest)
| computes center point of AABB
Parameters:
| *[in]* **box** bounding box
| *[out]* **box** center of bounding box

View File

@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.4.5'
version = u'0.4.6'
# The full version, including alpha/beta/rc tags.
release = u'0.4.5'
release = u'0.4.6'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -24,6 +24,7 @@ Functions:
#. :c:func:`glm_mat3_transpose_to`
#. :c:func:`glm_mat3_transpose`
#. :c:func:`glm_mat3_mulv`
#. :c:func:`glm_mat3_quat`
#. :c:func:`glm_mat3_scale`
#. :c:func:`glm_mat3_det`
#. :c:func:`glm_mat3_inv`
@@ -89,6 +90,14 @@ Functions documentation
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** destination (result, column vector)
.. c:function:: void glm_mat3_quat(mat3 m, versor dest)
convert mat3 to quaternion
Parameters:
| *[in]* **m** rotation matrix
| *[out]* **dest** destination quaternion
.. c:function:: void glm_mat3_scale(mat3 m, float s)
multiply matrix with scalar

View File

@@ -32,6 +32,7 @@ Functions:
#. :c:func:`glm_mat4_mulN`
#. :c:func:`glm_mat4_mulv`
#. :c:func:`glm_mat4_mulv3`
#. :c:func:`glm_mat4_quat`
#. :c:func:`glm_mat4_transpose_to`
#. :c:func:`glm_mat4_transpose`
#. :c:func:`glm_mat4_scale_p`
@@ -146,6 +147,14 @@ Functions documentation
| *[in]* **v** vec3 (right, column vector)
| *[out]* **dest** vec3 (result, column vector)
.. c:function:: void glm_mat4_quat(mat4 m, versor dest)
convert mat4's rotation part to quaternion
Parameters:
| *[in]* **m** affine matrix
| *[out]* **dest** destination quaternion
.. c:function:: void glm_mat4_transpose_to(mat4 m, mat4 dest)
transpose mat4 and store in dest

View File

@@ -44,48 +44,6 @@ CGLM_INLINE
void
glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest);
/*!
* @brief translate existing transform matrix by v vector
* and store result in dest
*
* @param[in] m affine transfrom
* @param[in] v translate vector [x, y, z]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
#if defined( __SSE__ ) || defined( __SSE2__ )
glmm_store(dest[3],
_mm_add_ps(_mm_add_ps(_mm_mul_ps(glmm_load(t[0]),
_mm_set1_ps(v[0])),
_mm_mul_ps(glmm_load(t[1]),
_mm_set1_ps(v[1]))),
_mm_add_ps(_mm_mul_ps(glmm_load(t[2]),
_mm_set1_ps(v[2])),
glmm_load(t[3]))))
;
glmm_store(dest[0], glmm_load(m[0]));
glmm_store(dest[1], glmm_load(m[1]));
glmm_store(dest[2], glmm_load(m[2]));
#else
vec4 v1, v2, v3;
glm_vec4_scale(t[0], v[0], v1);
glm_vec4_scale(t[1], v[1], v2);
glm_vec4_scale(t[2], v[2], v3);
glm_vec4_add(v1, t[3], t[3]);
glm_vec4_add(v2, t[3], t[3]);
glm_vec4_add(v3, t[3], t[3]);
glm__memcpy(float, dest, t, sizeof(mat4));
#endif
}
/*!
* @brief translate existing transform matrix by v vector
* and stores result in same matrix
@@ -119,6 +77,23 @@ glm_translate(mat4 m, vec3 v) {
#endif
}
/*!
* @brief translate existing transform matrix by v vector
* and store result in dest
*
* source matrix will remain same
*
* @param[in] m affine transfrom
* @param[in] v translate vector [x, y, z]
* @param[out] dest translated matrix
*/
CGLM_INLINE
void
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
glm_mat4_copy(m, dest);
glm_translate(dest, v);
}
/*!
* @brief translate existing transform matrix by x factor
*
@@ -194,8 +169,8 @@ glm_translate_z(mat4 m, float z) {
CGLM_INLINE
void
glm_translate_make(mat4 m, vec3 v) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
glm_translate_to(t, v, m);
glm_mat4_identity(m);
glm_vec_copy(v, m[3]);
}
/*!
@@ -225,8 +200,10 @@ glm_scale_to(mat4 m, vec3 v, mat4 dest) {
CGLM_INLINE
void
glm_scale_make(mat4 m, vec3 v) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
glm_scale_to(t, v, m);
glm_mat4_identity(m);
m[0][0] = v[0];
m[1][1] = v[1];
m[2][2] = v[2];
}
/*!
@@ -252,7 +229,7 @@ glm_scale(mat4 m, vec3 v) {
CGLM_INLINE
void
glm_scale_uni(mat4 m, float s) {
vec3 v = { s, s, s };
CGLM_ALIGN(8) vec3 v = { s, s, s };
glm_scale_to(m, v, m);
}
@@ -267,7 +244,7 @@ glm_scale_uni(mat4 m, float s) {
CGLM_INLINE
void
glm_rotate_x(mat4 m, float angle, mat4 dest) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
@@ -292,7 +269,7 @@ glm_rotate_x(mat4 m, float angle, mat4 dest) {
CGLM_INLINE
void
glm_rotate_y(mat4 m, float angle, mat4 dest) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
@@ -317,7 +294,7 @@ glm_rotate_y(mat4 m, float angle, mat4 dest) {
CGLM_INLINE
void
glm_rotate_z(mat4 m, float angle, mat4 dest) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s;
c = cosf(angle);
@@ -343,7 +320,7 @@ glm_rotate_z(mat4 m, float angle, mat4 dest) {
CGLM_INLINE
void
glm_rotate_make(mat4 m, float angle, vec3 axis) {
vec3 axisn, v, vs;
CGLM_ALIGN(8) vec3 axisn, v, vs;
float c;
c = cosf(angle);
@@ -374,7 +351,7 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
CGLM_INLINE
void
glm_rotate(mat4 m, float angle, vec3 axis) {
mat4 rot;
CGLM_ALIGN(16) mat4 rot;
glm_rotate_make(rot, angle, axis);
glm_mul_rot(m, rot, m);
}
@@ -391,7 +368,7 @@ glm_rotate(mat4 m, float angle, vec3 axis) {
CGLM_INLINE
void
glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
vec3 pivotInv;
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec_inv_to(pivot, pivotInv);
@@ -416,12 +393,11 @@ glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
CGLM_INLINE
void
glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) {
vec3 pivotInv;
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec_inv_to(pivot, pivotInv);
glm_mat4_identity(m);
glm_vec_copy(pivot, m[3]);
glm_translate_make(m, pivot);
glm_rotate(m, angle, axis);
glm_translate(m, pivotInv);
}
@@ -451,9 +427,8 @@ glm_decompose_scalev(mat4 m, vec3 s) {
CGLM_INLINE
bool
glm_uniscaled(mat4 m) {
vec3 s;
CGLM_ALIGN(8) vec3 s;
glm_decompose_scalev(m, s);
return glm_vec_eq_all(s);
}
@@ -468,8 +443,8 @@ glm_uniscaled(mat4 m) {
CGLM_INLINE
void
glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
vec4 t = {0.0f, 0.0f, 0.0f, 1.0f};
vec3 v;
CGLM_ALIGN(16) vec4 t = {0.0f, 0.0f, 0.0f, 1.0f};
CGLM_ALIGN(8) vec3 v;
glm_vec4_copy(m[0], r[0]);
glm_vec4_copy(m[1], r[1]);

View File

@@ -200,4 +200,16 @@ glm_aabb_radius(vec3 box[2]) {
return glm_aabb_size(box) * 0.5f;
}
/*!
* @brief computes center point of AABB
*
* @param[in] box bounding box
* @param[out] dest center of bounding box
*/
CGLM_INLINE
void
glm_aabb_center(vec3 box[2], vec3 dest) {
glm_vec_center(box[0], box[1], dest);
}
#endif /* cglm_box_h */

View File

@@ -97,6 +97,20 @@ CGLM_EXPORT
void
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s);
/* affine-mat */
CGLM_EXPORT
void
glmc_mul(mat4 m1, mat4 m2, mat4 dest);
CGLM_EXPORT
void
glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest);
CGLM_EXPORT
void
glmc_inv_tr(mat4 mat);
#ifdef __cplusplus
}
#endif

View File

@@ -32,6 +32,30 @@ glmc_aabb_crop_until(vec3 box[2],
vec3 clampBox[2],
vec3 dest[2]);
CGLM_EXPORT
bool
glmc_aabb_frustum(vec3 box[2], vec4 planes[6]);
CGLM_EXPORT
void
glmc_aabb_invalidate(vec3 box[2]);
CGLM_EXPORT
bool
glmc_aabb_isvalid(vec3 box[2]);
CGLM_EXPORT
float
glmc_aabb_size(vec3 box[2]);
CGLM_EXPORT
float
glmc_aabb_radius(vec3 box[2]);
CGLM_EXPORT
void
glmc_aabb_center(vec3 box[2], vec3 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -33,6 +33,26 @@ glmc_ortho(float left,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb(vec3 box[2], mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_ortho_default_s(float aspect, float size, mat4 dest);
CGLM_EXPORT
void
glmc_perspective(float fovy,
@@ -41,6 +61,14 @@ glmc_perspective(float fovy,
float farVal,
mat4 dest);
CGLM_EXPORT
void
glmc_perspective_default(float aspect, mat4 dest);
CGLM_EXPORT
void
glmc_perspective_resize(float aspect, mat4 proj);
CGLM_EXPORT
void
glmc_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest);
@@ -53,6 +81,58 @@ CGLM_EXPORT
void
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest);
CGLM_EXPORT
void
glmc_persp_decomp(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal,
float * __restrict top,
float * __restrict bottom,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decompv(mat4 proj, float dest[6]);
CGLM_EXPORT
void
glmc_persp_decomp_x(mat4 proj,
float * __restrict left,
float * __restrict right);
CGLM_EXPORT
void
glmc_persp_decomp_y(mat4 proj,
float * __restrict top,
float * __restrict bottom);
CGLM_EXPORT
void
glmc_persp_decomp_z(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal);
CGLM_EXPORT
void
glmc_persp_decomp_far(mat4 proj, float * __restrict farVal);
CGLM_EXPORT
void
glmc_persp_decomp_near(mat4 proj, float * __restrict nearVal);
CGLM_EXPORT
float
glmc_persp_fovy(mat4 proj);
CGLM_EXPORT
float
glmc_persp_aspect(mat4 proj);
CGLM_EXPORT
void
glmc_persp_sizes(mat4 proj, float fovy, vec4 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -40,6 +40,10 @@ CGLM_EXPORT
void
glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest);
CGLM_EXPORT
void
glmc_mat3_quat(mat3 m, versor dest);
CGLM_EXPORT
void
glmc_mat3_scale(mat3 m, float s);

View File

@@ -53,6 +53,10 @@ CGLM_EXPORT
void
glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest);
CGLM_EXPORT
void
glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest);
CGLM_EXPORT
void
glmc_mat4_quat(mat4 m, versor dest);
@@ -85,6 +89,10 @@ CGLM_EXPORT
void
glmc_mat4_inv_precise(mat4 mat, mat4 dest);
CGLM_EXPORT
void
glmc_mat4_inv_fast(mat4 mat, mat4 dest);
CGLM_EXPORT
void
glmc_mat4_swap_col(mat4 mat, int col1, int col2);

View File

@@ -136,6 +136,10 @@ CGLM_EXPORT
void
glmc_vec_rotate_m4(mat4 m, vec3 v, vec3 dest);
CGLM_EXPORT
void
glmc_vec_rotate_m3(mat3 m, vec3 v, vec3 dest);
CGLM_EXPORT
void
glmc_vec_proj(vec3 a, vec3 b, vec3 dest);

View File

@@ -332,7 +332,7 @@ glm_lookat(vec3 eye,
vec3 center,
vec3 up,
mat4 dest) {
vec3 f, u, s;
CGLM_ALIGN(8) vec3 f, u, s;
glm_vec_sub(center, eye, f);
glm_vec_normalize(f);
@@ -372,7 +372,7 @@ glm_lookat(vec3 eye,
CGLM_INLINE
void
glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
vec3 target;
CGLM_ALIGN(8) vec3 target;
glm_vec_add(eye, dir, target);
glm_lookat(eye, target, up, dest);
}
@@ -390,7 +390,7 @@ glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
CGLM_INLINE
void
glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
vec3 up;
CGLM_ALIGN(8) vec3 up;
glm_vec_ortho(dir, up);
glm_look(eye, dir, up, dest);
}

View File

@@ -81,7 +81,7 @@ glm_mat3_copy(mat3 mat, mat3 dest) {
CGLM_INLINE
void
glm_mat3_identity(mat3 mat) {
mat3 t = GLM_MAT3_IDENTITY_INIT;
CGLM_ALIGN(16) mat3 t = GLM_MAT3_IDENTITY_INIT;
glm_mat3_copy(t, mat);
}
@@ -155,7 +155,7 @@ glm_mat3_transpose_to(mat3 m, mat3 dest) {
CGLM_INLINE
void
glm_mat3_transpose(mat3 m) {
mat3 tmp;
CGLM_ALIGN(16) mat3 tmp;
tmp[0][1] = m[1][0];
tmp[0][2] = m[2][0];
@@ -189,9 +189,9 @@ glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
/*!
* @brief convert mat4's rotation part to quaternion
* @brief convert mat3 to quaternion
*
* @param[in] m left matrix
* @param[in] m rotation matrix
* @param[out] dest destination quaternion
*/
CGLM_INLINE

View File

@@ -139,7 +139,7 @@ glm_mat4_copy(mat4 mat, mat4 dest) {
CGLM_INLINE
void
glm_mat4_identity(mat4 mat) {
mat4 t = GLM_MAT4_IDENTITY_INIT;
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
glm_mat4_copy(t, mat);
}
@@ -323,7 +323,7 @@ glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
/*!
* @brief convert mat4's rotation part to quaternion
*
* @param[in] m left matrix
* @param[in] m affine matrix
* @param[out] dest destination quaternion
*/
CGLM_INLINE
@@ -370,20 +370,20 @@ glm_mat4_quat(mat4 m, versor dest) {
}
/*!
* @brief multiply vector with mat4's mat3 part(rotation)
* @brief multiply vector with mat4
*
* @param[in] m mat4(affine transform)
* @param[in] v vec3
* @param[out] dest vec3
* @param[in] last 4th item to make it vec4
* @param[out] dest result vector (vec3)
*/
CGLM_INLINE
void
glm_mat4_mulv3(mat4 m, vec3 v, vec3 dest) {
vec3 res;
res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2];
res[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2];
res[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2];
glm_vec_copy(res, dest);
glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) {
vec4 res;
glm_vec4(v, last, res);
glm_mat4_mulv(m, res, res);
glm_vec3(res, dest);
}
/*!
@@ -586,7 +586,7 @@ glm_mat4_inv_fast(mat4 mat, mat4 dest) {
CGLM_INLINE
void
glm_mat4_swap_col(mat4 mat, int col1, int col2) {
vec4 tmp;
CGLM_ALIGN(16) vec4 tmp;
glm_vec4_copy(mat[col1], tmp);
glm_vec4_copy(mat[col2], mat[col1]);
glm_vec4_copy(tmp, mat[col2]);
@@ -602,7 +602,7 @@ glm_mat4_swap_col(mat4 mat, int col1, int col2) {
CGLM_INLINE
void
glm_mat4_swap_row(mat4 mat, int row1, int row2) {
vec4 tmp;
CGLM_ALIGN(16) vec4 tmp;
tmp[0] = mat[0][row1];
tmp[1] = mat[1][row1];
tmp[2] = mat[2][row1];

View File

@@ -100,7 +100,7 @@ glm_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
CGLM_INLINE
void
glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
vec4 pos4, vone = GLM_VEC4_ONE_INIT;
CGLM_ALIGN(16) vec4 pos4, vone = GLM_VEC4_ONE_INIT;
glm_vec4(pos, 1.0f, pos4);

View File

@@ -99,7 +99,7 @@ glm_translate(mat4 m, vec3 v);
CGLM_INLINE
void
glm_quat_identity(versor q) {
versor v = GLM_QUAT_IDENTITY_INIT;
CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT;
glm_vec4_copy(v, q);
}
@@ -131,7 +131,7 @@ glm_quat_init(versor q, float x, float y, float z, float w) {
CGLM_INLINE
void
glm_quatv(versor q, float angle, vec3 axis) {
vec3 k;
CGLM_ALIGN(8) vec3 k;
float a, c, s;
a = angle * 0.5f;
@@ -158,7 +158,7 @@ glm_quatv(versor q, float angle, vec3 axis) {
CGLM_INLINE
void
glm_quat(versor q, float angle, float x, float y, float z) {
vec3 axis = {x, y, z};
CGLM_ALIGN(8) vec3 axis = {x, y, z};
glm_quatv(q, angle, axis);
}
@@ -267,7 +267,7 @@ glm_quat_conjugate(versor q, versor dest) {
CGLM_INLINE
void
glm_quat_inv(versor q, versor dest) {
versor conj;
CGLM_ALIGN(8) versor conj;
glm_quat_conjugate(q, conj);
glm_vec4_scale(conj, 1.0f / glm_vec4_norm2(q), dest);
}
@@ -603,7 +603,7 @@ glm_quat_lerp(versor from, versor to, float t, versor dest) {
CGLM_INLINE
void
glm_quat_slerp(versor from, versor to, float t, versor dest) {
vec4 q1, q2;
CGLM_ALIGN(16) vec4 q1, q2;
float cosTheta, sinTheta, angle;
cosTheta = glm_quat_dot(from, to);
@@ -646,7 +646,7 @@ glm_quat_slerp(versor from, versor to, float t, versor dest) {
CGLM_INLINE
void
glm_quat_look(vec3 eye, versor ori, mat4 dest) {
vec4 t;
CGLM_ALIGN(16) vec4 t;
/* orientation */
glm_quat_mat4t(ori, dest);
@@ -668,7 +668,7 @@ glm_quat_look(vec3 eye, versor ori, mat4 dest) {
CGLM_INLINE
void
glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
vec3 axis;
CGLM_ALIGN(8) vec3 axis;
float dot, angle;
dot = glm_vec_dot(dir, fwd);
@@ -702,7 +702,7 @@ glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
CGLM_INLINE
void
glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest) {
vec3 dir;
CGLM_ALIGN(8) vec3 dir;
glm_vec_sub(to, from, dir);
glm_quat_for(dir, fwd, up, dest);
}
@@ -717,9 +717,9 @@ glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest) {
CGLM_INLINE
void
glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
versor p;
vec3 u, v1, v2;
float s;
CGLM_ALIGN(16) versor p;
CGLM_ALIGN(8) vec3 u, v1, v2;
float s;
glm_quat_normalize_to(q, p);
glm_quat_imag(p, u);
@@ -745,7 +745,7 @@ glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
CGLM_INLINE
void
glm_quat_rotate(mat4 m, versor q, mat4 dest) {
mat4 rot;
CGLM_ALIGN(16) mat4 rot;
glm_quat_mat4(q, rot);
glm_mul_rot(m, rot, dest);
}
@@ -760,7 +760,7 @@ glm_quat_rotate(mat4 m, versor q, mat4 dest) {
CGLM_INLINE
void
glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) {
vec3 pivotInv;
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec_inv_to(pivot, pivotInv);
@@ -784,12 +784,11 @@ glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) {
CGLM_INLINE
void
glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) {
vec3 pivotInv;
CGLM_ALIGN(8) vec3 pivotInv;
glm_vec_inv_to(pivot, pivotInv);
glm_mat4_identity(m);
glm_vec_copy(pivot, m[3]);
glm_translate_make(m, pivot);
glm_quat_rotate(m, q, m);
glm_translate(m, pivotInv);
}

View File

@@ -454,8 +454,7 @@ glm_vec_inv(vec3 v) {
CGLM_INLINE
void
glm_vec_inv_to(vec3 v, vec3 dest) {
glm_vec_copy(v, dest);
glm_vec_flipsign(dest);
glm_vec_flipsign_to(v, dest);
}
/*!

View File

@@ -10,6 +10,6 @@
#define CGLM_VERSION_MAJOR 0
#define CGLM_VERSION_MINOR 4
#define CGLM_VERSION_PATCH 5
#define CGLM_VERSION_PATCH 6
#endif /* cglm_version_h */

View File

@@ -133,3 +133,21 @@ void
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s) {
glm_decompose(m, t, r, s);
}
CGLM_EXPORT
void
glmc_mul(mat4 m1, mat4 m2, mat4 dest) {
glm_mul(m1, m2, dest);
}
CGLM_EXPORT
void
glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest) {
glm_mul_rot(m1, m2, dest);
}
CGLM_EXPORT
void
glmc_inv_tr(mat4 mat) {
glm_inv_tr(mat);
}

View File

@@ -34,3 +34,39 @@ glmc_aabb_crop_until(vec3 box[2],
vec3 dest[2]) {
glm_aabb_crop_until(box, cropBox, clampBox, dest);
}
CGLM_EXPORT
bool
glmc_aabb_frustum(vec3 box[2], vec4 planes[6]) {
return glm_aabb_frustum(box, planes);
}
CGLM_EXPORT
void
glmc_aabb_invalidate(vec3 box[2]) {
glm_aabb_invalidate(box);
}
CGLM_EXPORT
bool
glmc_aabb_isvalid(vec3 box[2]) {
return glm_aabb_isvalid(box);
}
CGLM_EXPORT
float
glmc_aabb_size(vec3 box[2]) {
return glm_aabb_size(box);
}
CGLM_EXPORT
float
glmc_aabb_radius(vec3 box[2]) {
return glm_aabb_radius(box);
}
CGLM_EXPORT
void
glmc_aabb_center(vec3 box[2], vec3 dest) {
glm_aabb_center(box, dest);
}

114
src/cam.c
View File

@@ -44,6 +44,36 @@ glmc_ortho(float left,
dest);
}
CGLM_EXPORT
void
glmc_ortho_aabb(vec3 box[2], mat4 dest) {
glm_ortho_aabb(box, dest);
}
CGLM_EXPORT
void
glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) {
glm_ortho_aabb_p(box, padding, dest);
}
CGLM_EXPORT
void
glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
glm_ortho_aabb_pz(box, padding, dest);
}
CGLM_EXPORT
void
glmc_ortho_default(float aspect, mat4 dest) {
glm_ortho_default(aspect, dest);
}
CGLM_EXPORT
void
glmc_ortho_default_s(float aspect, float size, mat4 dest) {
glm_ortho_default_s(aspect, size, dest);
}
CGLM_EXPORT
void
glmc_perspective(float fovy,
@@ -58,6 +88,18 @@ glmc_perspective(float fovy,
dest);
}
CGLM_EXPORT
void
glmc_perspective_default(float aspect, mat4 dest) {
glm_perspective_default(aspect, dest);
}
CGLM_EXPORT
void
glmc_perspective_resize(float aspect, mat4 proj) {
glm_perspective_resize(aspect, proj);
}
CGLM_EXPORT
void
glmc_lookat(vec3 eye,
@@ -78,3 +120,75 @@ void
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
glm_look_anyup(eye, dir, dest);
}
CGLM_EXPORT
void
glmc_persp_decomp(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal,
float * __restrict top,
float * __restrict bottom,
float * __restrict left,
float * __restrict right) {
glm_persp_decomp(proj, nearVal, farVal, top, bottom, left, right);
}
CGLM_EXPORT
void
glmc_persp_decompv(mat4 proj, float dest[6]) {
glm_persp_decompv(proj, dest);
}
CGLM_EXPORT
void
glmc_persp_decomp_x(mat4 proj,
float * __restrict left,
float * __restrict right) {
glm_persp_decomp_x(proj, left, right);
}
CGLM_EXPORT
void
glmc_persp_decomp_y(mat4 proj,
float * __restrict top,
float * __restrict bottom) {
glm_persp_decomp_y(proj, top, bottom);
}
CGLM_EXPORT
void
glmc_persp_decomp_z(mat4 proj,
float * __restrict nearVal,
float * __restrict farVal) {
glm_persp_decomp_z(proj, nearVal, farVal);
}
CGLM_EXPORT
void
glmc_persp_decomp_far(mat4 proj, float * __restrict farVal) {
glm_persp_decomp_far(proj, farVal);
}
CGLM_EXPORT
void
glmc_persp_decomp_near(mat4 proj, float * __restrict nearVal) {
glm_persp_decomp_near(proj, nearVal);
}
CGLM_EXPORT
float
glmc_persp_fovy(mat4 proj) {
return glm_persp_fovy(proj);
}
CGLM_EXPORT
float
glmc_persp_aspect(mat4 proj) {
return glm_persp_aspect(proj);
}
CGLM_EXPORT
void
glmc_persp_sizes(mat4 proj, float fovy, vec4 dest) {
glm_persp_sizes(proj, fovy, dest);
}

View File

@@ -44,6 +44,12 @@ glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
glm_mat3_mulv(m, v, dest);
}
CGLM_EXPORT
void
glmc_mat3_quat(mat3 m, versor dest) {
glm_mat3_quat(m, dest);
}
CGLM_EXPORT
void
glmc_mat3_scale(mat3 m, float s) {

View File

@@ -62,6 +62,12 @@ glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
glm_mat4_mulv(m, v, dest);
}
CGLM_EXPORT
void
glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) {
glm_mat4_mulv3(m, v, last, dest);
}
CGLM_EXPORT
void
glmc_mat4_quat(mat4 m, versor dest) {
@@ -110,6 +116,12 @@ glmc_mat4_inv_precise(mat4 mat, mat4 dest) {
glm_mat4_inv_precise(mat, dest);
}
CGLM_EXPORT
void
glmc_mat4_inv_fast(mat4 mat, mat4 dest) {
glm_mat4_inv_fast(mat, dest);
}
CGLM_EXPORT
void
glmc_mat4_swap_col(mat4 mat, int col1, int col2) {

View File

@@ -188,6 +188,12 @@ glmc_vec_rotate_m4(mat4 m, vec3 v, vec3 dest) {
glm_vec_rotate_m4(m, v, dest);
}
CGLM_EXPORT
void
glmc_vec_rotate_m3(mat3 m, vec3 v, vec3 dest) {
glm_vec_rotate_m3(m, v, dest);
}
CGLM_EXPORT
void
glmc_vec_proj(vec3 a, vec3 b, vec3 dest) {