mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
16 Commits
interpolat
...
v0.4.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08479f38ce | ||
|
|
dadae4b773 | ||
|
|
20360f2296 | ||
|
|
aa2b0f2631 | ||
|
|
280ac72fd8 | ||
|
|
7405d5e1d0 | ||
|
|
eefafefbae | ||
|
|
b9021978cb | ||
|
|
3fd12032e6 | ||
|
|
59ee8c1fd2 | ||
|
|
b00f2b9ccc | ||
|
|
d3c50147cb | ||
|
|
98da3daf82 | ||
|
|
2e1790ccf9 | ||
|
|
cc5f533fc9 | ||
|
|
2d63d7e0cd |
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.4.8], [info@recp.me])
|
AC_INIT([cglm], [0.4.9], [info@recp.me])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||||
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'0.4.8'
|
version = u'0.4.9'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.4.8'
|
release = u'0.4.9'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Functions:
|
|||||||
|
|
||||||
1. :c:func:`glm_mat3_copy`
|
1. :c:func:`glm_mat3_copy`
|
||||||
#. :c:func:`glm_mat3_identity`
|
#. :c:func:`glm_mat3_identity`
|
||||||
|
#. :c:func:`glm_mat3_identity_array`
|
||||||
#. :c:func:`glm_mat3_mul`
|
#. :c:func:`glm_mat3_mul`
|
||||||
#. :c:func:`glm_mat3_transpose_to`
|
#. :c:func:`glm_mat3_transpose_to`
|
||||||
#. :c:func:`glm_mat3_transpose`
|
#. :c:func:`glm_mat3_transpose`
|
||||||
@@ -49,6 +50,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[out]* **mat** matrix
|
| *[out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3_identity_array(mat3 * __restrict mat, size_t count)
|
||||||
|
|
||||||
|
make given matrix array's each element identity matrix
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of matrices
|
||||||
|
|
||||||
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ Functions:
|
|||||||
1. :c:func:`glm_mat4_ucopy`
|
1. :c:func:`glm_mat4_ucopy`
|
||||||
#. :c:func:`glm_mat4_copy`
|
#. :c:func:`glm_mat4_copy`
|
||||||
#. :c:func:`glm_mat4_identity`
|
#. :c:func:`glm_mat4_identity`
|
||||||
|
#. :c:func:`glm_mat4_identity_array`
|
||||||
#. :c:func:`glm_mat4_pick3`
|
#. :c:func:`glm_mat4_pick3`
|
||||||
#. :c:func:`glm_mat4_pick3t`
|
#. :c:func:`glm_mat4_pick3t`
|
||||||
#. :c:func:`glm_mat4_ins3`
|
#. :c:func:`glm_mat4_ins3`
|
||||||
@@ -69,6 +70,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[out]* **mat** matrix
|
| *[out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4_identity_array(mat4 * __restrict mat, size_t count)
|
||||||
|
|
||||||
|
make given matrix array's each element identity matrix
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of matrices
|
||||||
|
|
||||||
.. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest)
|
.. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest)
|
||||||
|
|
||||||
copy upper-left of mat4 to mat3
|
copy upper-left of mat4 to mat3
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ Macros:
|
|||||||
Functions:
|
Functions:
|
||||||
|
|
||||||
1. :c:func:`glm_quat_identity`
|
1. :c:func:`glm_quat_identity`
|
||||||
|
#. :c:func:`glm_quat_identity_array`
|
||||||
#. :c:func:`glm_quat_init`
|
#. :c:func:`glm_quat_init`
|
||||||
#. :c:func:`glm_quat`
|
#. :c:func:`glm_quat`
|
||||||
#. :c:func:`glm_quatv`
|
#. :c:func:`glm_quatv`
|
||||||
@@ -70,6 +71,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **q** quaternion
|
| *[in, out]* **q** quaternion
|
||||||
|
|
||||||
|
.. c:function:: void glm_quat_identity_array(versor * __restrict q, size_t count)
|
||||||
|
|
||||||
|
| make given quaternion array's each element identity quaternion
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **q** quat array (must be aligned (16) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of quaternions
|
||||||
|
|
||||||
.. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w)
|
.. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w)
|
||||||
|
|
||||||
| inits quaternion with given values
|
| inits quaternion with given values
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ glm_inv_tr(mat4 mat) {
|
|||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_inv_tr_sse2(mat);
|
glm_inv_tr_sse2(mat);
|
||||||
#else
|
#else
|
||||||
CGLM_ALIGN(16) mat3 r;
|
CGLM_ALIGN_MAT mat3 r;
|
||||||
CGLM_ALIGN(16) vec3 t;
|
CGLM_ALIGN(16) vec3 t;
|
||||||
|
|
||||||
/* rotate */
|
/* rotate */
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ glm_scale_uni(mat4 m, float s) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
||||||
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -269,7 +269,7 @@ glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
||||||
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -294,7 +294,7 @@ glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_z(mat4 m, float angle, mat4 dest) {
|
glm_rotate_z(mat4 m, float angle, mat4 dest) {
|
||||||
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -351,7 +351,7 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate(mat4 m, float angle, vec3 axis) {
|
glm_rotate(mat4 m, float angle, vec3 axis) {
|
||||||
CGLM_ALIGN(16) mat4 rot;
|
CGLM_ALIGN_MAT mat4 rot;
|
||||||
glm_rotate_make(rot, angle, axis);
|
glm_rotate_make(rot, angle, axis);
|
||||||
glm_mul_rot(m, rot, m);
|
glm_mul_rot(m, rot, m);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c), Recep Aslantas.
|
|
||||||
*
|
|
||||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
|
||||||
* Full license can be found in the LICENSE file
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef cglm_bezier_h
|
|
||||||
#define cglm_bezier_h
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief cubic bezier interpolation
|
|
||||||
*
|
|
||||||
* @param[in] t time between 0 and 1
|
|
||||||
* @param[in] p0 begin point
|
|
||||||
* @param[in] c0 control point 1
|
|
||||||
* @param[in] c1 control point 2
|
|
||||||
* @param[in] p1 end point
|
|
||||||
*
|
|
||||||
* @return B(s)
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
float
|
|
||||||
glm_bezier_cubic(float t, float p0, float c0, float c1, float p1) {
|
|
||||||
float s, ss, tt;
|
|
||||||
|
|
||||||
s = 1.0f - t;
|
|
||||||
ss = s * s;
|
|
||||||
tt = t * t;
|
|
||||||
|
|
||||||
return p0 * ss * s + 3.0f * c0 * t * ss + 3.0f * c1 * tt * s + p1 * tt * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief cubic bezier interpolation for vec3
|
|
||||||
*
|
|
||||||
* @param[in] t time between 0 and 1
|
|
||||||
* @param[in] p0 begin point
|
|
||||||
* @param[in] c0 control point 1
|
|
||||||
* @param[in] c1 control point 2
|
|
||||||
* @param[in] p1 end point
|
|
||||||
* @param[in] dest destination
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
void
|
|
||||||
glm_bezier_cubicv3(float t, vec3 p0, vec3 c0, vec3 c1, vec3 p1, vec3 dest) {
|
|
||||||
vec3 Bs, tmp0, tmp1, tmp2;
|
|
||||||
float s, ss, tt;
|
|
||||||
|
|
||||||
s = 1.0f - t;
|
|
||||||
ss = s * s;
|
|
||||||
tt = t * t;
|
|
||||||
|
|
||||||
glm_vec_scale(p0, ss * s, Bs);
|
|
||||||
glm_vec_scale(c0, 3.0f * t * ss, tmp0);
|
|
||||||
glm_vec_scale(c1, 3.0f * tt * s, tmp1);
|
|
||||||
glm_vec_scale(p1, tt * t, tmp2);
|
|
||||||
|
|
||||||
glm_vec_add(Bs, tmp0, Bs);
|
|
||||||
glm_vec_add(Bs, tmp1, Bs);
|
|
||||||
glm_vec_add(Bs, tmp2, Bs);
|
|
||||||
|
|
||||||
glm_vec_copy(Bs, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief cubic hermite interpolation
|
|
||||||
*
|
|
||||||
* @param[in] t time between 0 and 1
|
|
||||||
* @param[in] p0 begin point
|
|
||||||
* @param[in] t0 tangent 1
|
|
||||||
* @param[in] t1 tangent 2
|
|
||||||
* @param[in] p1 end point
|
|
||||||
*
|
|
||||||
* @return B(s)
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
float
|
|
||||||
glm_hermite_cubic(float t, float p0, float t0, float t1, float p1) {
|
|
||||||
float tt, ttt;
|
|
||||||
|
|
||||||
tt = t * t;
|
|
||||||
ttt = tt * t;
|
|
||||||
|
|
||||||
return p0 * (2.0f * ttt - 3.0f * tt + 1)
|
|
||||||
+ t0 * (ttt - 2.0f * tt + t)
|
|
||||||
+ p1 * (3.0f * tt - 2.0f * ttt)
|
|
||||||
- t1 * (ttt - tt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief cubic hermite interpolation for vec3
|
|
||||||
*
|
|
||||||
* @param[in] t time between 0 and 1
|
|
||||||
* @param[in] p0 begin point
|
|
||||||
* @param[in] t0 tangent 1
|
|
||||||
* @param[in] t1 tangent 2
|
|
||||||
* @param[in] p1 end point
|
|
||||||
* @param[in] dest destination
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
void
|
|
||||||
glm_hermite_cubicv3(float t, vec3 p0, vec3 t0, vec3 t1, vec3 p1, vec3 dest) {
|
|
||||||
vec3 Hs, tmp0, tmp1, tmp2;
|
|
||||||
float tt, ttt;
|
|
||||||
|
|
||||||
tt = t * t;
|
|
||||||
ttt = tt * t;
|
|
||||||
|
|
||||||
glm_vec_scale(p0, 2.0f * ttt - 3.0f * tt + 1, Hs);
|
|
||||||
glm_vec_scale(t0, ttt - 2.0f * tt + t, tmp0);
|
|
||||||
glm_vec_scale(p1, 3.0f * tt - 2.0f * ttt, tmp1);
|
|
||||||
glm_vec_scale(t1, ttt - tt, tmp2);
|
|
||||||
|
|
||||||
glm_vec_add(Hs, tmp0, Hs);
|
|
||||||
glm_vec_add(Hs, tmp1, Hs);
|
|
||||||
glm_vec_add(Hs, tmp2, Hs);
|
|
||||||
|
|
||||||
glm_vec_copy(Hs, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* cglm_bezier_h */
|
|
||||||
@@ -24,6 +24,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat3_identity(mat3 mat);
|
glmc_mat3_identity(mat3 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat4_identity(mat4 mat);
|
glmc_mat4_identity(mat4 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_pick3(mat4 mat, mat3 dest);
|
glmc_mat4_pick3(mat4 mat, mat3 dest);
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_quat_identity(versor q);
|
glmc_quat_identity(versor q);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_quat_identity_array(versor * __restrict q, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_init(versor q, float x, float y, float z, float w);
|
glmc_quat_init(versor q, float x, float y, float z, float w);
|
||||||
|
|||||||
@@ -198,26 +198,15 @@ glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_ortho_default(float aspect,
|
glm_ortho_default(float aspect, mat4 dest) {
|
||||||
mat4 dest) {
|
|
||||||
if (aspect >= 1.0f) {
|
if (aspect >= 1.0f) {
|
||||||
glm_ortho(-1.0f * aspect,
|
glm_ortho(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||||
1.0f * aspect,
|
|
||||||
-1.0f,
|
|
||||||
1.0f,
|
|
||||||
-100.0f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm_ortho(-1.0f,
|
aspect = 1.0f / aspect;
|
||||||
1.0f,
|
|
||||||
-1.0f / aspect,
|
glm_ortho(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||||
1.0f / aspect,
|
|
||||||
-100.0f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -291,13 +280,8 @@ glm_perspective(float fovy,
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_default(float aspect,
|
glm_perspective_default(float aspect, mat4 dest) {
|
||||||
mat4 dest) {
|
glm_perspective(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
glm_perspective((float)CGLM_PI_4,
|
|
||||||
aspect,
|
|
||||||
0.01f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -310,8 +294,7 @@ glm_perspective_default(float aspect,
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_resize(float aspect,
|
glm_perspective_resize(float aspect, mat4 proj) {
|
||||||
mat4 proj) {
|
|
||||||
if (proj[0][0] == 0.0f)
|
if (proj[0][0] == 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,5 @@
|
|||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "sphere.h"
|
#include "sphere.h"
|
||||||
#include "ease.h"
|
#include "ease.h"
|
||||||
#include "bezier.h"
|
|
||||||
|
|
||||||
#endif /* cglm_h */
|
#endif /* cglm_h */
|
||||||
|
|||||||
@@ -19,19 +19,19 @@ glm_ease_linear(float t) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_ease_sine_in(float t) {
|
glm_ease_sine_in(float t) {
|
||||||
return sinf((t - 1.0f) * CGLM_PI_2) + 1.0f;
|
return sinf((t - 1.0f) * GLM_PI_2f) + 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_ease_sine_out(float t) {
|
glm_ease_sine_out(float t) {
|
||||||
return sinf(t * CGLM_PI_2);
|
return sinf(t * GLM_PI_2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_ease_sine_inout(float t) {
|
glm_ease_sine_inout(float t) {
|
||||||
return 0.5f * (1.0f - cosf(t * CGLM_PI));
|
return 0.5f * (1.0f - cosf(t * GLM_PIf));
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
@@ -254,13 +254,13 @@ glm_ease_back_inout(float t) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_ease_elast_in(float t) {
|
glm_ease_elast_in(float t) {
|
||||||
return sinf(13.0f * CGLM_PI_2 * t) * powf(2.0f, 10.0f * (t - 1.0f));
|
return sinf(13.0f * GLM_PI_2f * t) * powf(2.0f, 10.0f * (t - 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_ease_elast_out(float t) {
|
glm_ease_elast_out(float t) {
|
||||||
return sinf(-13.0f * CGLM_PI_2 * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f;
|
return sinf(-13.0f * GLM_PI_2f * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
@@ -271,10 +271,10 @@ glm_ease_elast_inout(float t) {
|
|||||||
a = 2.0f * t;
|
a = 2.0f * t;
|
||||||
|
|
||||||
if (t < 0.5f)
|
if (t < 0.5f)
|
||||||
return 0.5f * sinf(13.0f * CGLM_PI_2 * a)
|
return 0.5f * sinf(13.0f * GLM_PI_2f * a)
|
||||||
* powf(2.0f, 10.0f * (a - 1.0f));
|
* powf(2.0f, 10.0f * (a - 1.0f));
|
||||||
|
|
||||||
return 0.5f * (sinf(-13.0f * CGLM_PI_2 * a)
|
return 0.5f * (sinf(-13.0f * GLM_PI_2f * a)
|
||||||
* powf(2.0f, -10.0f * (a - 1.0f)) + 2.0f);
|
* powf(2.0f, -10.0f * (a - 1.0f)) + 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ glm_euler_angles(mat4 m, vec3 dest) {
|
|||||||
thetaZ = atan2f(-m10, m00);
|
thetaZ = atan2f(-m10, m00);
|
||||||
} else { /* m20 == -1 */
|
} else { /* m20 == -1 */
|
||||||
/* Not a unique solution */
|
/* Not a unique solution */
|
||||||
thetaY = -CGLM_PI_2;
|
thetaY = -GLM_PI_2f;
|
||||||
thetaX = -atan2f(m01, m11);
|
thetaX = -atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
}
|
}
|
||||||
} else { /* m20 == +1 */
|
} else { /* m20 == +1 */
|
||||||
thetaY = CGLM_PI_2;
|
thetaY = GLM_PI_2f;
|
||||||
thetaX = atan2f(m01, m11);
|
thetaX = atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest);
|
CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_identity(mat3 mat);
|
CGLM_INLINE void glm_mat3_identity(mat3 mat);
|
||||||
|
CGLM_INLINE void glm_mat3_identity_array(mat3 * restrict mat, size_t count);
|
||||||
CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
|
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_transpose(mat3 m);
|
CGLM_INLINE void glm_mat3_transpose(mat3 m);
|
||||||
@@ -81,10 +82,29 @@ glm_mat3_copy(mat3 mat, mat3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3_identity(mat3 mat) {
|
glm_mat3_identity(mat3 mat) {
|
||||||
CGLM_ALIGN(16) mat3 t = GLM_MAT3_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
|
||||||
glm_mat3_copy(t, mat);
|
glm_mat3_copy(t, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix array's each element identity matrix
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix array (must be aligned (16/32)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of matrices
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3_identity_array(mat3 * __restrict mat, size_t count) {
|
||||||
|
CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_mat3_copy(t, mat[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
@@ -155,7 +175,7 @@ glm_mat3_transpose_to(mat3 m, mat3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3_transpose(mat3 m) {
|
glm_mat3_transpose(mat3 m) {
|
||||||
CGLM_ALIGN(16) mat3 tmp;
|
CGLM_ALIGN_MAT mat3 tmp;
|
||||||
|
|
||||||
tmp[0][1] = m[1][0];
|
tmp[0][1] = m[1][0];
|
||||||
tmp[0][2] = m[2][0];
|
tmp[0][2] = m[2][0];
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat4_identity(mat4 mat);
|
CGLM_INLINE void glm_mat4_identity(mat4 mat);
|
||||||
|
CGLM_INLINE void glm_mat4_identity_array(mat4 * restrict mat, size_t count);
|
||||||
CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest);
|
CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest);
|
CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest);
|
||||||
@@ -139,10 +140,29 @@ glm_mat4_copy(mat4 mat, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_identity(mat4 mat) {
|
glm_mat4_identity(mat4 mat) {
|
||||||
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
glm_mat4_copy(t, mat);
|
glm_mat4_copy(t, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix array's each element identity matrix
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix array (must be aligned (16/32)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of matrices
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_identity_array(mat4 * __restrict mat, size_t count) {
|
||||||
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_mat4_copy(t, mat[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy upper-left of mat4 to mat3
|
* @brief copy upper-left of mat4 to mat3
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -103,6 +103,25 @@ glm_quat_identity(versor q) {
|
|||||||
glm_vec4_copy(v, q);
|
glm_vec4_copy(v, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given quaternion array's each element identity quaternion
|
||||||
|
*
|
||||||
|
* @param[in, out] q quat array (must be aligned (16)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of quaternions
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_quat_identity_array(versor * __restrict q, size_t count) {
|
||||||
|
CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_vec4_copy(v, q[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief inits quaterion with raw values
|
* @brief inits quaterion with raw values
|
||||||
*
|
*
|
||||||
@@ -670,7 +689,7 @@ glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
|
|||||||
|
|
||||||
dot = glm_vec_dot(dir, fwd);
|
dot = glm_vec_dot(dir, fwd);
|
||||||
if (fabsf(dot + 1.0f) < 0.000001f) {
|
if (fabsf(dot + 1.0f) < 0.000001f) {
|
||||||
glm_quat_init(dest, up[0], up[1], up[2], CGLM_PI);
|
glm_quat_init(dest, up[0], up[1], up[2], GLM_PIf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -742,7 +761,7 @@ glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_rotate(mat4 m, versor q, mat4 dest) {
|
glm_quat_rotate(mat4 m, versor q, mat4 dest) {
|
||||||
CGLM_ALIGN(16) mat4 rot;
|
CGLM_ALIGN_MAT mat4 rot;
|
||||||
glm_quat_mat4(q, rot);
|
glm_quat_mat4(q, rot);
|
||||||
glm_mul_rot(m, rot, dest);
|
glm_mul_rot(m, rot, dest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,21 +27,24 @@ glm_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
||||||
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
||||||
|
|
||||||
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
|
/* 0x03: 0b00000011 */
|
||||||
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000000); /* l k j i l k j i */
|
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
|
||||||
|
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
|
||||||
|
|
||||||
/* f f f f a a a a */
|
/* f f f f a a a a */
|
||||||
/* g g g g c c c c */
|
/* h h h h c c c c */
|
||||||
/* e e e e b b b b */
|
/* e e e e b b b b */
|
||||||
y7 = _mm256_permute_ps(y0, 0b10101010);
|
/* g g g g d d d d */
|
||||||
y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0));
|
y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0));
|
||||||
|
y7 = _mm256_permutevar_ps(y0, _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2));
|
||||||
y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1));
|
y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1));
|
||||||
|
y9 = _mm256_permutevar_ps(y0, _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3));
|
||||||
|
|
||||||
glmm_store256(dest[0],
|
glmm_store256(dest[0],
|
||||||
_mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6),
|
_mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6),
|
||||||
_mm256_mul_ps(y4, y8)),
|
_mm256_mul_ps(y3, y7)),
|
||||||
_mm256_mul_ps(y5, y7)));
|
_mm256_add_ps(_mm256_mul_ps(y4, y8),
|
||||||
|
_mm256_mul_ps(y5, y9))));
|
||||||
|
|
||||||
/* n n n n i i i i */
|
/* n n n n i i i i */
|
||||||
/* p p p p k k k k */
|
/* p p p p k k k k */
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ glm_mat4_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
||||||
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
||||||
|
|
||||||
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
|
/* 0x03: 0b00000011 */
|
||||||
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000011); /* l k j i p o n m */
|
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
|
||||||
|
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
|
||||||
|
|
||||||
/* f f f f a a a a */
|
/* f f f f a a a a */
|
||||||
/* h h h h c c c c */
|
/* h h h h c c c c */
|
||||||
|
|||||||
@@ -26,18 +26,58 @@
|
|||||||
# define CGLM_ALIGN_IF(X) /* no alignment */
|
# define CGLM_ALIGN_IF(X) /* no alignment */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __AVX__
|
||||||
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(32)
|
||||||
|
#else
|
||||||
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef float vec2[2];
|
typedef float vec2[2];
|
||||||
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
||||||
typedef int ivec3[3];
|
typedef int ivec3[3];
|
||||||
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
||||||
|
|
||||||
|
#ifdef __AVX__
|
||||||
|
typedef CGLM_ALIGN_IF(32) vec3 mat3[3];
|
||||||
|
typedef CGLM_ALIGN_IF(32) vec4 mat4[4];
|
||||||
|
#else
|
||||||
typedef vec3 mat3[3];
|
typedef vec3 mat3[3];
|
||||||
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef vec4 versor;
|
typedef vec4 versor;
|
||||||
|
|
||||||
#define CGLM_PI ((float)M_PI)
|
#define GLM_E 2.71828182845904523536028747135266250 /* e */
|
||||||
#define CGLM_PI_2 ((float)M_PI_2)
|
#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
|
||||||
#define CGLM_PI_4 ((float)M_PI_4)
|
#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
|
||||||
|
#define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */
|
||||||
|
#define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */
|
||||||
|
#define GLM_PI 3.14159265358979323846264338327950288 /* pi */
|
||||||
|
#define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
|
||||||
|
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
|
||||||
|
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
|
||||||
|
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
|
||||||
|
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
|
||||||
|
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
|
||||||
|
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
|
||||||
|
|
||||||
|
#define GLM_Ef ((float)GLM_E)
|
||||||
|
#define GLM_LOG2Ef ((float)GLM_LOG2E)
|
||||||
|
#define GLM_LOG10Ef ((float)GLM_LOG10E)
|
||||||
|
#define GLM_LN2f ((float)GLM_LN2)
|
||||||
|
#define GLM_LN10f ((float)GLM_LN10)
|
||||||
|
#define GLM_PIf ((float)GLM_PI)
|
||||||
|
#define GLM_PI_2f ((float)GLM_PI_2)
|
||||||
|
#define GLM_PI_4f ((float)GLM_PI_4)
|
||||||
|
#define GLM_1_PIf ((float)GLM_1_PI)
|
||||||
|
#define GLM_2_PIf ((float)GLM_2_PI)
|
||||||
|
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
|
||||||
|
#define GLM_SQRT2f ((float)GLM_SQRT2)
|
||||||
|
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
|
||||||
|
|
||||||
|
/* DEPRECATED! use GLM_PI and friends */
|
||||||
|
#define CGLM_PI GLM_PIf
|
||||||
|
#define CGLM_PI_2 GLM_PI_2f
|
||||||
|
#define CGLM_PI_4 GLM_PI_4f
|
||||||
|
|
||||||
#endif /* cglm_types_h */
|
#endif /* cglm_types_h */
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ glm_signf(float val) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_rad(float deg) {
|
glm_rad(float deg) {
|
||||||
return deg * CGLM_PI / 180.0f;
|
return deg * GLM_PIf / 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -69,7 +69,7 @@ glm_rad(float deg) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_deg(float rad) {
|
glm_deg(float rad) {
|
||||||
return rad * 180.0f / CGLM_PI;
|
return rad * 180.0f / GLM_PIf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -80,7 +80,7 @@ glm_deg(float rad) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_make_rad(float *deg) {
|
glm_make_rad(float *deg) {
|
||||||
*deg = *deg * CGLM_PI / 180.0f;
|
*deg = *deg * GLM_PIf / 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -91,7 +91,7 @@ glm_make_rad(float *deg) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_make_deg(float *rad) {
|
glm_make_deg(float *rad) {
|
||||||
*rad = *rad * 180.0f / CGLM_PI;
|
*rad = *rad * 180.0f / GLM_PIf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 4
|
#define CGLM_VERSION_MINOR 4
|
||||||
#define CGLM_VERSION_PATCH 8
|
#define CGLM_VERSION_PATCH 9
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ glmc_mat3_identity(mat3 mat) {
|
|||||||
glm_mat3_identity(mat);
|
glm_mat3_identity(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count) {
|
||||||
|
glm_mat3_identity_array(mat, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) {
|
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) {
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ glmc_mat4_identity(mat4 mat) {
|
|||||||
glm_mat4_identity(mat);
|
glm_mat4_identity(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count) {
|
||||||
|
glm_mat4_identity_array(mat, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_pick3(mat4 mat, mat3 dest) {
|
glmc_mat4_pick3(mat4 mat, mat3 dest) {
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
#include "../include/cglm/cglm.h"
|
#include "../include/cglm/cglm.h"
|
||||||
#include "../include/cglm/call.h"
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_identity(versor q) {
|
glmc_quat_identity(versor q) {
|
||||||
glm_quat_identity(q);
|
glm_quat_identity(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_quat_identity_array(versor * __restrict q, size_t count) {
|
||||||
|
glm_quat_identity_array(q, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_init(versor q, float x, float y, float z, float w) {
|
glmc_quat_init(versor q, float x, float y, float z, float w) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ test_affine(void **state) {
|
|||||||
mat4 t1, t2, t3, t4, t5;
|
mat4 t1, t2, t3, t4, t5;
|
||||||
|
|
||||||
/* test translate is postmultiplied */
|
/* test translate is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -21,16 +21,16 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test rotate is postmultiplied */
|
/* test rotate is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate(t2, M_PI_4, GLM_YUP);
|
glm_rotate(t2, GLM_PI_4f, GLM_YUP);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test scale is postmultiplied */
|
/* test scale is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
glm_scale_make(t4, (vec3){3, 5, 6});
|
glm_scale_make(t4, (vec3){3, 5, 6});
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t3, t5);
|
test_assert_mat4_eq(t3, t5);
|
||||||
|
|
||||||
/* test translate_x */
|
/* test translate_x */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 0, 0});
|
glm_translate_make(t2, (vec3){34, 0, 0});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -49,7 +49,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test translate_y */
|
/* test translate_y */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){0, 57, 0});
|
glm_translate_make(t2, (vec3){0, 57, 0});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -57,7 +57,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test translate_z */
|
/* test translate_z */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){0, 0, 36});
|
glm_translate_make(t2, (vec3){0, 0, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -65,43 +65,43 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test rotate_x */
|
/* test rotate_x */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){1, 0, 0});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){1, 0, 0});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_x(t2, M_PI_4, t2);
|
glm_rotate_x(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate_y */
|
/* test rotate_y */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 1, 0});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 1, 0});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_y(t2, M_PI_4, t2);
|
glm_rotate_y(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate_z */
|
/* test rotate_z */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_z(t2, M_PI_4, t2);
|
glm_rotate_z(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate */
|
/* test rotate */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
glmc_rotate(t2, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate(t2, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
|
|
||||||
test_assert_mat4_eq(t3, t2);
|
test_assert_mat4_eq(t3, t2);
|
||||||
|
|
||||||
/* test scale_uni */
|
/* test scale_uni */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
glm_scale_make(t4, (vec3){3, 3, 3});
|
glm_scale_make(t4, (vec3){3, 3, 3});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user