mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63e60f46f3 | ||
|
|
f28260e20b | ||
|
|
d232ab7865 | ||
|
|
e3b52100e3 | ||
|
|
bb8ff25752 | ||
|
|
98244da67f | ||
|
|
14f06a262f | ||
|
|
392565f920 | ||
|
|
120ae9ae99 | ||
|
|
a5f1ed32af | ||
|
|
010e887946 | ||
|
|
6e501ef1f6 | ||
|
|
6ed275734b | ||
|
|
85ca81ce79 | ||
|
|
e909c8268d | ||
|
|
73e6b65da0 | ||
|
|
ecbe36df6b | ||
|
|
d85b5234a9 | ||
|
|
5b80e0e3c2 | ||
|
|
461a4009ba | ||
|
|
8f2f2c5572 | ||
|
|
81a74ba225 | ||
|
|
6c0c5167b0 | ||
|
|
4c5451994f | ||
|
|
73226bd2fd | ||
|
|
8fa21a1837 | ||
|
|
ee1937f28d |
@@ -57,3 +57,6 @@ after_success:
|
|||||||
--gcov-options '\-lp'
|
--gcov-options '\-lp'
|
||||||
--verbose;
|
--verbose;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
after_failure:
|
||||||
|
- cat ./test-suite.log
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.5.3], [info@recp.me])
|
AC_INIT([cglm], [0.5.4], [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])
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
Building cglm
|
Build cglm
|
||||||
================================
|
================================
|
||||||
|
|
||||||
| **cglm** does not have external dependencies except for unit testing.
|
| **cglm** does not have external dependencies except for unit testing. When you pulled **cglm** repo with submodules all dependencies will be pulled too. `build-deps.sh` will pull all dependencies/submodules and build for you.
|
||||||
| When you pulled cglm repo with submodules all dependencies will be pulled too.
|
|
||||||
| `build-deps.sh` will pull all dependencies/submodules and build for you.
|
|
||||||
|
|
||||||
External dependencies:
|
External dependencies:
|
||||||
* cmocka - for unit testing
|
* cmocka - for unit testing
|
||||||
@@ -12,7 +10,8 @@ External dependencies:
|
|||||||
If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program.
|
If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program.
|
||||||
Just import cglm to your project as dependency / external lib by copy-paste then use it as usual
|
Just import cglm to your project as dependency / external lib by copy-paste then use it as usual
|
||||||
|
|
||||||
**Unix (Autotools):**
|
Unix (Autotools):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:linenos:
|
:linenos:
|
||||||
@@ -26,11 +25,12 @@ Just import cglm to your project as dependency / external lib by copy-paste then
|
|||||||
$ [sudo] make install # install to system (optional)
|
$ [sudo] make install # install to system (optional)
|
||||||
|
|
||||||
**make** will build cglm to **.libs** sub folder in project folder.
|
**make** will build cglm to **.libs** sub folder in project folder.
|
||||||
If you don't want to install cglm to your system's folder you can get static and dynamic libs in this folder.
|
If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder.
|
||||||
|
|
||||||
**Build dependencies (windows):**
|
Windows (MSBuild):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Windows related build files, project files are located in win folder,
|
Windows related build files, project files are located in `win` folder,
|
||||||
make sure you are inside in cglm/win folder.
|
make sure you are inside in cglm/win folder.
|
||||||
|
|
||||||
Code Analysis are enabled, it may take awhile to build.
|
Code Analysis are enabled, it may take awhile to build.
|
||||||
@@ -50,3 +50,19 @@ then try to build with *devenv*:
|
|||||||
$ devenv cglm.sln /Build Release
|
$ devenv cglm.sln /Build Release
|
||||||
|
|
||||||
Currently tests are not available on Windows.
|
Currently tests are not available on Windows.
|
||||||
|
|
||||||
|
Documentation (Sphinx):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**cglm** uses sphinx framework for documentation, it allows lot of formats for documentation. To see all options see sphinx build page:
|
||||||
|
|
||||||
|
https://www.sphinx-doc.org/en/master/man/sphinx-build.html
|
||||||
|
|
||||||
|
Example build:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
$ cd cglm/docs
|
||||||
|
$ sphinx-build source build
|
||||||
|
|
||||||
|
|||||||
@@ -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.5.3'
|
version = u'0.5.4'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.5.3'
|
release = u'0.5.4'
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -90,7 +90,7 @@ todo_include_todos = False
|
|||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
html_theme = 'alabaster'
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
@@ -99,13 +99,13 @@ html_theme = 'alabaster'
|
|||||||
# html_theme_options = {}
|
# html_theme_options = {}
|
||||||
|
|
||||||
html_theme_options = {
|
html_theme_options = {
|
||||||
'github_banner': 'true',
|
# 'github_banner': 'true',
|
||||||
'github_button': 'true',
|
# 'github_button': 'true',
|
||||||
'github_user': 'recp',
|
# 'github_user': 'recp',
|
||||||
'github_repo': 'cglm',
|
# 'github_repo': 'cglm',
|
||||||
'travis_button': 'true',
|
# 'travis_button': 'true',
|
||||||
'show_related': 'true',
|
# 'show_related': 'true',
|
||||||
'fixed_sidebar': 'true'
|
# 'fixed_sidebar': 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
|
|||||||
23
docs/source/features.rst
Normal file
23
docs/source/features.rst
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
Features
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
* general purpose matrix operations (mat4, mat3)
|
||||||
|
* chain matrix multiplication (square only)
|
||||||
|
* general purpose vector operations (cross, dot, rotate, proj, angle...)
|
||||||
|
* affine transforms
|
||||||
|
* matrix decomposition (extract rotation, scaling factor)
|
||||||
|
* optimized affine transform matrices (mul, rigid-body inverse)
|
||||||
|
* camera (lookat)
|
||||||
|
* projections (ortho, perspective)
|
||||||
|
* quaternions
|
||||||
|
* euler angles / yaw-pitch-roll to matrix
|
||||||
|
* extract euler angles
|
||||||
|
* inline or pre-compiled function call
|
||||||
|
* frustum (extract view frustum planes, corners...)
|
||||||
|
* bounding box (AABB in Frustum (culling), crop, merge...)
|
||||||
|
* bounding sphere
|
||||||
|
* project, unproject
|
||||||
|
* easing functions
|
||||||
|
* curves
|
||||||
|
* curve interpolation helpers (SMC, deCasteljau...)
|
||||||
|
* and other...
|
||||||
@@ -9,23 +9,26 @@ Types:
|
|||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
typedef float vec3[3];
|
typedef float vec2[2];
|
||||||
typedef int ivec3[3];
|
typedef float vec3[3];
|
||||||
typedef CGLM_ALIGN(16) float vec4[4];
|
typedef int ivec3[3];
|
||||||
|
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
||||||
|
typedef vec4 versor;
|
||||||
|
typedef vec3 mat3[3];
|
||||||
|
|
||||||
typedef vec3 mat3[3];
|
#ifdef __AVX__
|
||||||
typedef vec4 mat4[4];
|
typedef CGLM_ALIGN_IF(32) vec4 mat4[4];
|
||||||
|
#else
|
||||||
typedef vec4 versor;
|
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
As you can see types don't store extra informations in favor of space.
|
As you can see types don't store extra informations in favor of space.
|
||||||
You can send these values e.g. matrix to OpenGL directly without casting or calling a function like *value_ptr*
|
You can send these values e.g. matrix to OpenGL directly without casting or calling a function like *value_ptr*
|
||||||
|
|
||||||
Alignment is Required:
|
Alignment Is Required:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
**vec4** and **mat4** requires 16 byte alignment because vec4 and mat4 operations are
|
**vec4** and **mat4** requires 16 (32 for **mat4** if AVX is enabled) byte alignment because **vec4** and **mat4** operations are vectorized by SIMD instructions (SSE/AVX/NEON).
|
||||||
vectorized by SIMD instructions (SSE/AVX).
|
|
||||||
|
|
||||||
**UPDATE:**
|
**UPDATE:**
|
||||||
By starting v0.4.5 cglm provides an option to disable alignment requirement, it is enabled as default
|
By starting v0.4.5 cglm provides an option to disable alignment requirement, it is enabled as default
|
||||||
@@ -37,10 +40,9 @@ vectorized by SIMD instructions (SSE/AVX).
|
|||||||
Allocations:
|
Allocations:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
*cglm* doesn't alloc any memory on heap. So it doesn't provide any allocator.
|
*cglm* doesn't alloc any memory on heap. So it doesn't provide any allocator.
|
||||||
You must allocate memory yourself. You should alloc memory for out parameters too if you pass pointer of memory location.
|
You must allocate memory yourself. You should alloc memory for out parameters too if you pass pointer of memory location. When allocating memory, don't forget that **vec4** and **mat4** require alignment.
|
||||||
When allocating memory don't forget that **vec4** and **mat4** requires alignment.
|
|
||||||
|
|
||||||
**NOTE:** Unaligned vec4 and unaligned mat4 operations will be supported in the future. Check todo list.
|
**NOTE:** Unaligned **vec4** and unaligned **mat4** operations will be supported in the future. Check todo list.
|
||||||
Because you may want to multiply a CGLM matrix with external matrix.
|
Because you may want to multiply a CGLM matrix with external matrix.
|
||||||
There is no guarantee that non-CGLM matrix is aligned. Unaligned types will have *u* prefix e.g. **umat4**
|
There is no guarantee that non-CGLM matrix is aligned. Unaligned types will have *u* prefix e.g. **umat4**
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
You can adapt this file completely to your liking, but it should at least
|
You can adapt this file completely to your liking, but it should at least
|
||||||
contain the root `toctree` directive.
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
Welcome to cglm's documentation!
|
cglm Documentation
|
||||||
================================
|
================================
|
||||||
|
|
||||||
**cglm** is optimized 3D math library written in C99 (compatible with C89).
|
**cglm** is optimized 3D math library written in C99 (compatible with C89).
|
||||||
@@ -14,33 +14,36 @@ is considered to be supported as optional.
|
|||||||
|
|
||||||
Also currently only **float** type is supported for most operations.
|
Also currently only **float** type is supported for most operations.
|
||||||
|
|
||||||
**Features**
|
|
||||||
|
|
||||||
* general purpose matrix operations (mat4, mat3)
|
|
||||||
* chain matrix multiplication (square only)
|
|
||||||
* general purpose vector operations (cross, dot, rotate, proj, angle...)
|
|
||||||
* affine transforms
|
|
||||||
* matrix decomposition (extract rotation, scaling factor)
|
|
||||||
* optimized affine transform matrices (mul, rigid-body inverse)
|
|
||||||
* camera (lookat)
|
|
||||||
* projections (ortho, perspective)
|
|
||||||
* quaternions
|
|
||||||
* euler angles / yaw-pitch-roll to matrix
|
|
||||||
* extract euler angles
|
|
||||||
* inline or pre-compiled function call
|
|
||||||
* frustum (extract view frustum planes, corners...)
|
|
||||||
* bounding box (AABB in Frustum (culling), crop, merge...)
|
|
||||||
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 2
|
||||||
:caption: Table Of Contents:
|
:caption: Getting Started:
|
||||||
|
|
||||||
|
features
|
||||||
build
|
build
|
||||||
getting_started
|
getting_started
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: How To:
|
||||||
|
|
||||||
opengl
|
opengl
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: API:
|
||||||
|
|
||||||
api
|
api
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Options:
|
||||||
|
|
||||||
opt
|
opt
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:caption: Troubleshooting:
|
||||||
|
|
||||||
troubleshooting
|
troubleshooting
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ array of matrices:
|
|||||||
|
|
||||||
in this way, passing aray of matrices is same
|
in this way, passing aray of matrices is same
|
||||||
|
|
||||||
Passing / Uniforming Vectors to OpenGL:¶
|
Passing / Uniforming Vectors to OpenGL:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
You don't need to do extra thing when passing cglm vectors to OpengL or other APIs.
|
You don't need to do extra thing when passing cglm vectors to OpengL or other APIs.
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ glm_inv_tr(mat4 mat) {
|
|||||||
glm_inv_tr_sse2(mat);
|
glm_inv_tr_sse2(mat);
|
||||||
#else
|
#else
|
||||||
CGLM_ALIGN_MAT mat3 r;
|
CGLM_ALIGN_MAT mat3 r;
|
||||||
CGLM_ALIGN(16) vec3 t;
|
CGLM_ALIGN(8) vec3 t;
|
||||||
|
|
||||||
/* rotate */
|
/* rotate */
|
||||||
glm_mat4_pick3t(mat, r);
|
glm_mat4_pick3t(mat, r);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#ifndef cglm_bezier_h
|
#ifndef cglm_bezier_h
|
||||||
#define cglm_bezier_h
|
#define cglm_bezier_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#define GLM_BEZIER_MAT_INIT {{-1.0f, 3.0f, -3.0f, 1.0f}, \
|
#define GLM_BEZIER_MAT_INIT {{-1.0f, 3.0f, -3.0f, 1.0f}, \
|
||||||
{ 3.0f, -6.0f, 3.0f, 0.0f}, \
|
{ 3.0f, -6.0f, 3.0f, 0.0f}, \
|
||||||
{-3.0f, 3.0f, 0.0f, 0.0f}, \
|
{-3.0f, 3.0f, 0.0f, 0.0f}, \
|
||||||
|
|||||||
@@ -11,8 +11,10 @@
|
|||||||
#define _USE_MATH_DEFINES /* for windows */
|
#define _USE_MATH_DEFINES /* for windows */
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# ifdef CGLM_DLL
|
# ifdef CGLM_DLL
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#ifndef cglm_project_h
|
#ifndef cglm_project_h
|
||||||
#define cglm_project_h
|
#define cglm_project_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "vec3.h"
|
#include "vec3.h"
|
||||||
#include "vec4.h"
|
#include "vec4.h"
|
||||||
#include "mat4.h"
|
#include "mat4.h"
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ glm_quat_normalize_to(versor q, versor dest) {
|
|||||||
dot = glm_vec4_norm2(q);
|
dot = glm_vec4_norm2(q);
|
||||||
|
|
||||||
if (dot <= 0.0f) {
|
if (dot <= 0.0f) {
|
||||||
glm_quat_identity(q);
|
glm_quat_identity(dest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#define cglm_util_h
|
#define cglm_util_h
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#define GLM_MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
#define GLM_MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||||
#define GLM_MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
|
#define GLM_MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
|
||||||
|
|||||||
@@ -31,9 +31,6 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief fill a vector with specified value
|
* @brief fill a vector with specified value
|
||||||
|
|||||||
@@ -428,8 +428,8 @@ glm_vec3_maxadd(vec3 a, vec3 b, vec3 dest) {
|
|||||||
*
|
*
|
||||||
* it applies += operator so dest must be initialized
|
* it applies += operator so dest must be initialized
|
||||||
*
|
*
|
||||||
* @param[in] a vector
|
* @param[in] a vector 1
|
||||||
* @param[in] b scalar
|
* @param[in] b vector 2
|
||||||
* @param[out] dest dest += min(a, b)
|
* @param[out] dest dest += min(a, b)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
|
|||||||
@@ -31,9 +31,6 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "vec3-ext.h"
|
#include "vec3-ext.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief fill a vector with specified value
|
* @brief fill a vector with specified value
|
||||||
|
|||||||
@@ -576,8 +576,8 @@ glm_vec4_maxadd(vec4 a, vec4 b, vec4 dest) {
|
|||||||
*
|
*
|
||||||
* it applies += operator so dest must be initialized
|
* it applies += operator so dest must be initialized
|
||||||
*
|
*
|
||||||
* @param[in] a vector
|
* @param[in] a vector 1
|
||||||
* @param[in] b scalar
|
* @param[in] b vector 2
|
||||||
* @param[out] dest dest += min(a, b)
|
* @param[out] dest dest += min(a, b)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
@@ -690,18 +690,9 @@ CGLM_INLINE
|
|||||||
float
|
float
|
||||||
glm_vec4_distance(vec4 a, vec4 b) {
|
glm_vec4_distance(vec4 a, vec4 b) {
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
__m128 x0;
|
return glmm_norm(_mm_sub_ps(glmm_load(b), glmm_load(a)));
|
||||||
x0 = _mm_sub_ps(glmm_load(b), glmm_load(a));
|
|
||||||
x0 = _mm_mul_ps(x0, x0);
|
|
||||||
x0 = _mm_add_ps(x0, glmm_shuff1(x0, 1, 0, 3, 2));
|
|
||||||
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_add_ss(x0,
|
|
||||||
glmm_shuff1(x0, 0, 1, 0, 1))));
|
|
||||||
#elif defined(CGLM_NEON_FP)
|
#elif defined(CGLM_NEON_FP)
|
||||||
float32x4_t v0;
|
return glmm_norm(vsubq_f32(glmm_load(a), glmm_load(b)));
|
||||||
float32_t r;
|
|
||||||
v0 = vsubq_f32(vld1q_f32(a), vld1q_f32(b));
|
|
||||||
r = vaddvq_f32(vmulq_f32(v0, v0));
|
|
||||||
return sqrtf(r);
|
|
||||||
#else
|
#else
|
||||||
return sqrtf(glm_pow2(b[0] - a[0])
|
return sqrtf(glm_pow2(b[0] - a[0])
|
||||||
+ glm_pow2(b[1] - a[1])
|
+ glm_pow2(b[1] - a[1])
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 5
|
#define CGLM_VERSION_MINOR 5
|
||||||
#define CGLM_VERSION_PATCH 3
|
#define CGLM_VERSION_PATCH 4
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
@@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
cd $(dirname "$0")
|
cd $(dirname "$0")
|
||||||
|
|
||||||
mkdir -p .libs
|
mkdir -p "$(pwd)/.libs"
|
||||||
|
|
||||||
|
libmocka_folder=$(pwd)/test/lib/cmocka/build/src/
|
||||||
|
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
ln -sf $(pwd)/test/lib/cmocka/build/src/libcmocka.0.dylib \
|
libcmocka=libcmocka.0.dylib
|
||||||
.libs/libcmocka.0.dylib;
|
|
||||||
else
|
else
|
||||||
ln -sf $(pwd)/test/lib/cmocka/build/src/libcmocka.so.0 \
|
libcmocka=libcmocka.so.0
|
||||||
.libs/libcmocka.so.0;
|
fi
|
||||||
|
|
||||||
|
libcmocka_path="$libmocka_folder$libcmocka"
|
||||||
|
if [ -f "$libcmocka_path" ]; then
|
||||||
|
ln -sf "$libcmocka_path" "$(pwd)/.libs/$libcmocka";
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ test_bezier(void **state) {
|
|||||||
Bs_plain = test_bezier_plain(s, p0, c0, c1, p1);
|
Bs_plain = test_bezier_plain(s, p0, c0, c1, p1);
|
||||||
|
|
||||||
assert_true(glm_eq(Bs, Bs_plain));
|
assert_true(glm_eq(Bs, Bs_plain));
|
||||||
assert_true(glm_eq(smc, Bs_plain));
|
test_assert_eqf(smc, Bs_plain);
|
||||||
assert_true(glm_eq(Bs, smc));
|
test_assert_eqf(Bs, smc);
|
||||||
|
|
||||||
/* test cubic hermite */
|
/* test cubic hermite */
|
||||||
smc = glm_smc(s, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1});
|
smc = glm_smc(s, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "test_common.h"
|
#include "test_common.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#define m 4
|
#define m 4
|
||||||
#define n 4
|
#define n 4
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ test_vec4(void **state) {
|
|||||||
/* 3. test SIMD norm2 */
|
/* 3. test SIMD norm2 */
|
||||||
test_rand_vec4(v);
|
test_rand_vec4(v);
|
||||||
test_assert_eqf(test_vec4_norm2(v), glm_vec4_norm2(v));
|
test_assert_eqf(test_vec4_norm2(v), glm_vec4_norm2(v));
|
||||||
|
|
||||||
|
/* 4. test SSE/SIMD distance */
|
||||||
|
test_rand_vec4(v1);
|
||||||
|
test_rand_vec4(v2);
|
||||||
|
d1 = glm_vec4_distance(v1, v2);
|
||||||
|
d2 = sqrtf(powf(v1[0]-v2[0], 2.0f) + pow(v1[1]-v2[1], 2.0f) + pow(v1[2]-v2[2], 2.0f) + pow(v1[3]-v2[3], 2.0f));
|
||||||
|
assert_true(fabsf(d1 - d2) <= 0.000009);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test zero */
|
/* test zero */
|
||||||
|
|||||||
Reference in New Issue
Block a user