mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Merge branch 'master' into optimize-inv
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.8.2)
|
cmake_minimum_required(VERSION 3.8.2)
|
||||||
project(cglm
|
project(cglm
|
||||||
VERSION 0.9.4
|
VERSION 0.9.5
|
||||||
HOMEPAGE_URL https://github.com/recp/cglm
|
HOMEPAGE_URL https://github.com/recp/cglm
|
||||||
DESCRIPTION "OpenGL Mathematics (glm) for C"
|
DESCRIPTION "OpenGL Mathematics (glm) for C"
|
||||||
LANGUAGES C
|
LANGUAGES C
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
# Description
|
# Description
|
||||||
s.name = "cglm"
|
s.name = "cglm"
|
||||||
s.version = "0.9.3"
|
s.version = "0.9.4"
|
||||||
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
cglm is math library for graphics programming for C. See the documentation or README for all features.
|
cglm is math library for graphics programming for C. See the documentation or README for all features.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.9.4], [info@recp.me])
|
AC_INIT([cglm], [0.9.5], [info@recp.me])
|
||||||
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests])
|
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects serial-tests])
|
||||||
|
|
||||||
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.
|
||||||
|
|||||||
@@ -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.9.4'
|
version = u'0.9.5'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.9.4'
|
release = u'0.9.5'
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -91,6 +91,7 @@ todo_include_todos = False
|
|||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
html_theme = 'sphinx_rtd_theme'
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
pygments_style = 'monokai'
|
||||||
|
|
||||||
# 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
|
||||||
@@ -111,8 +112,11 @@ html_theme_options = {
|
|||||||
# 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,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
# html_static_path = ['_static']
|
html_static_path = ['sphinx-static']
|
||||||
|
|
||||||
|
# Add customm CSS and JS files
|
||||||
|
html_css_files = ['theme_overrides.css']
|
||||||
|
html_js_files = []
|
||||||
|
|
||||||
# -- Options for HTMLHelp output ------------------------------------------
|
# -- Options for HTMLHelp output ------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ Functions:
|
|||||||
#. :c:func:`glm_mat2x3_transpose`
|
#. :c:func:`glm_mat2x3_transpose`
|
||||||
#. :c:func:`glm_mat2x3_scale`
|
#. :c:func:`glm_mat2x3_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10"
|
||||||
|
"row 2", "m01", "m11"
|
||||||
|
"row 3", "m02", "m12"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +61,68 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix2x3
|
| *[out]* **dest** destination matrix2x3
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest)
|
.. c:function:: void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat2x3)
|
| *[in]* **m1** left matrix (mat2x3)
|
||||||
| *[in]* **m2** right matrix (mat3x2)
|
| *[in]* **m2** right matrix (mat3x2)
|
||||||
| *[out]* **dest** destination matrix (mat2)
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest)
|
.. csv-table:: mat2x3
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
multiply mat2x3 with vec3 (column vector) and store in dest vector
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10", "b20"
|
||||||
|
"row 2", "b01", "b11", "b21"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21"
|
||||||
|
"row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest)
|
||||||
|
|
||||||
|
multiply mat2x3 with vec2 (column vector) and store in dest column vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat2x3 (left)
|
| *[in]* **m** mat2x3 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10"
|
||||||
|
"row 2", "m01", "m11"
|
||||||
|
"row 3", "m02", "m12"
|
||||||
|
|
||||||
|
.. csv-table:: column vec2 (1x2)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
|
||||||
|
.. csv-table:: column vec3 (1x3)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1"
|
||||||
|
"row 3", "m02 * v0 + m12 * v1"
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest)
|
.. c:function:: void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ Functions:
|
|||||||
#. :c:func:`glm_mat2x4_transpose`
|
#. :c:func:`glm_mat2x4_transpose`
|
||||||
#. :c:func:`glm_mat2x4_scale`
|
#. :c:func:`glm_mat2x4_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10"
|
||||||
|
"row 2", "m01", "m11"
|
||||||
|
"row 3", "m02", "m12"
|
||||||
|
"row 4", "m03", "m13"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +62,72 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix2x4
|
| *[out]* **dest** destination matrix2x4
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest)
|
.. c:function:: void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat2x4)
|
| *[in]* **m1** left matrix (mat2x4)
|
||||||
| *[in]* **m2** right matrix (mat4x2)
|
| *[in]* **m2** right matrix (mat4x2)
|
||||||
| *[out]* **dest** destination matrix (mat2)
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest)
|
.. csv-table:: mat2x4
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
multiply mat2x4 with vec4 (column vector) and store in dest vector
|
"row 1", "a00", "a10"
|
||||||
|
"row 2", "a01", "a11"
|
||||||
|
"row 3", "a02", "a12"
|
||||||
|
"row 4", "a03", "a13"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10", "b20", "b30"
|
||||||
|
"row 2", "b01", "b11", "b21", "b31"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01", "a00 * b10 + a10 * b11", "a00 * b20 + a10 * b21", "a00 * b30 + a10 * b31"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01", "a01 * b10 + a11 * b11", "a01 * b20 + a11 * b21", "a01 * b30 + a11 * b31"
|
||||||
|
"row 3", "a02 * b00 + a12 * b01", "a02 * b10 + a12 * b11", "a02 * b20 + a12 * b21", "a02 * b30 + a12 * b31"
|
||||||
|
"row 4", "a03 * b00 + a13 * b01", "a03 * b10 + a13 * b11", "a03 * b20 + a13 * b21", "a03 * b30 + a13 * b31"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest)
|
||||||
|
|
||||||
|
multiply mat2x4 with vec2 (column vector) and store in dest column vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat2x4 (left)
|
| *[in]* **m** mat2x4 (left)
|
||||||
| *[in]* **v** vec4 (right, column vector)
|
| *[in]* **v** vec2 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10"
|
||||||
|
"row 2", "m01", "m11"
|
||||||
|
"row 3", "m02", "m12"
|
||||||
|
"row 4", "m03", "m13"
|
||||||
|
|
||||||
|
.. csv-table:: column vec2 (1x2)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
|
||||||
|
.. csv-table:: column vec4 (1x4)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1"
|
||||||
|
"row 3", "m02 * v0 + m12 * v1"
|
||||||
|
"row 4", "m03 * v0 + m13 * v1"
|
||||||
|
|
||||||
.. c:function:: void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest)
|
.. c:function:: void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ Functions:
|
|||||||
#. :c:func:`glm_mat3x2_transpose`
|
#. :c:func:`glm_mat3x2_transpose`
|
||||||
#. :c:func:`glm_mat3x2_scale`
|
#. :c:func:`glm_mat3x2_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20"
|
||||||
|
"row 2", "m01", "m11", "m21"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +60,66 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix3x2
|
| *[out]* **dest** destination matrix3x2
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest)
|
.. c:function:: void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat3x2)
|
| *[in]* **m1** left matrix (mat3x2)
|
||||||
| *[in]* **m2** right matrix (mat2x3)
|
| *[in]* **m2** right matrix (mat2x3)
|
||||||
| *[out]* **dest** destination matrix (mat3)
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest)
|
.. csv-table:: mat3x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
multiply mat3x2 with vec2 (column vector) and store in dest vector
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x3
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10"
|
||||||
|
"row 2", "b01", "b11"
|
||||||
|
"row 3", "b02", "b12"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x2
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest)
|
||||||
|
|
||||||
|
multiply mat3x2 with vec3 (column vector) and store in dest vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat3x2 (left)
|
| *[in]* **m** mat3x2 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20"
|
||||||
|
"row 2", "m01", "m11", "m21"
|
||||||
|
|
||||||
|
.. csv-table:: column vec3 (1x3)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
|
||||||
|
.. csv-table:: column vec2 (1x2)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest)
|
.. c:function:: void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ Functions:
|
|||||||
#. :c:func:`glm_mat3x4_transpose`
|
#. :c:func:`glm_mat3x4_transpose`
|
||||||
#. :c:func:`glm_mat3x4_scale`
|
#. :c:func:`glm_mat3x4_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20"
|
||||||
|
"row 2", "m01", "m11", "m21"
|
||||||
|
"row 3", "m02", "m12", "m22"
|
||||||
|
"row 4", "m03", "m13", "m23"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +62,74 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix3x4
|
| *[out]* **dest** destination matrix3x4
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest)
|
.. c:function:: void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat3x4)
|
| *[in]* **m1** left matrix (mat3x4)
|
||||||
| *[in]* **m2** right matrix (mat4x3)
|
| *[in]* **m2** right matrix (mat4x3)
|
||||||
| *[out]* **dest** destination matrix (mat3)
|
| *[out]* **dest** destination matrix (mat4)
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest)
|
.. csv-table:: mat3x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
multiply mat3x4 with vec4 (column vector) and store in dest vector
|
"row 1", "a00", "a10", "a20"
|
||||||
|
"row 2", "a01", "a11", "a21"
|
||||||
|
"row 3", "a02", "a12", "a22"
|
||||||
|
"row 4", "a03", "a13", "a23"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10", "b20", "b30"
|
||||||
|
"row 2", "b01", "b11", "b21", "b31"
|
||||||
|
"row 3", "b02", "b12", "b22", "b32"
|
||||||
|
|
||||||
|
.. csv-table:: mat4x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02", "a00 * b10 + a10 * b11 + a20 * b12", "a00 * b20 + a10 * b21 + a20 * b22", "a00 * b30 + a10 * b31 + a20 * b32"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01 + a21 * b02", "a01 * b10 + a11 * b11 + a21 * b12", "a01 * b20 + a11 * b21 + a21 * b22", "a01 * b30 + a11 * b31 + a21 * b32"
|
||||||
|
"row 3", "a02 * b00 + a12 * b01 + a22 * b02", "a02 * b10 + a12 * b11 + a22 * b12", "a02 * b20 + a12 * b21 + a22 * b22", "a02 * b30 + a12 * b31 + a22 * b32"
|
||||||
|
"row 4", "a03 * b00 + a13 * b01 + a23 * b02", "a03 * b10 + a13 * b11 + a23 * b12", "a03 * b20 + a13 * b21 + a23 * b22", "a03 * b30 + a13 * b31 + a23 * b32"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest)
|
||||||
|
|
||||||
|
multiply mat3x4 with vec3 (column vector) and store in dest vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat3x4 (left)
|
| *[in]* **m** mat3x4 (left)
|
||||||
| *[in]* **v** vec4 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20"
|
||||||
|
"row 2", "m01", "m11", "m21"
|
||||||
|
"row 3", "m02", "m12", "m22"
|
||||||
|
"row 4", "m03", "m13", "m23"
|
||||||
|
|
||||||
|
.. csv-table:: column vec3 (1x3)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
|
||||||
|
.. csv-table:: column vec4 (1x4)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2"
|
||||||
|
"row 3", "m02 * v0 + m12 * v1 + m22 * v2"
|
||||||
|
"row 4", "m03 * v0 + m13 * v1 + m23 * v2"
|
||||||
|
|
||||||
.. c:function:: void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest)
|
.. c:function:: void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ Functions:
|
|||||||
#. :c:func:`glm_mat4x2_transpose`
|
#. :c:func:`glm_mat4x2_transpose`
|
||||||
#. :c:func:`glm_mat4x2_scale`
|
#. :c:func:`glm_mat4x2_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column4"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +60,70 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix4x2
|
| *[out]* **dest** destination matrix4x2
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest)
|
.. c:function:: void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat4x2)
|
| *[in]* **m1** left matrix (mat4x2)
|
||||||
| *[in]* **m2** right matrix (mat2x4)
|
| *[in]* **m2** right matrix (mat2x4)
|
||||||
| *[out]* **dest** destination matrix (mat4)
|
| *[out]* **dest** destination matrix (mat2)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest)
|
.. csv-table:: mat4x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
multiply mat4x2 with vec2 (column vector) and store in dest vector
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x4
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10"
|
||||||
|
"row 2", "b01", "b11"
|
||||||
|
"row 3", "b02", "b12"
|
||||||
|
"row 4", "b03", "b13"
|
||||||
|
|
||||||
|
.. csv-table:: mat2x2
|
||||||
|
:header: "", "column 1", "column 2"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest)
|
||||||
|
|
||||||
|
multiply mat4x2 with vec4 (column vector) and store in dest vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat4x2 (left)
|
| *[in]* **m** mat4x2 (left)
|
||||||
| *[in]* **v** vec2 (right, column vector)
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x2
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20"
|
||||||
|
"row 2", "m01", "m11", "m21"
|
||||||
|
"row 3", "m02", "m12", "m22"
|
||||||
|
"row 4", "m03", "m13", "m23"
|
||||||
|
|
||||||
|
.. csv-table:: column vec4 (1x4)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
|
||||||
|
.. csv-table:: column vec2 (1x2)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest)
|
.. c:function:: void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ Functions:
|
|||||||
#. :c:func:`glm_mat4x3_transpose`
|
#. :c:func:`glm_mat4x3_transpose`
|
||||||
#. :c:func:`glm_mat4x3_scale`
|
#. :c:func:`glm_mat4x3_scale`
|
||||||
|
|
||||||
|
Represented
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column4"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
|
"row 3", "m02", "m12", "m22", "m32"
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -51,28 +61,72 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination matrix4x3
|
| *[out]* **dest** destination matrix4x3
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest)
|
.. c:function:: void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
|
|
||||||
.. code-block:: c
|
.. code-block:: c
|
||||||
|
|
||||||
glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m1** left matrix (mat4x3)
|
| *[in]* **m1** left matrix (mat4x3)
|
||||||
| *[in]* **m2** right matrix (mat3x4)
|
| *[in]* **m2** right matrix (mat3x4)
|
||||||
| *[out]* **dest** destination matrix (mat4)
|
| *[out]* **dest** destination matrix (mat3)
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest)
|
.. csv-table:: mat4x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
multiply mat4x3 with vec3 (column vector) and store in dest vector
|
"row 1", "a00", "a10", "a20", "a30"
|
||||||
|
"row 2", "a01", "a11", "a21", "a31"
|
||||||
|
"row 3", "a02", "a12", "a22", "a32"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x4
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "b00", "b10", "b20"
|
||||||
|
"row 2", "b01", "b11", "b21"
|
||||||
|
"row 3", "b02", "b12", "b22"
|
||||||
|
"row 4", "b03", "b13", "b23"
|
||||||
|
|
||||||
|
.. csv-table:: mat3x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3"
|
||||||
|
|
||||||
|
"row 1", "a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03", "a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13", "a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23"
|
||||||
|
"row 2", "a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03", "a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13", "a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23"
|
||||||
|
"row 3", "a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03", "a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13", "a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23"
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest)
|
||||||
|
|
||||||
|
multiply mat4x3 with vec4 (column vector) and store in dest column vector
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **m** mat4x3 (left)
|
| *[in]* **m** mat4x3 (left)
|
||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec4 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. csv-table:: mat4x3
|
||||||
|
:header: "", "column 1", "column 2", "column 3", "column 4"
|
||||||
|
|
||||||
|
"row 1", "m00", "m10", "m20", "m30"
|
||||||
|
"row 2", "m01", "m11", "m21", "m31"
|
||||||
|
"row 3", "m02", "m12", "m22", "m32"
|
||||||
|
|
||||||
|
.. csv-table:: column vec4 (1x4)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "v0"
|
||||||
|
"row 2", "v1"
|
||||||
|
"row 3", "v2"
|
||||||
|
"row 4", "v3"
|
||||||
|
|
||||||
|
.. csv-table:: column vec3 (1x3)
|
||||||
|
:header: "", "column 1"
|
||||||
|
|
||||||
|
"row 1", "m00 * v0 + m10 * v1 + m20 * v2 + m30 * v3"
|
||||||
|
"row 2", "m01 * v0 + m11 * v1 + m21 * v2 + m31 * v3"
|
||||||
|
"row 3", "m02 * v0 + m12 * v1 + m22 * v2 + m32 * v3"
|
||||||
|
|
||||||
.. c:function:: void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest)
|
.. c:function:: void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest)
|
||||||
|
|
||||||
transpose matrix and store in dest
|
transpose matrix and store in dest
|
||||||
|
|||||||
12
docs/source/sphinx-static/theme_overrides.css
Normal file
12
docs/source/sphinx-static/theme_overrides.css
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
@media screen {
|
||||||
|
/* content column
|
||||||
|
*
|
||||||
|
* RTD theme's default is 800px as max width for the content, but we have
|
||||||
|
* tables with tons of columns, which need the full width of the view-port.
|
||||||
|
*
|
||||||
|
* Comment from yocto project theme_overrides.css
|
||||||
|
*/
|
||||||
|
|
||||||
|
.wy-nav-content{ max-width: none; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -397,16 +397,16 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination vector
|
| *[out]* **dest** destination vector
|
||||||
|
|
||||||
.. c:function:: void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest)
|
.. c:function:: void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
|
||||||
|
|
||||||
Reflection vector using an incident ray and a surface normal
|
Reflection vector using an incident ray and a surface normal
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** incident vector
|
| *[in]* **v** incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[out]* **dest** destination: reflection result
|
| *[out]* **dest** destination: reflection result
|
||||||
|
|
||||||
.. c:function:: bool glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest)
|
.. c:function:: bool glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
|
||||||
|
|
||||||
Computes refraction vector for an incident vector and a surface normal.
|
Computes refraction vector for an incident vector and a surface normal.
|
||||||
|
|
||||||
@@ -415,8 +415,8 @@ Functions documentation
|
|||||||
Otherwise, computes refraction vector, stores it in dest, and returns true.
|
Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** *❗️ normalized ❗️* incident vector
|
| *[in]* **v** *❗️ normalized ❗️* incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
||||||
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
||||||
|
|
||||||
|
|||||||
@@ -516,26 +516,26 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination vector
|
| *[out]* **dest** destination vector
|
||||||
|
|
||||||
.. c:function:: void glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest)
|
.. c:function:: void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest)
|
||||||
|
|
||||||
A vector pointing in the same direction as another
|
A vector pointing in the same direction as another
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **N** vector to orient
|
| *[in]* **n** vector to orient
|
||||||
| *[in]* **I** incident vector
|
| *[in]* **v** incident vector
|
||||||
| *[in]* **Nref** reference vector
|
| *[in]* **nref** reference vector
|
||||||
| *[out]* **dest** destination: oriented vector, pointing away from the surface.
|
| *[out]* **dest** destination: oriented vector, pointing away from the surface.
|
||||||
|
|
||||||
.. c:function:: void glm_vec3_reflect(vec3 I, vec3 N, vec3 dest)
|
.. c:function:: void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest)
|
||||||
|
|
||||||
Reflection vector using an incident ray and a surface normal
|
Reflection vector using an incident ray and a surface normal
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** incident vector
|
| *[in]* **v** incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[out]* **dest** destination: reflection result
|
| *[out]* **dest** destination: reflection result
|
||||||
|
|
||||||
.. c:function:: bool glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest)
|
.. c:function:: bool glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest)
|
||||||
|
|
||||||
|
|
||||||
Computes refraction vector for an incident vector and a surface normal.
|
Computes refraction vector for an incident vector and a surface normal.
|
||||||
@@ -545,10 +545,10 @@ Functions documentation
|
|||||||
Otherwise, computes refraction vector, stores it in dest, and returns true.
|
Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** *❗️ normalized ❗️* incident vector
|
| *[in]* **v** *❗️ normalized ❗️* incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
||||||
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
returns true if refraction occurs; false if total internal reflection occurs.
|
returns true if refraction occurs; false if total internal reflection occurs.
|
||||||
|
|||||||
@@ -427,16 +427,16 @@ Functions documentation
|
|||||||
| *[in]* **src** pointer to an array of floats
|
| *[in]* **src** pointer to an array of floats
|
||||||
| *[out]* **dest** destination vector
|
| *[out]* **dest** destination vector
|
||||||
|
|
||||||
.. c:function:: bool glm_vec4_reflect(vec4 I, vec4 N, vec4 dest)
|
.. c:function:: bool glm_vec4_reflect(vec4 v, vec4 n, vec4 dest)
|
||||||
|
|
||||||
Reflection vector using an incident ray and a surface normal
|
Reflection vector using an incident ray and a surface normal
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** incident vector
|
| *[in]* **v** incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[out]* **dest** destination: reflection result
|
| *[out]* **dest** destination: reflection result
|
||||||
|
|
||||||
.. c:function:: bool glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest)
|
.. c:function:: bool glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest)
|
||||||
|
|
||||||
computes refraction vector for an incident vector and a surface normal.
|
computes refraction vector for an incident vector and a surface normal.
|
||||||
|
|
||||||
@@ -449,10 +449,10 @@ Functions documentation
|
|||||||
the 'w' component should manually adjust 'dest' after calling this function.
|
the 'w' component should manually adjust 'dest' after calling this function.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **I** *❗️ normalized ❗️* incident vector
|
| *[in]* **v** *❗️ normalized ❗️* incident vector
|
||||||
| *[in]* **N** *❗️ normalized ❗️* normal vector
|
| *[in]* **n** *❗️ normalized ❗️* normal vector
|
||||||
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
| *[in]* **eta** ratio of indices of refraction (incident/transmitted)
|
||||||
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
| *[out]* **dest** refraction vector if refraction occurs; zero vector otherwise
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
returns true if refraction occurs; false if total internal reflection occurs.
|
returns true if refraction occurs; false if total internal reflection occurs.
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat2x3_make(const float * __restrict src, mat2x3 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest);
|
glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest);
|
glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat2x4_make(const float * __restrict src, mat2x4 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest);
|
glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest);
|
glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat3x2_make(const float * __restrict src, mat3x2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest);
|
glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest);
|
glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat3x4_make(const float * __restrict src, mat3x4 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest);
|
glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest);
|
glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat4x2_make(const float * __restrict src, mat4x2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest);
|
glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest);
|
glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ glmc_mat4x3_make(const float * __restrict src, mat4x3 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest);
|
glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest);
|
glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -199,11 +199,11 @@ glmc_vec2_make(const float * __restrict src, vec2 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest);
|
glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest);
|
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,15 +336,15 @@ glmc_vec3_make(const float * __restrict src, vec3 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest);
|
glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest);
|
glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest);
|
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,11 +313,11 @@ glmc_vec4_make(const float * __restrict src, vec4 dest);
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest);
|
glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest);
|
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
# define CGLM_LIKELY(expr) (expr)
|
# define CGLM_LIKELY(expr) (expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_M_FP_FAST) || defined(__FAST_MATH__)
|
||||||
|
# define CGLM_FAST_MATH
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GLM_SHUFFLE4(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
|
#define GLM_SHUFFLE4(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
|
||||||
#define GLM_SHUFFLE3(z, y, x) (((z) << 4) | ((y) << 2) | (x))
|
#define GLM_SHUFFLE3(z, y, x) (((z) << 4) | ((y) << 2) | (x))
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
CGLM_INLINE void glm_mat2x3_copy(mat2x3 mat, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat);
|
CGLM_INLINE void glm_mat2x3_zero(mat2x3 mat);
|
||||||
CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest);
|
CGLM_INLINE void glm_mat2x3_make(const float * __restrict src, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest);
|
CGLM_INLINE void glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest);
|
CGLM_INLINE void glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
CGLM_INLINE void glm_mat2x3_transpose(mat2x3 m, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s);
|
CGLM_INLINE void glm_mat2x3_scale(mat2x3 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +82,7 @@ glm_mat2x3_make(const float * __restrict src, mat2x3 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x3_mul(mat2x3, mat3x2, mat2);
|
* glm_mat2x3_mul(mat2x3, mat3x2, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x3)
|
* @param[in] m1 left matrix (mat2x3)
|
||||||
@@ -91,19 +91,25 @@ glm_mat2x3_make(const float * __restrict src, mat2x3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest) {
|
glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
||||||
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
||||||
|
|
||||||
b00 = m2[0][0], b01 = m2[0][1],
|
b00 = m2[0][0], b01 = m2[0][1],
|
||||||
b10 = m2[1][0], b11 = m2[1][1],
|
b10 = m2[1][0], b11 = m2[1][1],
|
||||||
b20 = m2[2][0], b21 = m2[2][1];
|
b20 = m2[2][0], b21 = m2[2][1];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20;
|
dest[0][0] = a00 * b00 + a10 * b01;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21;
|
dest[0][1] = a01 * b00 + a11 * b01;
|
||||||
|
dest[0][2] = a02 * b00 + a12 * b01;
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20;
|
dest[1][0] = a00 * b10 + a10 * b11;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21;
|
dest[1][1] = a01 * b10 + a11 * b11;
|
||||||
|
dest[1][2] = a02 * b10 + a12 * b11;
|
||||||
|
|
||||||
|
dest[2][0] = a00 * b20 + a10 * b21;
|
||||||
|
dest[2][1] = a01 * b20 + a11 * b21;
|
||||||
|
dest[2][2] = a02 * b20 + a12 * b21;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -115,11 +121,12 @@ glm_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest) {
|
glm_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) {
|
||||||
float v0 = v[0], v1 = v[1], v2 = v[2];
|
float v0 = v[0], v1 = v[1];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1;
|
||||||
|
dest[2] = m[0][2] * v0 + m[1][2] * v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
CGLM_INLINE void glm_mat2x4_copy(mat2x4 mat, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat);
|
CGLM_INLINE void glm_mat2x4_zero(mat2x4 mat);
|
||||||
CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest);
|
CGLM_INLINE void glm_mat2x4_make(const float * __restrict src, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest);
|
CGLM_INLINE void glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest);
|
CGLM_INLINE void glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
CGLM_INLINE void glm_mat2x4_transpose(mat2x4 m, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s);
|
CGLM_INLINE void glm_mat2x4_scale(mat2x4 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -80,16 +80,16 @@ glm_mat2x4_make(const float * __restrict src, mat2x4 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat2x4_mul(mat2x4, mat4x2, mat2);
|
* glm_mat2x4_mul(mat2x4, mat4x2, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat2x4)
|
* @param[in] m1 left matrix (mat2x4)
|
||||||
* @param[in] m2 right matrix (mat4x2)
|
* @param[in] m2 right matrix (mat4x2)
|
||||||
* @param[out] dest destination matrix (mat2)
|
* @param[out] dest destination matrix (mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest) {
|
glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
|
||||||
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
|
||||||
|
|
||||||
@@ -98,15 +98,29 @@ glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest) {
|
|||||||
b20 = m2[2][0], b21 = m2[2][1],
|
b20 = m2[2][0], b21 = m2[2][1],
|
||||||
b30 = m2[3][0], b31 = m2[3][1];
|
b30 = m2[3][0], b31 = m2[3][1];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
|
dest[0][0] = a00 * b00 + a10 * b01;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
|
dest[0][1] = a01 * b00 + a11 * b01;
|
||||||
|
dest[0][2] = a02 * b00 + a12 * b01;
|
||||||
|
dest[0][3] = a03 * b00 + a13 * b01;
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
|
dest[1][0] = a00 * b10 + a10 * b11;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
|
dest[1][1] = a01 * b10 + a11 * b11;
|
||||||
|
dest[1][2] = a02 * b10 + a12 * b11;
|
||||||
|
dest[1][3] = a03 * b10 + a13 * b11;
|
||||||
|
|
||||||
|
dest[2][0] = a00 * b20 + a10 * b21;
|
||||||
|
dest[2][1] = a01 * b20 + a11 * b21;
|
||||||
|
dest[2][2] = a02 * b20 + a12 * b21;
|
||||||
|
dest[2][3] = a03 * b20 + a13 * b21;
|
||||||
|
|
||||||
|
dest[3][0] = a00 * b30 + a10 * b31;
|
||||||
|
dest[3][1] = a01 * b30 + a11 * b31;
|
||||||
|
dest[3][2] = a02 * b30 + a12 * b31;
|
||||||
|
dest[3][3] = a03 * b30 + a13 * b31;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
@@ -114,11 +128,13 @@ glm_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest) {
|
glm_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) {
|
||||||
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
float v0 = v[0], v1 = v[1];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2 + m[0][3] * v3;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2 + m[1][3] * v3;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1;
|
||||||
|
dest[2] = m[0][2] * v0 + m[1][2] * v1;
|
||||||
|
dest[3] = m[0][3] * v0 + m[1][3] * v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
CGLM_INLINE void glm_mat3x2_copy(mat3x2 mat, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
|
CGLM_INLINE void glm_mat3x2_zero(mat3x2 mat);
|
||||||
CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest);
|
CGLM_INLINE void glm_mat3x2_make(const float * __restrict src, mat3x2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest);
|
CGLM_INLINE void glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest);
|
CGLM_INLINE void glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
CGLM_INLINE void glm_mat3x2_transpose(mat3x2 m, mat2x3 dest);
|
||||||
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
CGLM_INLINE void glm_mat3x2_scale(mat3x2 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -84,16 +84,16 @@ glm_mat3x2_make(const float * __restrict src, mat3x2 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x2_mul(mat3x2, mat2x3, mat3);
|
* glm_mat3x2_mul(mat3x2, mat2x3, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x2)
|
* @param[in] m1 left matrix (mat3x2)
|
||||||
* @param[in] m2 right matrix (mat2x3)
|
* @param[in] m2 right matrix (mat2x3)
|
||||||
* @param[out] dest destination matrix (mat3)
|
* @param[out] dest destination matrix (mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1],
|
float a00 = m1[0][0], a01 = m1[0][1],
|
||||||
a10 = m1[1][0], a11 = m1[1][1],
|
a10 = m1[1][0], a11 = m1[1][1],
|
||||||
a20 = m1[2][0], a21 = m1[2][1],
|
a20 = m1[2][0], a21 = m1[2][1],
|
||||||
@@ -101,21 +101,15 @@ glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
|||||||
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2],
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2],
|
||||||
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2];
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10;
|
dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11;
|
dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02;
|
||||||
dest[0][2] = a00 * b02 + a01 * b12;
|
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10;
|
dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11;
|
dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12;
|
||||||
dest[1][2] = a10 * b02 + a11 * b12;
|
|
||||||
|
|
||||||
dest[2][0] = a20 * b00 + a21 * b10;
|
|
||||||
dest[2][1] = a20 * b01 + a21 * b11;
|
|
||||||
dest[2][2] = a20 * b02 + a21 * b12;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
@@ -123,12 +117,11 @@ glm_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest) {
|
glm_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) {
|
||||||
float v0 = v[0], v1 = v[1];
|
float v0 = v[0], v1 = v[1], v2 = v[2];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2;
|
||||||
dest[2] = m[2][0] * v0 + m[2][1] * v1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
CGLM_INLINE void glm_mat3x4_copy(mat3x4 mat, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat);
|
CGLM_INLINE void glm_mat3x4_zero(mat3x4 mat);
|
||||||
CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest);
|
CGLM_INLINE void glm_mat3x4_make(const float * __restrict src, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest);
|
CGLM_INLINE void glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest);
|
CGLM_INLINE void glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
CGLM_INLINE void glm_mat3x4_transpose(mat3x4 m, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s);
|
CGLM_INLINE void glm_mat3x4_scale(mat3x4 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -87,16 +87,16 @@ glm_mat3x4_make(const float * __restrict src, mat3x4 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat3x4_mul(mat3x4, mat4x3, mat3);
|
* glm_mat3x4_mul(mat3x4, mat4x3, mat4);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x4)
|
* @param[in] m1 left matrix (mat3x4)
|
||||||
* @param[in] m2 right matrix (mat4x3)
|
* @param[in] m2 right matrix (mat4x3)
|
||||||
* @param[out] dest destination matrix (mat3)
|
* @param[out] dest destination matrix (mat4)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest) {
|
glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2], a03 = m1[0][3],
|
||||||
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2], a13 = m1[1][3],
|
||||||
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3],
|
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2], a23 = m1[2][3],
|
||||||
@@ -106,21 +106,29 @@ glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest) {
|
|||||||
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2],
|
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2],
|
||||||
b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2];
|
b30 = m2[3][0], b31 = m2[3][1], b32 = m2[3][2];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;
|
dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;
|
dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02;
|
||||||
dest[0][2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;
|
dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02;
|
||||||
|
dest[0][3] = a03 * b00 + a13 * b01 + a23 * b02;
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;
|
dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;
|
dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12;
|
||||||
dest[1][2] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;
|
dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12;
|
||||||
|
dest[1][3] = a03 * b10 + a13 * b11 + a23 * b12;
|
||||||
|
|
||||||
dest[2][0] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;
|
dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22;
|
||||||
dest[2][1] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;
|
dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22;
|
||||||
dest[2][2] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;
|
dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22;
|
||||||
|
dest[2][3] = a03 * b20 + a13 * b21 + a23 * b22;
|
||||||
|
|
||||||
|
dest[3][0] = a00 * b30 + a10 * b31 + a20 * b32;
|
||||||
|
dest[3][1] = a01 * b30 + a11 * b31 + a21 * b32;
|
||||||
|
dest[3][2] = a02 * b30 + a12 * b31 + a22 * b32;
|
||||||
|
dest[3][3] = a03 * b30 + a13 * b31 + a23 * b32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
@@ -128,12 +136,13 @@ glm_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest) {
|
glm_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) {
|
||||||
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
float v0 = v[0], v1 = v[1], v2 = v[2];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2 + m[0][3] * v3;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2 + m[1][3] * v3;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2;
|
||||||
dest[2] = m[2][0] * v0 + m[2][1] * v1 + m[2][2] * v2 + m[2][3] * v3;
|
dest[2] = m[0][2] * v0 + m[1][2] * v1 + m[2][2] * v2;
|
||||||
|
dest[3] = m[0][3] * v0 + m[1][3] * v1 + m[2][3] * v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -162,10 +171,9 @@ glm_mat3x4_transpose(mat3x4 m, mat4x3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3x4_scale(mat3x4 m, float s) {
|
glm_mat3x4_scale(mat3x4 m, float s) {
|
||||||
m[0][0] *= s; m[1][0] *= s; m[2][0] *= s;
|
m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s;
|
||||||
m[0][1] *= s; m[1][1] *= s; m[2][1] *= s;
|
m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s;
|
||||||
m[0][2] *= s; m[1][2] *= s; m[2][2] *= s;
|
m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; m[2][3] *= s;
|
||||||
m[0][3] *= s; m[1][3] *= s; m[2][3] *= s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
CGLM_INLINE void glm_mat4x2_copy(mat4x2 mat, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat);
|
CGLM_INLINE void glm_mat4x2_zero(mat4x2 mat);
|
||||||
CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest);
|
CGLM_INLINE void glm_mat4x2_make(const float * __restrict src, mat4x2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest);
|
CGLM_INLINE void glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest);
|
CGLM_INLINE void glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
CGLM_INLINE void glm_mat4x2_transpose(mat4x2 m, mat2x4 dest);
|
||||||
CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s);
|
CGLM_INLINE void glm_mat4x2_scale(mat4x2 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -90,16 +90,16 @@ glm_mat4x2_make(const float * __restrict src, mat4x2 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x2_mul(mat4x2, mat2x4, mat4);
|
* glm_mat4x2_mul(mat4x2, mat2x4, mat2);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x2)
|
* @param[in] m1 left matrix (mat4x2)
|
||||||
* @param[in] m2 right matrix (mat2x4)
|
* @param[in] m2 right matrix (mat2x4)
|
||||||
* @param[out] dest destination matrix (mat4)
|
* @param[out] dest destination matrix (mat2)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest) {
|
glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1],
|
float a00 = m1[0][0], a01 = m1[0][1],
|
||||||
a10 = m1[1][0], a11 = m1[1][1],
|
a10 = m1[1][0], a11 = m1[1][1],
|
||||||
a20 = m1[2][0], a21 = m1[2][1],
|
a20 = m1[2][0], a21 = m1[2][1],
|
||||||
@@ -108,29 +108,15 @@ glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest) {
|
|||||||
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3],
|
b00 = m2[0][0], b01 = m2[0][1], b02 = m2[0][2], b03 = m2[0][3],
|
||||||
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3];
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10;
|
dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11;
|
dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;
|
||||||
dest[0][2] = a00 * b02 + a01 * b12;
|
|
||||||
dest[0][3] = a00 * b03 + a01 * b13;
|
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10;
|
dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11;
|
dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;
|
||||||
dest[1][2] = a10 * b02 + a11 * b12;
|
|
||||||
dest[1][3] = a10 * b03 + a11 * b13;
|
|
||||||
|
|
||||||
dest[2][0] = a20 * b00 + a21 * b10;
|
|
||||||
dest[2][1] = a20 * b01 + a21 * b11;
|
|
||||||
dest[2][2] = a20 * b02 + a21 * b12;
|
|
||||||
dest[2][3] = a20 * b03 + a21 * b13;
|
|
||||||
|
|
||||||
dest[3][0] = a30 * b00 + a31 * b10;
|
|
||||||
dest[3][1] = a30 * b01 + a31 * b11;
|
|
||||||
dest[3][2] = a30 * b02 + a31 * b12;
|
|
||||||
dest[3][3] = a30 * b03 + a31 * b13;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
@@ -138,13 +124,11 @@ glm_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest) {
|
glm_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) {
|
||||||
float v0 = v[0], v1 = v[1];
|
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2 + m[3][0] * v3;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2 + m[3][1] * v3;
|
||||||
dest[2] = m[2][0] * v0 + m[2][1] * v1;
|
|
||||||
dest[3] = m[3][0] * v0 + m[3][1] * v1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
CGLM_INLINE void glm_mat4x3_copy(mat4x3 mat, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat);
|
CGLM_INLINE void glm_mat4x3_zero(mat4x3 mat);
|
||||||
CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest);
|
CGLM_INLINE void glm_mat4x3_make(const float * __restrict src, mat4x3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest);
|
CGLM_INLINE void glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest);
|
CGLM_INLINE void glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
CGLM_INLINE void glm_mat4x3_transpose(mat4x3 m, mat3x4 dest);
|
||||||
CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s);
|
CGLM_INLINE void glm_mat4x3_scale(mat4x3 m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -99,16 +99,16 @@ glm_mat4x3_make(const float * __restrict src, mat4x3 dest) {
|
|||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* glm_mat4x3_mul(mat4x3, mat3x4, mat4);
|
* glm_mat4x3_mul(mat4x3, mat3x4, mat3);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x3)
|
* @param[in] m1 left matrix (mat4x3)
|
||||||
* @param[in] m2 right matrix (mat3x4)
|
* @param[in] m2 right matrix (mat3x4)
|
||||||
* @param[out] dest destination matrix (mat4)
|
* @param[out] dest destination matrix (mat3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest) {
|
glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) {
|
||||||
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
float a00 = m1[0][0], a01 = m1[0][1], a02 = m1[0][2],
|
||||||
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
a10 = m1[1][0], a11 = m1[1][1], a12 = m1[1][2],
|
||||||
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2],
|
a20 = m1[2][0], a21 = m1[2][1], a22 = m1[2][2],
|
||||||
@@ -118,29 +118,21 @@ glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest) {
|
|||||||
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3],
|
b10 = m2[1][0], b11 = m2[1][1], b12 = m2[1][2], b13 = m2[1][3],
|
||||||
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b23 = m2[2][3];
|
b20 = m2[2][0], b21 = m2[2][1], b22 = m2[2][2], b23 = m2[2][3];
|
||||||
|
|
||||||
dest[0][0] = a00 * b00 + a01 * b10 + a02 * b20;
|
dest[0][0] = a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03;
|
||||||
dest[0][1] = a00 * b01 + a01 * b11 + a02 * b21;
|
dest[0][1] = a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03;
|
||||||
dest[0][2] = a00 * b02 + a01 * b12 + a02 * b22;
|
dest[0][2] = a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03;
|
||||||
dest[0][3] = a00 * b03 + a01 * b13 + a02 * b23;
|
|
||||||
|
|
||||||
dest[1][0] = a10 * b00 + a11 * b10 + a12 * b20;
|
dest[1][0] = a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13;
|
||||||
dest[1][1] = a10 * b01 + a11 * b11 + a12 * b21;
|
dest[1][1] = a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13;
|
||||||
dest[1][2] = a10 * b02 + a11 * b12 + a12 * b22;
|
dest[1][2] = a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13;
|
||||||
dest[1][3] = a10 * b03 + a11 * b13 + a12 * b23;
|
|
||||||
|
|
||||||
dest[2][0] = a20 * b00 + a21 * b10 + a22 * b20;
|
dest[2][0] = a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23;
|
||||||
dest[2][1] = a20 * b01 + a21 * b11 + a22 * b21;
|
dest[2][1] = a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23;
|
||||||
dest[2][2] = a20 * b02 + a21 * b12 + a22 * b22;
|
dest[2][2] = a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23;
|
||||||
dest[2][3] = a20 * b03 + a21 * b13 + a22 * b23;
|
|
||||||
|
|
||||||
dest[3][0] = a30 * b00 + a31 * b10 + a32 * b20;
|
|
||||||
dest[3][1] = a30 * b01 + a31 * b11 + a32 * b21;
|
|
||||||
dest[3][2] = a30 * b02 + a31 * b12 + a32 * b22;
|
|
||||||
dest[3][3] = a30 * b03 + a31 * b13 + a32 * b23;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
@@ -148,13 +140,12 @@ glm_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest) {
|
glm_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) {
|
||||||
float v0 = v[0], v1 = v[1], v2 = v[2];
|
float v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
||||||
|
|
||||||
dest[0] = m[0][0] * v0 + m[0][1] * v1 + m[0][2] * v2;
|
dest[0] = m[0][0] * v0 + m[1][0] * v1 + m[2][0] * v2 + m[3][0] * v3;
|
||||||
dest[1] = m[1][0] * v0 + m[1][1] * v1 + m[1][2] * v2;
|
dest[1] = m[0][1] * v0 + m[1][1] * v1 + m[2][1] * v2 + m[3][1] * v3;
|
||||||
dest[2] = m[2][0] * v0 + m[2][1] * v1 + m[2][2] * v2;
|
dest[2] = m[0][2] * v0 + m[1][2] * v1 + m[2][2] * v2 + m[3][2] * v3;
|
||||||
dest[3] = m[3][0] * v0 + m[3][1] * v1 + m[3][2] * v2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
# if (defined(_M_AMD64) || defined(_M_X64)) || _M_IX86_FP == 2
|
# if (defined(_M_AMD64) || defined(_M_X64)) || _M_IX86_FP == 2
|
||||||
|
# ifndef __SSE__
|
||||||
|
# define __SSE__
|
||||||
|
# endif
|
||||||
# ifndef __SSE2__
|
# ifndef __SSE2__
|
||||||
# define __SSE2__
|
# define __SSE2__
|
||||||
# endif
|
# endif
|
||||||
@@ -24,15 +27,22 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined(__SSE__)
|
||||||
# include <xmmintrin.h>
|
# include <xmmintrin.h>
|
||||||
# include <emmintrin.h>
|
|
||||||
# define CGLM_SSE_FP 1
|
# define CGLM_SSE_FP 1
|
||||||
# ifndef CGLM_SIMD_x86
|
# ifndef CGLM_SIMD_x86
|
||||||
# define CGLM_SIMD_x86
|
# define CGLM_SIMD_x86
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SSE2__)
|
||||||
|
# include <emmintrin.h>
|
||||||
|
# define CGLM_SSE2_FP 1
|
||||||
|
# ifndef CGLM_SIMD_x86
|
||||||
|
# define CGLM_SIMD_x86
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__SSE3__)
|
#if defined(__SSE3__)
|
||||||
# include <pmmintrin.h>
|
# include <pmmintrin.h>
|
||||||
# ifndef CGLM_SIMD_x86
|
# ifndef CGLM_SIMD_x86
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define glmm_set1(x) _mm_set1_ps(x)
|
#define glmm_set1(x) _mm_set1_ps(x)
|
||||||
#define glmm_128 __m128
|
#define glmm_128 __m128
|
||||||
|
|
||||||
#ifdef CGLM_USE_INT_DOMAIN
|
#if defined(CGLM_USE_INT_DOMAIN) && defined(__SSE2__)
|
||||||
# define glmm_shuff1(xmm, z, y, x, w) \
|
# define glmm_shuff1(xmm, z, y, x, w) \
|
||||||
_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(xmm), \
|
_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(xmm), \
|
||||||
_MM_SHUFFLE(z, y, x, w)))
|
_MM_SHUFFLE(z, y, x, w)))
|
||||||
@@ -55,17 +55,40 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Note that `0x80000000` corresponds to `INT_MIN` for a 32-bit int. */
|
/* Note that `0x80000000` corresponds to `INT_MIN` for a 32-bit int. */
|
||||||
#define GLMM_NEGZEROf ((int)0x80000000) /* 0x80000000 ---> -0.0f */
|
|
||||||
|
|
||||||
#define GLMM__SIGNMASKf(X, Y, Z, W) \
|
#if defined(__SSE2__)
|
||||||
|
# define GLMM_NEGZEROf ((int)0x80000000) /* 0x80000000 ---> -0.0f */
|
||||||
|
# define GLMM_POSZEROf ((int)0x00000000) /* 0x00000000 ---> +0.0f */
|
||||||
|
#else
|
||||||
|
# ifdef CGLM_FAST_MATH
|
||||||
|
union { int i; float f; } static GLMM_NEGZEROf_TU = { .i = (int)0x80000000 };
|
||||||
|
# define GLMM_NEGZEROf GLMM_NEGZEROf_TU.f
|
||||||
|
# define GLMM_POSZEROf 0.0f
|
||||||
|
# else
|
||||||
|
# define GLMM_NEGZEROf -0.0f
|
||||||
|
# define GLMM_POSZEROf 0.0f
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SSE2__)
|
||||||
|
# define GLMM__SIGNMASKf(X, Y, Z, W) \
|
||||||
_mm_castsi128_ps(_mm_set_epi32(X, Y, Z, W))
|
_mm_castsi128_ps(_mm_set_epi32(X, Y, Z, W))
|
||||||
/* _mm_set_ps(X, Y, Z, W); */
|
/* _mm_set_ps(X, Y, Z, W); */
|
||||||
|
#else
|
||||||
|
# define GLMM__SIGNMASKf(X, Y, Z, W) _mm_set_ps(X, Y, Z, W)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define glmm_float32x4_SIGNMASK_PNPN GLMM__SIGNMASKf(0, GLMM_NEGZEROf, 0, GLMM_NEGZEROf)
|
#define glmm_float32x4_SIGNMASK_PNPN GLMM__SIGNMASKf(GLMM_POSZEROf, GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_NEGZEROf)
|
||||||
#define glmm_float32x4_SIGNMASK_NPNP GLMM__SIGNMASKf(GLMM_NEGZEROf, 0, GLMM_NEGZEROf, 0)
|
#define glmm_float32x4_SIGNMASK_NPNP GLMM__SIGNMASKf(GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_NEGZEROf, GLMM_POSZEROf)
|
||||||
#define glmm_float32x4_SIGNMASK_NPPN GLMM__SIGNMASKf(GLMM_NEGZEROf, 0, 0, GLMM_NEGZEROf)
|
#define glmm_float32x4_SIGNMASK_NPPN GLMM__SIGNMASKf(GLMM_NEGZEROf, GLMM_POSZEROf, GLMM_POSZEROf, GLMM_NEGZEROf)
|
||||||
|
|
||||||
|
/* fasth math prevents -0.0f to work */
|
||||||
|
#if defined(__SSE2__)
|
||||||
|
# define glmm_float32x4_SIGNMASK_NEG _mm_castsi128_ps(_mm_set1_epi32(GLMM_NEGZEROf)) /* _mm_set1_ps(-0.0f) */
|
||||||
|
#else
|
||||||
|
# define glmm_float32x4_SIGNMASK_NEG _mm_set1_ps(GLMM_NEGZEROf)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define glmm_float32x4_SIGNMASK_NEG _mm_castsi128_ps(_mm_set1_epi32(GLMM_NEGZEROf)) /* _mm_set1_ps(-0.0f) */
|
|
||||||
#define glmm_float32x8_SIGNMASK_NEG _mm256_castsi256_ps(_mm256_set1_epi32(GLMM_NEGZEROf))
|
#define glmm_float32x8_SIGNMASK_NEG _mm256_castsi256_ps(_mm256_set1_epi32(GLMM_NEGZEROf))
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
@@ -207,6 +230,7 @@ glmm_norm_inf(__m128 a) {
|
|||||||
return _mm_cvtss_f32(glmm_vhmax(glmm_abs(a)));
|
return _mm_cvtss_f32(glmm_vhmax(glmm_abs(a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__SSE2__)
|
||||||
static inline
|
static inline
|
||||||
__m128
|
__m128
|
||||||
glmm_load3(float v[3]) {
|
glmm_load3(float v[3]) {
|
||||||
@@ -225,6 +249,7 @@ glmm_store3(float v[3], __m128 vx) {
|
|||||||
_mm_storel_pi(CGLM_CASTPTR_ASSUME_ALIGNED(v, __m64), vx);
|
_mm_storel_pi(CGLM_CASTPTR_ASSUME_ALIGNED(v, __m64), vx);
|
||||||
_mm_store_ss(&v[2], glmm_shuff1(vx, 2, 2, 2, 2));
|
_mm_store_ss(&v[2], glmm_shuff1(vx, 2, 2, 2, 2));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
__m128
|
__m128
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
CGLM_INLINE mat2x3s glms_mat2x3_zero(void);
|
CGLM_INLINE mat2x3s glms_mat2x3_zero(void);
|
||||||
CGLM_INLINE mat2x3s glms_mat2x3_make(const float * __restrict src);
|
CGLM_INLINE mat2x3s glms_mat2x3_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat2s glms_mat2x3_mul(mat2x3s m1, mat3x2s m2);
|
CGLM_INLINE mat2s glms_mat2x3_mul(mat2x3s m1, mat3x2s m2);
|
||||||
CGLM_INLINE vec2s glms_mat2x3_mulv(mat2x3s m, vec3s v);
|
CGLM_INLINE vec3s glms_mat2x3_mulv(mat2x3s m, vec2s v);
|
||||||
CGLM_INLINE mat3x2s glms_mat2x3_transpose(mat2x3s m);
|
CGLM_INLINE mat3x2s glms_mat2x3_transpose(mat2x3s m);
|
||||||
CGLM_INLINE mat2x3s glms_mat2x3_scale(mat2x3s m, float s);
|
CGLM_INLINE mat2x3s glms_mat2x3_scale(mat2x3s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -73,9 +73,9 @@ glms_mat2x3_(make)(const float * __restrict src) {
|
|||||||
* @returns destination matrix (mat2s)
|
* @returns destination matrix (mat2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat3s
|
||||||
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
||||||
mat2s r;
|
mat3s r;
|
||||||
glm_mat2x3_mul(m1.raw, m2.raw, r.raw);
|
glm_mat2x3_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -85,12 +85,12 @@ glms_mat2x3_(mul)(mat2x3s m1, mat3x2s m2) {
|
|||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @returns destination vector (vec3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec3s
|
||||||
glms_mat2x3_(mulv)(mat2x3s m, vec3s v) {
|
glms_mat2x3_(mulv)(mat2x3s m, vec2s v) {
|
||||||
vec2s r;
|
vec3s r;
|
||||||
glm_mat2x3_mulv(m.raw, v.raw, r.raw);
|
glm_mat2x3_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
CGLM_INLINE mat2x4s glms_mat2x4_zero(void);
|
CGLM_INLINE mat2x4s glms_mat2x4_zero(void);
|
||||||
CGLM_INLINE mat2x4s glms_mat2x4_make(const float * __restrict src);
|
CGLM_INLINE mat2x4s glms_mat2x4_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat2s glms_mat2x4_mul(mat2x4s m1, mat4x2s m2);
|
CGLM_INLINE mat2s glms_mat2x4_mul(mat2x4s m1, mat4x2s m2);
|
||||||
CGLM_INLINE vec2s glms_mat2x4_mulv(mat2x4s m, vec4s v);
|
CGLM_INLINE vec4s glms_mat2x4_mulv(mat2x4s m, vec2s v);
|
||||||
CGLM_INLINE mat4x2s glms_mat2x4_transpose(mat2x4s m);
|
CGLM_INLINE mat4x2s glms_mat2x4_transpose(mat2x4s m);
|
||||||
CGLM_INLINE mat2x4s glms_mat2x4_scale(mat2x4s m, float s);
|
CGLM_INLINE mat2x4s glms_mat2x4_scale(mat2x4s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -73,24 +73,24 @@ glms_mat2x4_(make)(const float * __restrict src) {
|
|||||||
* @returns destination matrix (mat2s)
|
* @returns destination matrix (mat2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat2s
|
mat4s
|
||||||
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
|
glms_mat2x4_(mul)(mat2x4s m1, mat4x2s m2) {
|
||||||
mat2s r;
|
mat4s r;
|
||||||
glm_mat2x4_mul(m1.raw, m2.raw, r.raw);
|
glm_mat2x4_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @param[out] dest result vector
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec4s
|
||||||
glms_mat2x4_(mulv)(mat2x4s m, vec4s v) {
|
glms_mat2x4_(mulv)(mat2x4s m, vec2s v) {
|
||||||
vec2s r;
|
vec4s r;
|
||||||
glm_mat2x4_mulv(m.raw, v.raw, r.raw);
|
glm_mat2x4_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE mat3x2s glms_mat3x2_zero(void);
|
CGLM_INLINE mat3x2s glms_mat3x2_zero(void);
|
||||||
CGLM_INLINE mat3x2s glms_mat3x2_make(const float * __restrict src);
|
CGLM_INLINE mat3x2s glms_mat3x2_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat3s glms_mat3x2_mul(mat3x2s m1, mat2x3s m2);
|
CGLM_INLINE mat2s glms_mat3x2_mul(mat3x2s m1, mat2x3s m2);
|
||||||
CGLM_INLINE vec3s glms_mat3x2_mulv(mat3x2s m, vec2s v);
|
CGLM_INLINE vec2s glms_mat3x2_mulv(mat3x2s m, vec3s v);
|
||||||
CGLM_INLINE mat2x3s glms_mat3x2_transpose(mat3x2s m);
|
CGLM_INLINE mat2x3s glms_mat3x2_transpose(mat3x2s m);
|
||||||
CGLM_INLINE mat3x2s glms_mat3x2_scale(mat3x2s m, float s);
|
CGLM_INLINE mat3x2s glms_mat3x2_scale(mat3x2s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -73,9 +73,9 @@ glms_mat3x2_(make)(const float * __restrict src) {
|
|||||||
* @returns destination matrix (mat3s)
|
* @returns destination matrix (mat3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat2s
|
||||||
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
||||||
mat3s r;
|
mat2s r;
|
||||||
glm_mat3x2_mul(m1.raw, m2.raw, r.raw);
|
glm_mat3x2_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -88,9 +88,9 @@ glms_mat3x2_(mul)(mat3x2s m1, mat2x3s m2) {
|
|||||||
* @param[out] dest result vector
|
* @param[out] dest result vector
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec2s
|
||||||
glms_mat3x2_(mulv)(mat3x2s m, vec2s v) {
|
glms_mat3x2_(mulv)(mat3x2s m, vec3s v) {
|
||||||
vec3s r;
|
vec2s r;
|
||||||
glm_mat3x2_mulv(m.raw, v.raw, r.raw);
|
glm_mat3x2_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE mat3x4s glms_mat3x4_zero(void);
|
CGLM_INLINE mat3x4s glms_mat3x4_zero(void);
|
||||||
CGLM_INLINE mat3x4s glms_mat3x4_make(const float * __restrict src);
|
CGLM_INLINE mat3x4s glms_mat3x4_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat3s glms_mat3x4_mul(mat3x4s m1, mat4x3s m2);
|
CGLM_INLINE mat4s glms_mat3x4_mul(mat3x4s m1, mat4x3s m2);
|
||||||
CGLM_INLINE vec3s glms_mat3x4_mulv(mat3x4s m, vec4s v);
|
CGLM_INLINE vec4s glms_mat3x4_mulv(mat3x4s m, vec3s v);
|
||||||
CGLM_INLINE mat4x3s glms_mat3x4_transpose(mat3x4s m);
|
CGLM_INLINE mat4x3s glms_mat3x4_transpose(mat3x4s m);
|
||||||
CGLM_INLINE mat3x4s glms_mat3x4_scale(mat3x4s m, float s);
|
CGLM_INLINE mat3x4s glms_mat3x4_scale(mat3x4s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -70,27 +70,27 @@ glms_mat3x4_(make)(const float * __restrict src) {
|
|||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat3x4s)
|
* @param[in] m1 left matrix (mat3x4s)
|
||||||
* @param[in] m2 right matrix (mat4x3s)
|
* @param[in] m2 right matrix (mat4x3s)
|
||||||
* @returns destination matrix (mat3s)
|
* @returns destination matrix (mat4s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat3s
|
mat4s
|
||||||
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
|
glms_mat3x4_(mul)(mat3x4s m1, mat4x3s m2) {
|
||||||
mat3s r;
|
mat4s r;
|
||||||
glm_mat3x4_mul(m1.raw, m2.raw, r.raw);
|
glm_mat3x4_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @returns destination vector (vec4s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec4s
|
||||||
glms_mat3x4_(mulv)(mat3x4s m, vec4s v) {
|
glms_mat3x4_(mulv)(mat3x4s m, vec3s v) {
|
||||||
vec3s r;
|
vec4s r;
|
||||||
glm_mat3x4_mulv(m.raw, v.raw, r.raw);
|
glm_mat3x4_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE mat4x2s glms_mat4x2_zero(void);
|
CGLM_INLINE mat4x2s glms_mat4x2_zero(void);
|
||||||
CGLM_INLINE mat4x2s glms_mat4x2_make(const float * __restrict src);
|
CGLM_INLINE mat4x2s glms_mat4x2_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat4s glms_mat4x2_mul(mat4x2s m1, mat2x4s m2);
|
CGLM_INLINE mat2s glms_mat4x2_mul(mat4x2s m1, mat2x4s m2);
|
||||||
CGLM_INLINE vec4s glms_mat4x2_mulv(mat4x2s m, vec2s v);
|
CGLM_INLINE vec2s glms_mat4x2_mulv(mat4x2s m, vec4s v);
|
||||||
CGLM_INLINE mat2x4s glms_mat4x2_transpose(mat4x2s m);
|
CGLM_INLINE mat2x4s glms_mat4x2_transpose(mat4x2s m);
|
||||||
CGLM_INLINE mat4x2s glms_mat4x2_scale(mat4x2s m, float s);
|
CGLM_INLINE mat4x2s glms_mat4x2_scale(mat4x2s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -71,27 +71,27 @@ glms_mat4x2_(make)(const float * __restrict src) {
|
|||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x2s)
|
* @param[in] m1 left matrix (mat4x2s)
|
||||||
* @param[in] m2 right matrix (mat2x4s)
|
* @param[in] m2 right matrix (mat2x4s)
|
||||||
* @returns destination matrix (mat4s)
|
* @returns destination matrix (mat2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat2s
|
||||||
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
|
glms_mat4x2_(mul)(mat4x2s m1, mat2x4s m2) {
|
||||||
mat4s r;
|
mat2s r;
|
||||||
glm_mat4x2_mul(m1.raw, m2.raw, r.raw);
|
glm_mat4x2_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply matrix with column vector and store in dest vector
|
* @brief multiply matrix with column vector and store in dest column vector
|
||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @returns destination vector (vec2s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec4s
|
vec2s
|
||||||
glms_mat4x2_(mulv)(mat4x2s m, vec2s v) {
|
glms_mat4x2_(mulv)(mat4x2s m, vec4s v) {
|
||||||
vec4s r;
|
vec2s r;
|
||||||
glm_mat4x2_mulv(m.raw, v.raw, r.raw);
|
glm_mat4x2_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE mat4x3s glms_mat4x3_zero(void);
|
CGLM_INLINE mat4x3s glms_mat4x3_zero(void);
|
||||||
CGLM_INLINE mat4x3s glms_mat4x3_make(const float * __restrict src);
|
CGLM_INLINE mat4x3s glms_mat4x3_make(const float * __restrict src);
|
||||||
CGLM_INLINE mat4s glms_mat4x3_mul(mat4x3s m1, mat3x4s m2);
|
CGLM_INLINE mat3s glms_mat4x3_mul(mat4x3s m1, mat3x4s m2);
|
||||||
CGLM_INLINE vec4s glms_mat4x3_mulv(mat4x3s m, vec3s v);
|
CGLM_INLINE vec3s glms_mat4x3_mulv(mat4x3s m, vec4s v);
|
||||||
CGLM_INLINE mat3x4s glms_mat4x3_transpose(mat4x3s m);
|
CGLM_INLINE mat3x4s glms_mat4x3_transpose(mat4x3s m);
|
||||||
CGLM_INLINE mat4x3s glms_mat4x3_scale(mat4x3s m, float s);
|
CGLM_INLINE mat4x3s glms_mat4x3_scale(mat4x3s m, float s);
|
||||||
*/
|
*/
|
||||||
@@ -70,12 +70,12 @@ glms_mat4x3_(make)(const float * __restrict src) {
|
|||||||
*
|
*
|
||||||
* @param[in] m1 left matrix (mat4x3s)
|
* @param[in] m1 left matrix (mat4x3s)
|
||||||
* @param[in] m2 right matrix (mat3x4s)
|
* @param[in] m2 right matrix (mat3x4s)
|
||||||
* @returns destination matrix (mat4s)
|
* @returns destination matrix (mat3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
mat4s
|
mat3s
|
||||||
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
||||||
mat4s r;
|
mat3s r;
|
||||||
glm_mat4x3_mul(m1.raw, m2.raw, r.raw);
|
glm_mat4x3_mul(m1.raw, m2.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -85,12 +85,12 @@ glms_mat4x3_(mul)(mat4x3s m1, mat3x4s m2) {
|
|||||||
*
|
*
|
||||||
* @param[in] m matrix (left)
|
* @param[in] m matrix (left)
|
||||||
* @param[in] v vector (right, column vector)
|
* @param[in] v vector (right, column vector)
|
||||||
* @param[out] dest result vector
|
* @returns destination vector (vec3s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec4s
|
vec3s
|
||||||
glms_mat4x3_(mulv)(mat4x3s m, vec3s v) {
|
glms_mat4x3_(mulv)(mat4x3s m, vec4s v) {
|
||||||
vec4s r;
|
vec3s r;
|
||||||
glm_mat4x3_mulv(m.raw, v.raw, r.raw);
|
glm_mat4x3_mulv(m.raw, v.raw, r.raw);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@
|
|||||||
CGLM_INLINE vec2s glms_vec2_clamp(vec2s v, float minVal, float maxVal)
|
CGLM_INLINE vec2s glms_vec2_clamp(vec2s v, float minVal, float maxVal)
|
||||||
CGLM_INLINE vec2s glms_vec2_lerp(vec2s from, vec2s to, float t)
|
CGLM_INLINE vec2s glms_vec2_lerp(vec2s from, vec2s to, float t)
|
||||||
CGLM_INLINE vec2s glms_vec2_make(float * restrict src)
|
CGLM_INLINE vec2s glms_vec2_make(float * restrict src)
|
||||||
CGLM_INLINE vec2s glms_vec2_reflect(vec2s I, vec2s N)
|
CGLM_INLINE vec2s glms_vec2_reflect(vec2s v, vec2s n)
|
||||||
CGLM_INLINE bool glms_vec2_refract(vec2s I, vec2s N, float eta, vec2s *dest)
|
CGLM_INLINE bool glms_vec2_refract(vec2s v, vec2s n, float eta, vec2s *dest)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_vec2s_h
|
#ifndef cglms_vec2s_h
|
||||||
@@ -702,9 +702,9 @@ glms_vec2_(make)(const float * __restrict src) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec2s
|
vec2s
|
||||||
glms_vec2_(reflect)(vec2s I, vec2s N) {
|
glms_vec2_(reflect)(vec2s v, vec2s n) {
|
||||||
vec2s dest;
|
vec2s dest;
|
||||||
glm_vec2_reflect(I.raw, N.raw, dest.raw);
|
glm_vec2_reflect(v.raw, n.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,8 +715,8 @@ glms_vec2_(reflect)(vec2s I, vec2s N) {
|
|||||||
* occurs (angle too great given eta), dest is set to zero and returns false.
|
* occurs (angle too great given eta), dest is set to zero and returns false.
|
||||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -724,8 +724,8 @@ glms_vec2_(reflect)(vec2s I, vec2s N) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glms_vec2_(refract)(vec2s I, vec2s N, float eta, vec2s * __restrict dest) {
|
glms_vec2_(refract)(vec2s v, vec2s n, float eta, vec2s * __restrict dest) {
|
||||||
return glm_vec2_refract(I.raw, N.raw, eta, dest->raw);
|
return glm_vec2_refract(v.raw, n.raw, eta, dest->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* cglms_vec2s_h */
|
#endif /* cglms_vec2s_h */
|
||||||
|
|||||||
@@ -76,9 +76,9 @@
|
|||||||
CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t);
|
CGLM_INLINE vec3s glms_vec3_smoothinterpc(vec3s from, vec3s to, float t);
|
||||||
CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask);
|
CGLM_INLINE vec3s glms_vec3_swizzle(vec3s v, int mask);
|
||||||
CGLM_INLINE vec3s glms_vec3_make(float * restrict src);
|
CGLM_INLINE vec3s glms_vec3_make(float * restrict src);
|
||||||
CGLM_INLINE vec3s glms_vec3_faceforward(vec3s N, vec3s I, vec3s Nref);
|
CGLM_INLINE vec3s glms_vec3_faceforward(vec3s n, vec3s v, vec3s nref);
|
||||||
CGLM_INLINE vec3s glms_vec3_reflect(vec3s I, vec3s N);
|
CGLM_INLINE vec3s glms_vec3_reflect(vec3s v, vec3s n);
|
||||||
CGLM_INLINE bool glms_vec3_refract(vec3s I, vec3s N, float eta, vec3s *dest)
|
CGLM_INLINE bool glms_vec3_refract(vec3s v, vec3s n, float eta, vec3s *dest)
|
||||||
|
|
||||||
Convenient:
|
Convenient:
|
||||||
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
|
CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b);
|
||||||
@@ -1091,16 +1091,16 @@ glms_vec3_(make)(const float * __restrict src) {
|
|||||||
*
|
*
|
||||||
* orients a vector to point away from a surface as defined by its normal
|
* orients a vector to point away from a surface as defined by its normal
|
||||||
*
|
*
|
||||||
* @param[in] N vector to orient.
|
* @param[in] n vector to orient.
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] Nref reference vector
|
* @param[in] nref reference vector
|
||||||
* @returns oriented vector, pointing away from the surface.
|
* @returns oriented vector, pointing away from the surface.
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_vec3_(faceforward)(vec3s N, vec3s I, vec3s Nref) {
|
glms_vec3_(faceforward)(vec3s n, vec3s v, vec3s nref) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_vec3_faceforward(N.raw, I.raw, Nref.raw, dest.raw);
|
glm_vec3_faceforward(n.raw, v.raw, nref.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,9 +1113,9 @@ glms_vec3_(faceforward)(vec3s N, vec3s I, vec3s Nref) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec3s
|
vec3s
|
||||||
glms_vec3_(reflect)(vec3s I, vec3s N) {
|
glms_vec3_(reflect)(vec3s v, vec3s n) {
|
||||||
vec3s dest;
|
vec3s dest;
|
||||||
glm_vec3_reflect(I.raw, N.raw, dest.raw);
|
glm_vec3_reflect(v.raw, n.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1126,8 +1126,8 @@ glms_vec3_(reflect)(vec3s I, vec3s N) {
|
|||||||
* occurs (angle too great given eta), dest is set to zero and returns false.
|
* occurs (angle too great given eta), dest is set to zero and returns false.
|
||||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -1135,8 +1135,8 @@ glms_vec3_(reflect)(vec3s I, vec3s N) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glms_vec3_(refract)(vec3s I, vec3s N, float eta, vec3s * __restrict dest) {
|
glms_vec3_(refract)(vec3s v, vec3s n, float eta, vec3s * __restrict dest) {
|
||||||
return glm_vec3_refract(I.raw, N.raw, eta, dest->raw);
|
return glm_vec3_refract(v.raw, n.raw, eta, dest->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* cglms_vec3s_h */
|
#endif /* cglms_vec3s_h */
|
||||||
|
|||||||
@@ -67,8 +67,8 @@
|
|||||||
CGLM_INLINE vec4s glms_vec4_cubic(float s);
|
CGLM_INLINE vec4s glms_vec4_cubic(float s);
|
||||||
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
|
CGLM_INLINE vec4s glms_vec4_swizzle(vec4s v, int mask);
|
||||||
CGLM_INLINE vec4s glms_vec4_make(float * restrict src);
|
CGLM_INLINE vec4s glms_vec4_make(float * restrict src);
|
||||||
CGLM_INLINE vec4s glms_vec4_reflect(vec4s I, vec4s N);
|
CGLM_INLINE vec4s glms_vec4_reflect(vec4s v, vec4s n);
|
||||||
CGLM_INLINE bool glms_vec4_refract(vec4s I, vec4s N, float eta, vec4s *dest)
|
CGLM_INLINE bool glms_vec4_refract(vec4s v, vec4s n, float eta, vec4s *dest)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglms_vec4s_h
|
#ifndef cglms_vec4s_h
|
||||||
@@ -932,15 +932,15 @@ glms_vec4_(make)(const float * __restrict src) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief reflection vector using an incident ray and a surface normal
|
* @brief reflection vector using an incident ray and a surface normal
|
||||||
*
|
*
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @returns reflection result
|
* @returns reflection result
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
vec4s
|
vec4s
|
||||||
glms_vec4_(reflect)(vec4s I, vec4s N) {
|
glms_vec4_(reflect)(vec4s v, vec4s n) {
|
||||||
vec4s dest;
|
vec4s dest;
|
||||||
glm_vec4_reflect(I.raw, N.raw, dest.raw);
|
glm_vec4_reflect(v.raw, n.raw, dest.raw);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -955,8 +955,8 @@ glms_vec4_(reflect)(vec4s I, vec4s N) {
|
|||||||
* incident vector 'I' in the output 'dest', users requiring the preservation of
|
* incident vector 'I' in the output 'dest', users requiring the preservation of
|
||||||
* the 'w' component should manually adjust 'dest' after calling this function.
|
* the 'w' component should manually adjust 'dest' after calling this function.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -964,8 +964,8 @@ glms_vec4_(reflect)(vec4s I, vec4s N) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glms_vec4_(refract)(vec4s I, vec4s N, float eta, vec4s * __restrict dest) {
|
glms_vec4_(refract)(vec4s v, vec4s n, float eta, vec4s * __restrict dest) {
|
||||||
return glm_vec4_refract(I.raw, N.raw, eta, dest->raw);
|
return glm_vec4_refract(v.raw, n.raw, eta, dest->raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* cglms_vec4s_h */
|
#endif /* cglms_vec4s_h */
|
||||||
|
|||||||
@@ -55,8 +55,8 @@
|
|||||||
CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
|
CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
|
||||||
CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
|
CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
|
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest)
|
CGLM_INLINE void glm_vec2_reflect(vec2 v, vec2 n, vec2 dest)
|
||||||
CGLM_INLINE void glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest)
|
CGLM_INLINE void glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef cglm_vec2_h
|
#ifndef cglm_vec2_h
|
||||||
@@ -716,16 +716,16 @@ glm_vec2_make(const float * __restrict src, vec2 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief reflection vector using an incident ray and a surface normal
|
* @brief reflection vector using an incident ray and a surface normal
|
||||||
*
|
*
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[out] dest destination vector for the reflection result
|
* @param[out] dest destination vector for the reflection result
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
glm_vec2_reflect(vec2 v, vec2 n, vec2 dest) {
|
||||||
vec2 temp;
|
vec2 temp;
|
||||||
glm_vec2_scale(N, 2.0f * glm_vec2_dot(I, N), temp);
|
glm_vec2_scale(n, 2.0f * glm_vec2_dot(v, n), temp);
|
||||||
glm_vec2_sub(I, temp, dest);
|
glm_vec2_sub(v, temp, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -735,8 +735,8 @@ glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
|||||||
* occurs (angle too great given eta), dest is set to zero and returns false.
|
* occurs (angle too great given eta), dest is set to zero and returns false.
|
||||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -744,10 +744,10 @@ glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) {
|
glm_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
|
||||||
float ndi, eni, k;
|
float ndi, eni, k;
|
||||||
|
|
||||||
ndi = glm_vec2_dot(N, I);
|
ndi = glm_vec2_dot(n, v);
|
||||||
eni = eta * ndi;
|
eni = eta * ndi;
|
||||||
k = 1.0f + eta * eta - eni * eni;
|
k = 1.0f + eta * eta - eni * eni;
|
||||||
|
|
||||||
@@ -756,8 +756,8 @@ glm_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm_vec2_scale(I, eta, dest);
|
glm_vec2_scale(v, eta, dest);
|
||||||
glm_vec2_mulsubs(N, eni + sqrtf(k), dest);
|
glm_vec2_mulsubs(n, eni + sqrtf(k), dest);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,9 @@
|
|||||||
CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest);
|
CGLM_INLINE void glm_vec3_smoothinterpc(vec3 from, vec3 to, float t, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest);
|
CGLM_INLINE void glm_vec3_swizzle(vec3 v, int mask, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest);
|
CGLM_INLINE void glm_vec3_make(float * restrict src, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest);
|
CGLM_INLINE void glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_reflect(vec3 I, vec3 N, vec3 dest);
|
CGLM_INLINE void glm_vec3_reflect(vec3 v, vec3 n, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest);
|
CGLM_INLINE void glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest);
|
||||||
|
|
||||||
Convenient:
|
Convenient:
|
||||||
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
|
CGLM_INLINE void glm_cross(vec3 a, vec3 b, vec3 d);
|
||||||
@@ -1210,36 +1210,36 @@ glm_vec3_make(const float * __restrict src, vec3 dest) {
|
|||||||
*
|
*
|
||||||
* orients a vector to point away from a surface as defined by its normal
|
* orients a vector to point away from a surface as defined by its normal
|
||||||
*
|
*
|
||||||
* @param[in] N vector to orient
|
* @param[in] n vector to orient
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] Nref reference vector
|
* @param[in] nref reference vector
|
||||||
* @param[out] dest oriented vector, pointing away from the surface
|
* @param[out] dest oriented vector, pointing away from the surface
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) {
|
glm_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) {
|
||||||
if (glm_vec3_dot(I, Nref) < 0.0f) {
|
if (glm_vec3_dot(v, nref) < 0.0f) {
|
||||||
/* N is facing away from I */
|
/* N is facing away from I */
|
||||||
glm_vec3_copy(N, dest);
|
glm_vec3_copy(n, dest);
|
||||||
} else {
|
} else {
|
||||||
/* N is facing towards I, negate it */
|
/* N is facing towards I, negate it */
|
||||||
glm_vec3_negate_to(N, dest);
|
glm_vec3_negate_to(n, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief reflection vector using an incident ray and a surface normal
|
* @brief reflection vector using an incident ray and a surface normal
|
||||||
*
|
*
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[out] dest reflection result
|
* @param[out] dest reflection result
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
|
glm_vec3_reflect(vec3 v, vec3 n, vec3 dest) {
|
||||||
vec3 temp;
|
vec3 temp;
|
||||||
glm_vec3_scale(N, 2.0f * glm_vec3_dot(I, N), temp);
|
glm_vec3_scale(n, 2.0f * glm_vec3_dot(v, n), temp);
|
||||||
glm_vec3_sub(I, temp, dest);
|
glm_vec3_sub(v, temp, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1249,8 +1249,8 @@ glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
|
|||||||
* occurs (angle too great given eta), dest is set to zero and returns false.
|
* occurs (angle too great given eta), dest is set to zero and returns false.
|
||||||
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
* Otherwise, computes refraction vector, stores it in dest, and returns true.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -1258,10 +1258,10 @@ glm_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) {
|
glm_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
|
||||||
float ndi, eni, k;
|
float ndi, eni, k;
|
||||||
|
|
||||||
ndi = glm_vec3_dot(N, I);
|
ndi = glm_vec3_dot(n, v);
|
||||||
eni = eta * ndi;
|
eni = eta * ndi;
|
||||||
k = 1.0f + eta * eta - eni * eni;
|
k = 1.0f + eta * eta - eni * eni;
|
||||||
|
|
||||||
@@ -1270,8 +1270,8 @@ glm_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm_vec3_scale(I, eta, dest);
|
glm_vec3_scale(v, eta, dest);
|
||||||
glm_vec3_mulsubs(N, eni + sqrtf(k), dest);
|
glm_vec3_mulsubs(n, eni + sqrtf(k), dest);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,8 @@
|
|||||||
CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest);
|
CGLM_INLINE void glm_vec4_smoothinterpc(vec4 from, vec4 to, float t, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest);
|
CGLM_INLINE void glm_vec4_swizzle(vec4 v, int mask, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
|
CGLM_INLINE void glm_vec4_make(float * restrict src, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_reflect(vec4 I, vec4 N, vec4 dest);
|
CGLM_INLINE void glm_vec4_reflect(vec4 v, vec4 n, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest);
|
CGLM_INLINE void glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest);
|
||||||
|
|
||||||
DEPRECATED:
|
DEPRECATED:
|
||||||
glm_vec4_dup
|
glm_vec4_dup
|
||||||
@@ -1309,20 +1309,20 @@ glm_vec4_make(const float * __restrict src, vec4 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief reflection vector using an incident ray and a surface normal
|
* @brief reflection vector using an incident ray and a surface normal
|
||||||
*
|
*
|
||||||
* @param[in] I incident vector
|
* @param[in] v incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[out] dest destination vector for the reflection result
|
* @param[out] dest destination vector for the reflection result
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
|
glm_vec4_reflect(vec4 v, vec4 n, vec4 dest) {
|
||||||
vec4 temp;
|
vec4 temp;
|
||||||
|
|
||||||
/* TODO: direct simd touch */
|
/* TODO: direct simd touch */
|
||||||
glm_vec4_scale(N, 2.0f * glm_vec4_dot(I, N), temp);
|
glm_vec4_scale(n, 2.0f * glm_vec4_dot(v, n), temp);
|
||||||
glm_vec4_sub(I, temp, dest);
|
glm_vec4_sub(v, temp, dest);
|
||||||
|
|
||||||
dest[3] = I[3];
|
dest[3] = v[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1336,8 +1336,8 @@ glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
|
|||||||
* incident vector 'I' in the output 'dest', users requiring the preservation of
|
* incident vector 'I' in the output 'dest', users requiring the preservation of
|
||||||
* the 'w' component should manually adjust 'dest' after calling this function.
|
* the 'w' component should manually adjust 'dest' after calling this function.
|
||||||
*
|
*
|
||||||
* @param[in] I normalized incident vector
|
* @param[in] v normalized incident vector
|
||||||
* @param[in] N normalized normal vector
|
* @param[in] n normalized normal vector
|
||||||
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
* @param[in] eta ratio of indices of refraction (incident/transmitted)
|
||||||
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
* @param[out] dest refraction vector if refraction occurs; zero vector otherwise
|
||||||
*
|
*
|
||||||
@@ -1345,10 +1345,10 @@ glm_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) {
|
glm_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
|
||||||
float ndi, eni, k;
|
float ndi, eni, k;
|
||||||
|
|
||||||
ndi = glm_vec4_dot(N, I);
|
ndi = glm_vec4_dot(n, v);
|
||||||
eni = eta * ndi;
|
eni = eta * ndi;
|
||||||
k = 1.0f + eta * eta - eni * eni;
|
k = 1.0f + eta * eta - eni * eni;
|
||||||
|
|
||||||
@@ -1357,8 +1357,8 @@ glm_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm_vec4_scale(I, eta, dest);
|
glm_vec4_scale(v, eta, dest);
|
||||||
glm_vec4_mulsubs(N, eni + sqrtf(k), dest);
|
glm_vec4_mulsubs(n, eni + sqrtf(k), dest);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 9
|
#define CGLM_VERSION_MINOR 9
|
||||||
#define CGLM_VERSION_PATCH 4
|
#define CGLM_VERSION_PATCH 5
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
project('cglm', 'c',
|
project('cglm', 'c',
|
||||||
version : '0.9.4',
|
version : '0.9.5',
|
||||||
license : 'mit',
|
license : 'mit',
|
||||||
default_options : [
|
default_options : [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat2x3_make(const float * __restrict src, mat2x3 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat2 dest) {
|
glmc_mat2x3_mul(mat2x3 m1, mat3x2 m2, mat3 dest) {
|
||||||
glm_mat2x3_mul(m1, m2, dest);
|
glm_mat2x3_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x3_mulv(mat2x3 m, vec3 v, vec2 dest) {
|
glmc_mat2x3_mulv(mat2x3 m, vec2 v, vec3 dest) {
|
||||||
glm_mat2x3_mulv(m, v, dest);
|
glm_mat2x3_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat2x4_make(const float * __restrict src, mat2x4 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat2 dest) {
|
glmc_mat2x4_mul(mat2x4 m1, mat4x2 m2, mat4 dest) {
|
||||||
glm_mat2x4_mul(m1, m2, dest);
|
glm_mat2x4_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat2x4_mulv(mat2x4 m, vec4 v, vec2 dest) {
|
glmc_mat2x4_mulv(mat2x4 m, vec2 v, vec4 dest) {
|
||||||
glm_mat2x4_mulv(m, v, dest);
|
glm_mat2x4_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat3x2_make(const float * __restrict src, mat3x2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat3 dest) {
|
glmc_mat3x2_mul(mat3x2 m1, mat2x3 m2, mat2 dest) {
|
||||||
glm_mat3x2_mul(m1, m2, dest);
|
glm_mat3x2_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x2_mulv(mat3x2 m, vec2 v, vec3 dest) {
|
glmc_mat3x2_mulv(mat3x2 m, vec3 v, vec2 dest) {
|
||||||
glm_mat3x2_mulv(m, v, dest);
|
glm_mat3x2_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat3x4_make(const float * __restrict src, mat3x4 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat3 dest) {
|
glmc_mat3x4_mul(mat3x4 m1, mat4x3 m2, mat4 dest) {
|
||||||
glm_mat3x4_mul(m1, m2, dest);
|
glm_mat3x4_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3x4_mulv(mat3x4 m, vec4 v, vec3 dest) {
|
glmc_mat3x4_mulv(mat3x4 m, vec3 v, vec4 dest) {
|
||||||
glm_mat3x4_mulv(m, v, dest);
|
glm_mat3x4_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat4x2_make(const float * __restrict src, mat4x2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat4 dest) {
|
glmc_mat4x2_mul(mat4x2 m1, mat2x4 m2, mat2 dest) {
|
||||||
glm_mat4x2_mul(m1, m2, dest);
|
glm_mat4x2_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x2_mulv(mat4x2 m, vec2 v, vec4 dest) {
|
glmc_mat4x2_mulv(mat4x2 m, vec4 v, vec2 dest) {
|
||||||
glm_mat4x2_mulv(m, v, dest);
|
glm_mat4x2_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ glmc_mat4x3_make(const float * __restrict src, mat4x3 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat4 dest) {
|
glmc_mat4x3_mul(mat4x3 m1, mat3x4 m2, mat3 dest) {
|
||||||
glm_mat4x3_mul(m1, m2, dest);
|
glm_mat4x3_mul(m1, m2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4x3_mulv(mat4x3 m, vec3 v, vec4 dest) {
|
glmc_mat4x3_mulv(mat4x3 m, vec4 v, vec3 dest) {
|
||||||
glm_mat4x3_mulv(m, v, dest);
|
glm_mat4x3_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -305,12 +305,12 @@ glmc_vec2_make(const float * __restrict src, vec2 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
glmc_vec2_reflect(vec2 v, vec2 n, vec2 dest) {
|
||||||
glm_vec2_reflect(I, N, dest);
|
glm_vec2_reflect(v, n, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec2_refract(vec2 I, vec2 N, float eta, vec2 dest) {
|
glmc_vec2_refract(vec2 v, vec2 n, float eta, vec2 dest) {
|
||||||
return glm_vec2_refract(I, N, eta, dest);
|
return glm_vec2_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/vec3.c
12
src/vec3.c
@@ -462,18 +462,18 @@ glmc_vec3_make(const float * __restrict src, vec3 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_faceforward(vec3 N, vec3 I, vec3 Nref, vec3 dest) {
|
glmc_vec3_faceforward(vec3 n, vec3 v, vec3 nref, vec3 dest) {
|
||||||
glm_vec3_faceforward(N, I, Nref, dest);
|
glm_vec3_faceforward(n, v, nref, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec3_reflect(vec3 I, vec3 N, vec3 dest) {
|
glmc_vec3_reflect(vec3 v, vec3 n, vec3 dest) {
|
||||||
glm_vec3_reflect(I, N, dest);
|
glm_vec3_reflect(v, n, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec3_refract(vec3 I, vec3 N, float eta, vec3 dest) {
|
glmc_vec3_refract(vec3 v, vec3 n, float eta, vec3 dest) {
|
||||||
return glm_vec3_refract(I, N, eta, dest);
|
return glm_vec3_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -426,12 +426,12 @@ glmc_vec4_make(const float * __restrict src, vec4 dest) {
|
|||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec4_reflect(vec4 I, vec4 N, vec4 dest) {
|
glmc_vec4_reflect(vec4 v, vec4 n, vec4 dest) {
|
||||||
glm_vec4_reflect(I, N, dest);
|
glm_vec4_reflect(v, n, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
bool
|
bool
|
||||||
glmc_vec4_refract(vec4 I, vec4 N, float eta, vec4 dest) {
|
glmc_vec4_refract(vec4 v, vec4 n, float eta, vec4 dest) {
|
||||||
return glm_vec4_refract(I, N, eta, dest);
|
return glm_vec4_refract(v, n, eta, dest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,42 +83,42 @@ TEST_IMPL(GLM_PREFIX, mat2x3_mul) {
|
|||||||
mat2x3 m1 = GLM_MAT2X3_ZERO_INIT;
|
mat2x3 m1 = GLM_MAT2X3_ZERO_INIT;
|
||||||
mat3x2 m2 = GLM_MAT3X2_ZERO_INIT;
|
mat3x2 m2 = GLM_MAT3X2_ZERO_INIT;
|
||||||
|
|
||||||
mat2 m3 = GLM_MAT2_ZERO_INIT;
|
mat3 m3 = GLM_MAT3_ZERO_INIT;
|
||||||
mat2 m4 = GLM_MAT2_ZERO_INIT;
|
mat3 m4 = GLM_MAT3_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
/* test random matrices */
|
/* test random matrices */
|
||||||
/* random matrices */
|
/* random matrices */
|
||||||
test_rand_mat2x3(m1);
|
test_rand_mat2x3(m1);
|
||||||
test_rand_mat3x2(m2);
|
test_rand_mat3x2(m2);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (r = 0; r < 3; r++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (c = 0; c < 3; c++) {
|
||||||
for (k = 0; k < 3; k++) {
|
for (k = 0; k < 2; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat2x3_mul)(m1, m2, m3);
|
GLM(mat2x3_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat2_eq(m3, m4))
|
ASSERTIFY(test_assert_mat3_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat2x3_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat2x3_mulv) {
|
||||||
mat2x3 mat = A_MATRIX2X3;
|
mat2x3 mat = A_MATRIX2X3;
|
||||||
vec3 v = {11.0f, 21.0f, 31.0f};
|
vec2 v = {11.0f, 21.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec2 dest;
|
vec3 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat2x3_mulv)(mat, v, dest);
|
GLM(mat2x3_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1] + mat[i][2] * v[2];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,42 +86,42 @@ TEST_IMPL(GLM_PREFIX, mat2x4_mul) {
|
|||||||
mat2x4 m1 = GLM_MAT2X4_ZERO_INIT;
|
mat2x4 m1 = GLM_MAT2X4_ZERO_INIT;
|
||||||
mat4x2 m2 = GLM_MAT4X2_ZERO_INIT;
|
mat4x2 m2 = GLM_MAT4X2_ZERO_INIT;
|
||||||
|
|
||||||
mat2 m3 = GLM_MAT2_ZERO_INIT;
|
mat4 m3 = GLM_MAT4_ZERO_INIT;
|
||||||
mat2 m4 = GLM_MAT2_ZERO_INIT;
|
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
/* test random matrices */
|
/* test random matrices */
|
||||||
/* random matrices */
|
/* random matrices */
|
||||||
test_rand_mat2x4(m1);
|
test_rand_mat2x4(m1);
|
||||||
test_rand_mat4x2(m2);
|
test_rand_mat4x2(m2);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (c = 0; c < 4; c++) {
|
||||||
for (k = 0; k < 4; k++) {
|
for (k = 0; k < 2; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat2x4_mul)(m1, m2, m3);
|
GLM(mat2x4_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat2_eq(m3, m4))
|
ASSERTIFY(test_assert_mat4_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat2x4_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat2x4_mulv) {
|
||||||
mat2x4 mat = A_MATRIX2X4;
|
mat2x4 mat = A_MATRIX2X4;
|
||||||
vec4 v = {11.0f, 21.0f, 31.0f, 41.0f};
|
vec2 v = {11.0f, 21.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec2 dest;
|
vec4 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat2x4_mulv)(mat, v, dest);
|
GLM(mat2x4_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1] + mat[i][2] * v[2] + mat[i][3] * v[3];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,40 +84,40 @@ TEST_IMPL(GLM_PREFIX, mat3x2_mul) {
|
|||||||
mat3x2 m1 = GLM_MAT3X2_ZERO_INIT;
|
mat3x2 m1 = GLM_MAT3X2_ZERO_INIT;
|
||||||
mat2x3 m2 = GLM_MAT2X3_ZERO_INIT;
|
mat2x3 m2 = GLM_MAT2X3_ZERO_INIT;
|
||||||
|
|
||||||
mat3 m3 = GLM_MAT3_ZERO_INIT;
|
mat2 m3 = GLM_MAT2_ZERO_INIT;
|
||||||
mat3 m4 = GLM_MAT3_ZERO_INIT;
|
mat2 m4 = GLM_MAT2_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
test_rand_mat3x2(m1);
|
test_rand_mat3x2(m1);
|
||||||
test_rand_mat2x3(m2);
|
test_rand_mat2x3(m2);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (r = 0; r < 2; r++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (c = 0; c < 2; c++) {
|
||||||
for (k = 0; k < 2; k++) {
|
for (k = 0; k < 3; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat3x2_mul)(m1, m2, m3);
|
GLM(mat3x2_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat3_eq(m3, m4))
|
ASSERTIFY(test_assert_mat2_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat3x2_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat3x2_mulv) {
|
||||||
mat3x2 mat = A_MATRIX3X2;
|
mat3x2 mat = A_MATRIX3X2;
|
||||||
vec2 v = {11.0f, 21.0f};
|
vec3 v = {11.0f, 21.0f, 31.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec3 dest;
|
vec2 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat3x2_mulv)(mat, v, dest);
|
GLM(mat3x2_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,40 +90,40 @@ TEST_IMPL(GLM_PREFIX, mat3x4_mul) {
|
|||||||
mat3x4 m1 = GLM_MAT3X4_ZERO_INIT;
|
mat3x4 m1 = GLM_MAT3X4_ZERO_INIT;
|
||||||
mat4x3 m2 = GLM_MAT4X3_ZERO_INIT;
|
mat4x3 m2 = GLM_MAT4X3_ZERO_INIT;
|
||||||
|
|
||||||
mat3 m3 = GLM_MAT3_ZERO_INIT;
|
mat4 m3 = GLM_MAT4_ZERO_INIT;
|
||||||
mat3 m4 = GLM_MAT3_ZERO_INIT;
|
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
test_rand_mat3x4(m1);
|
test_rand_mat3x4(m1);
|
||||||
test_rand_mat4x3(m2);
|
test_rand_mat4x3(m2);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (r = 0; r < 4; r++) {
|
||||||
for (j = 0; j < 3; j++) {
|
for (c = 0; c < 4; c++) {
|
||||||
for (k = 0; k < 4; k++) {
|
for (k = 0; k < 3; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat3x4_mul)(m1, m2, m3);
|
GLM(mat3x4_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat3_eq(m3, m4))
|
ASSERTIFY(test_assert_mat4_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat3x4_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat3x4_mulv) {
|
||||||
mat3x4 mat = A_MATRIX3X4;
|
mat3x4 mat = A_MATRIX3X4;
|
||||||
vec4 v = {11.0f, 21.0f, 31.0f, 41.0f};
|
vec4 v = {11.0f, 21.0f, 31.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec3 dest;
|
vec4 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat3x4_mulv)(mat, v, dest);
|
GLM(mat3x4_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1] + mat[i][2] * v[2];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,40 +87,40 @@ TEST_IMPL(GLM_PREFIX, mat4x2_mul) {
|
|||||||
mat4x2 m1 = GLM_MAT4X2_ZERO_INIT;
|
mat4x2 m1 = GLM_MAT4X2_ZERO_INIT;
|
||||||
mat2x4 m2 = GLM_MAT2X4_ZERO_INIT;
|
mat2x4 m2 = GLM_MAT2X4_ZERO_INIT;
|
||||||
|
|
||||||
mat4 m3 = GLM_MAT4_ZERO_INIT;
|
mat2 m3 = GLM_MAT2_ZERO_INIT;
|
||||||
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
mat2 m4 = GLM_MAT2_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
test_rand_mat4x2(m1);
|
test_rand_mat4x2(m1);
|
||||||
test_rand_mat2x4(m2);
|
test_rand_mat2x4(m2);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (r = 0; r < 2; r++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (c = 0; c < 2; c++) {
|
||||||
for (k = 0; k < 2; k++) {
|
for (k = 0; k < 4; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat4x2_mul)(m1, m2, m3);
|
GLM(mat4x2_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat4_eq(m3, m4))
|
ASSERTIFY(test_assert_mat2_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat4x2_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat4x2_mulv) {
|
||||||
mat4x2 mat = A_MATRIX4X2;
|
mat4x2 mat = A_MATRIX4X2;
|
||||||
vec2 v = {11.0f, 21.0f};
|
vec4 v = {11.0f, 21.0f, 31.0f, 41.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec4 dest;
|
vec2 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat4x2_mulv)(mat, v, dest);
|
GLM(mat4x2_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2] + mat[3][i] * v[3];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,40 +91,40 @@ TEST_IMPL(GLM_PREFIX, mat4x3_mul) {
|
|||||||
mat4x3 m1 = GLM_MAT4X3_ZERO_INIT;
|
mat4x3 m1 = GLM_MAT4X3_ZERO_INIT;
|
||||||
mat3x4 m2 = GLM_MAT3X4_ZERO_INIT;
|
mat3x4 m2 = GLM_MAT3X4_ZERO_INIT;
|
||||||
|
|
||||||
mat4 m3 = GLM_MAT4_ZERO_INIT;
|
mat3 m3 = GLM_MAT3_ZERO_INIT;
|
||||||
mat4 m4 = GLM_MAT4_ZERO_INIT;
|
mat3 m4 = GLM_MAT3_ZERO_INIT;
|
||||||
|
|
||||||
int i, j, k;
|
int c, r, k;
|
||||||
|
|
||||||
test_rand_mat4x3(m1);
|
test_rand_mat4x3(m1);
|
||||||
test_rand_mat3x4(m2);
|
test_rand_mat3x4(m2);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (r = 0; r < 3; r++) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (c = 0; c < 3; c++) {
|
||||||
for (k = 0; k < 3; k++) {
|
for (k = 0; k < 4; k++) {
|
||||||
m4[i][j] += m1[i][k] * m2[k][j];
|
m4[c][r] += m1[k][r] * m2[c][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM(mat4x3_mul)(m1, m2, m3);
|
GLM(mat4x3_mul)(m1, m2, m3);
|
||||||
ASSERTIFY(test_assert_mat4_eq(m3, m4))
|
ASSERTIFY(test_assert_mat3_eq(m3, m4))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, mat4x3_mulv) {
|
TEST_IMPL(GLM_PREFIX, mat4x3_mulv) {
|
||||||
mat4x3 mat = A_MATRIX4X3;
|
mat4x3 mat = A_MATRIX4X3;
|
||||||
vec3 v = {11.0f, 21.0f, 31.0f};
|
vec4 v = {11.0f, 21.0f, 31.0f, 41.0f};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
vec4 dest;
|
vec3 dest;
|
||||||
float res = 0.0;
|
float res = 0.0;
|
||||||
|
|
||||||
GLM(mat4x3_mulv)(mat, v, dest);
|
GLM(mat4x3_mulv)(mat, v, dest);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
res = mat[i][0] * v[0] + mat[i][1] * v[1] + mat[i][2] * v[2];
|
res = mat[0][i] * v[0] + mat[1][i] * v[1] + mat[2][i] * v[2] + mat[3][i] * v[3];
|
||||||
ASSERT(test_eq(dest[i], res))
|
ASSERT(test_eq(dest[i], res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,15 @@ TEST_IMPL(GLM_PREFIX, unprojecti) {
|
|||||||
|
|
||||||
/* unprojected of projected vector must be same as original one */
|
/* unprojected of projected vector must be same as original one */
|
||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
||||||
|
#else
|
||||||
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
@@ -50,9 +56,16 @@ TEST_IMPL(GLM_PREFIX, unproject) {
|
|||||||
|
|
||||||
/* unprojected of projected vector must be same as original one */
|
/* unprojected of projected vector must be same as original one */
|
||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
|
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
||||||
|
#else
|
||||||
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
@@ -74,9 +87,16 @@ TEST_IMPL(GLM_PREFIX, project) {
|
|||||||
|
|
||||||
/* unprojected of projected vector must be same as original one */
|
/* unprojected of projected vector must be same as original one */
|
||||||
/* we used 0.01 because of projection floating point errors */
|
/* we used 0.01 because of projection floating point errors */
|
||||||
|
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.01)
|
||||||
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.01)
|
||||||
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.01)
|
||||||
|
#else
|
||||||
|
ASSERT(fabsf(pos[0] - unprojected[0]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[1] - unprojected[1]) < 0.1)
|
||||||
|
ASSERT(fabsf(pos[2] - unprojected[2]) < 0.1)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* test with no projection */
|
/* test with no projection */
|
||||||
glm_mat4_identity(mvp);
|
glm_mat4_identity(mvp);
|
||||||
|
|||||||
@@ -781,15 +781,15 @@ TEST_IMPL(GLM_PREFIX, vec2_reflect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec2_refract) {
|
TEST_IMPL(GLM_PREFIX, vec2_refract) {
|
||||||
vec2 I = {sqrtf(0.5f), -sqrtf(0.5f)}; /* Incoming vector at 45 degrees to normal */
|
vec2 v = {sqrtf(0.5f), -sqrtf(0.5f)}; /* Incoming vector at 45 degrees to normal */
|
||||||
vec2 N = {0.0f, 1.0f}; /* Surface normal */
|
vec2 N = {0.0f, 1.0f}; /* Surface normal */
|
||||||
vec2 dest;
|
vec2 dest;
|
||||||
float eta;
|
float eta;
|
||||||
float r;
|
float r;
|
||||||
|
|
||||||
/* Water to Air (eta = 1.33/1.0) */
|
/* Water to Air (eta = 1.33/1.0) */
|
||||||
eta = 1.33f / 1.0f;
|
eta = 1.33f / 1.0f;
|
||||||
r = GLM(vec2_refract)(I, N, eta, dest);
|
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||||
// In 2D, we expect a similar bending behavior as in 3D, so we check dest[1]
|
// In 2D, we expect a similar bending behavior as in 3D, so we check dest[1]
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Refracted ray bends away from the normal
|
ASSERT(dest[1] < -sqrtf(0.5f)); // Refracted ray bends away from the normal
|
||||||
@@ -801,17 +801,19 @@ TEST_IMPL(GLM_PREFIX, vec2_refract) {
|
|||||||
|
|
||||||
/* Air to Glass (eta = 1.0 / 1.5) */
|
/* Air to Glass (eta = 1.0 / 1.5) */
|
||||||
eta = 1.0f / 1.5f;
|
eta = 1.0f / 1.5f;
|
||||||
r = GLM(vec2_refract)(I, N, eta, dest);
|
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
|
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
|
||||||
|
|
||||||
/* Glass to Water (eta = 1.5 / 1.33) */
|
/* Glass to Water (eta = 1.5 / 1.33) */
|
||||||
eta = 1.5f / 1.33f;
|
eta = 1.5f / 1.33f;
|
||||||
r = GLM(vec2_refract)(I, N, eta, dest);
|
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
||||||
|
|
||||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||||
eta = 2.42f / 1.0f;
|
eta = 2.42f / 1.0f;
|
||||||
r = GLM(vec2_refract)(I, N, eta, dest);
|
r = GLM(vec2_refract)(v, N, eta, dest);
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f)) {
|
||||||
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
|
|||||||
@@ -1673,14 +1673,16 @@ TEST_IMPL(GLM_PREFIX, vec3_eqv_eps) {
|
|||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_max) {
|
TEST_IMPL(GLM_PREFIX, vec3_max) {
|
||||||
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
||||||
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
vec3 v3 = {INFINITY, 0.0f, 0.0f}/*, v4 = {NAN, INFINITY, 2.0f}*/;
|
||||||
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -11.0f, 11.0f};
|
vec3 /*v5 = {NAN, -1.0f, -1.0f}, */v6 = {-1.0f, -11.0f, 11.0f};
|
||||||
|
|
||||||
ASSERT(test_eq(GLM(vec3_max)(v1), 2.104f))
|
ASSERT(test_eq(GLM(vec3_max)(v1), 2.104f))
|
||||||
ASSERT(test_eq(GLM(vec3_max)(v2), -12.35f))
|
ASSERT(test_eq(GLM(vec3_max)(v2), -12.35f))
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(isinf(GLM(vec3_max)(v3)))
|
ASSERT(isinf(GLM(vec3_max)(v3)))
|
||||||
ASSERT(isnan(GLM(vec3_max)(v4)))
|
#endif
|
||||||
ASSERT(isnan(GLM(vec3_max)(v5)))
|
// ASSERT(isnan(GLM(vec3_max)(v4)))
|
||||||
|
// ASSERT(isnan(GLM(vec3_max)(v5)))
|
||||||
ASSERT(test_eq(GLM(vec3_max)(v6), 11.0f))
|
ASSERT(test_eq(GLM(vec3_max)(v6), 11.0f))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
@@ -1688,20 +1690,21 @@ TEST_IMPL(GLM_PREFIX, vec3_max) {
|
|||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_min) {
|
TEST_IMPL(GLM_PREFIX, vec3_min) {
|
||||||
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
||||||
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
vec3 v3 = {INFINITY, 0.0f, 0.0f}/*, v4 = {NAN, INFINITY, 2.0f}*/;
|
||||||
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -11.0f, 11.0f};
|
vec3 /*v5 = {NAN, -1.0f, -1.0f},*/ v6 = {-1.0f, -11.0f, 11.0f};
|
||||||
|
|
||||||
ASSERT(test_eq(GLM(vec3_min)(v1), -4.10f))
|
ASSERT(test_eq(GLM(vec3_min)(v1), -4.10f))
|
||||||
ASSERT(test_eq(GLM(vec3_min)(v2), -43.502f))
|
ASSERT(test_eq(GLM(vec3_min)(v2), -43.502f))
|
||||||
ASSERT(test_eq(GLM(vec3_min)(v3), 0.0f))
|
ASSERT(test_eq(GLM(vec3_min)(v3), 0.0f))
|
||||||
ASSERT(isnan(GLM(vec3_min)(v4)))
|
// ASSERT(isnan(GLM(vec3_min)(v4)))
|
||||||
ASSERT(isnan(GLM(vec3_min)(v5)))
|
// ASSERT(isnan(GLM(vec3_min)(v5)))
|
||||||
ASSERT(test_eq(GLM(vec3_min)(v6), -11.0f))
|
ASSERT(test_eq(GLM(vec3_min)(v6), -11.0f))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_isnan) {
|
TEST_IMPL(GLM_PREFIX, vec3_isnan) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
||||||
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
||||||
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
||||||
@@ -1712,11 +1715,12 @@ TEST_IMPL(GLM_PREFIX, vec3_isnan) {
|
|||||||
ASSERT(GLM(vec3_isnan)(v4))
|
ASSERT(GLM(vec3_isnan)(v4))
|
||||||
ASSERT(GLM(vec3_isnan)(v5))
|
ASSERT(GLM(vec3_isnan)(v5))
|
||||||
ASSERT(!GLM(vec3_isnan)(v6))
|
ASSERT(!GLM(vec3_isnan)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_isinf) {
|
TEST_IMPL(GLM_PREFIX, vec3_isinf) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
||||||
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
||||||
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
||||||
@@ -1727,11 +1731,12 @@ TEST_IMPL(GLM_PREFIX, vec3_isinf) {
|
|||||||
ASSERT(GLM(vec3_isinf)(v4))
|
ASSERT(GLM(vec3_isinf)(v4))
|
||||||
ASSERT(!GLM(vec3_isinf)(v5))
|
ASSERT(!GLM(vec3_isinf)(v5))
|
||||||
ASSERT(!GLM(vec3_isinf)(v6))
|
ASSERT(!GLM(vec3_isinf)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_isvalid) {
|
TEST_IMPL(GLM_PREFIX, vec3_isvalid) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
vec3 v1 = {2.104f, -3.012f, -4.10f}, v2 = {-12.35f, -31.140f, -43.502f};
|
||||||
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
vec3 v3 = {INFINITY, 0.0f, 0.0f}, v4 = {NAN, INFINITY, 2.0f};
|
||||||
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
vec3 v5 = {NAN, -1.0f, -1.0f}, v6 = {-1.0f, -1.0f, 11.0f};
|
||||||
@@ -1742,7 +1747,7 @@ TEST_IMPL(GLM_PREFIX, vec3_isvalid) {
|
|||||||
ASSERT(!GLM(vec3_isvalid)(v4))
|
ASSERT(!GLM(vec3_isvalid)(v4))
|
||||||
ASSERT(!GLM(vec3_isvalid)(v5))
|
ASSERT(!GLM(vec3_isvalid)(v5))
|
||||||
ASSERT(GLM(vec3_isvalid)(v6))
|
ASSERT(GLM(vec3_isvalid)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1843,12 +1848,12 @@ TEST_IMPL(GLM_PREFIX, vec3_make) {
|
|||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_faceforward) {
|
TEST_IMPL(GLM_PREFIX, vec3_faceforward) {
|
||||||
vec3 N = {0.0f, 1.0f, 0.0f};
|
vec3 N = {0.0f, 1.0f, 0.0f};
|
||||||
vec3 I = {1.0f, -1.0f, 0.0f};
|
vec3 v = {1.0f, -1.0f, 0.0f};
|
||||||
vec3 Nref = {0.0f, -1.0f, 0.0f};
|
vec3 Nref = {0.0f, -1.0f, 0.0f};
|
||||||
vec3 dest;
|
vec3 dest;
|
||||||
|
|
||||||
GLM(vec3_faceforward)(N, I, Nref, dest);
|
GLM(vec3_faceforward)(N, v, Nref, dest);
|
||||||
ASSERT(dest[0] == 0.0f
|
ASSERT(dest[0] == 0.0f
|
||||||
&& dest[1] == -1.0f
|
&& dest[1] == -1.0f
|
||||||
&& dest[2] == 0.0f); /* Expect N flipped */
|
&& dest[2] == 0.0f); /* Expect N flipped */
|
||||||
|
|
||||||
@@ -1886,15 +1891,15 @@ TEST_IMPL(GLM_PREFIX, vec3_reflect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec3_refract) {
|
TEST_IMPL(GLM_PREFIX, vec3_refract) {
|
||||||
vec3 I = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f}; /* Incoming vector at 45 degrees to normal */
|
vec3 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f}; /* Incoming vector at 45 degrees to normal */
|
||||||
vec3 N = {0.0f, 1.0f, 0.0f}; /* Surface normal */
|
vec3 N = {0.0f, 1.0f, 0.0f}; /* Surface normal */
|
||||||
vec3 dest;
|
vec3 dest;
|
||||||
float eta;
|
float eta;
|
||||||
bool r;
|
bool r;
|
||||||
|
|
||||||
/* Water to Air (eta = 1.33/1.0) */
|
/* Water to Air (eta = 1.33/1.0) */
|
||||||
eta = 1.33f / 1.0f;
|
eta = 1.33f / 1.0f;
|
||||||
r = GLM(vec3_refract)(I, N, eta, dest);
|
r = GLM(vec3_refract)(v, N, eta, dest);
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
ASSERT(r == true);
|
ASSERT(r == true);
|
||||||
@@ -1905,21 +1910,23 @@ TEST_IMPL(GLM_PREFIX, vec3_refract) {
|
|||||||
|
|
||||||
/* Air to Glass (eta = 1.0 / 1.5) */
|
/* Air to Glass (eta = 1.0 / 1.5) */
|
||||||
eta = 1.0f / 1.5f;
|
eta = 1.0f / 1.5f;
|
||||||
r = GLM(vec3_refract)(I, N, eta, dest);
|
r = GLM(vec3_refract)(v, N, eta, dest);
|
||||||
|
|
||||||
/* Expect bending towards the normal */
|
/* Expect bending towards the normal */
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
|
|
||||||
/* Glass to Water (eta = 1.5 / 1.33) */
|
/* Glass to Water (eta = 1.5 / 1.33) */
|
||||||
eta = 1.5f / 1.33f;
|
eta = 1.5f / 1.33f;
|
||||||
r = GLM(vec3_refract)(I, N, eta, dest);
|
r = GLM(vec3_refract)(v, N, eta, dest);
|
||||||
|
|
||||||
/* Expect bending towards the normal, less bending than air to glass */
|
/* Expect bending towards the normal, less bending than air to glass */
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
|
|
||||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||||
eta = 2.42f / 1.0f;
|
eta = 2.42f / 1.0f;
|
||||||
r = GLM(vec3_refract)(I, N, eta, dest);
|
r = GLM(vec3_refract)(v, N, eta, dest);
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f)) {
|
||||||
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
|
|||||||
@@ -1345,15 +1345,17 @@ TEST_IMPL(GLM_PREFIX, vec4_max) {
|
|||||||
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
||||||
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
||||||
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
||||||
vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f};
|
// vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f};
|
||||||
vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f};
|
// vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f};
|
||||||
vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f};
|
vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f};
|
||||||
|
|
||||||
ASSERT(test_eq(GLM(vec4_max)(v1), 2.104f))
|
ASSERT(test_eq(GLM(vec4_max)(v1), 2.104f))
|
||||||
ASSERT(test_eq(GLM(vec4_max)(v2), -12.35f))
|
ASSERT(test_eq(GLM(vec4_max)(v2), -12.35f))
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
ASSERT(isinf(GLM(vec4_max)(v3)))
|
ASSERT(isinf(GLM(vec4_max)(v3)))
|
||||||
ASSERT(isnan(GLM(vec4_max)(v4)))
|
#endif
|
||||||
ASSERT(isnan(GLM(vec4_max)(v5)))
|
// ASSERT(isnan(GLM(vec4_max)(v4)))
|
||||||
|
// ASSERT(isnan(GLM(vec4_max)(v5)))
|
||||||
ASSERT(test_eq(GLM(vec4_max)(v6), 11.0f))
|
ASSERT(test_eq(GLM(vec4_max)(v6), 11.0f))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
@@ -1363,21 +1365,22 @@ TEST_IMPL(GLM_PREFIX, vec4_min) {
|
|||||||
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
||||||
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
||||||
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
||||||
vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f};
|
// vec4 v4 = {NAN, INFINITY, 2.0f, 2.0f};
|
||||||
vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f};
|
// vec4 v5 = {NAN, -1.0f, -1.0f, -1.0f};
|
||||||
vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f};
|
vec4 v6 = {-1.0f, -11.0f, 11.0f, 11.0f};
|
||||||
|
|
||||||
ASSERT(test_eq(GLM(vec4_min)(v1), -4.10f))
|
ASSERT(test_eq(GLM(vec4_min)(v1), -4.10f))
|
||||||
ASSERT(test_eq(GLM(vec4_min)(v2), -43.502f))
|
ASSERT(test_eq(GLM(vec4_min)(v2), -43.502f))
|
||||||
ASSERT(test_eq(GLM(vec4_min)(v3), 0.0f))
|
ASSERT(test_eq(GLM(vec4_min)(v3), 0.0f))
|
||||||
ASSERT(isnan(GLM(vec4_min)(v4)))
|
// ASSERT(isnan(GLM(vec4_min)(v4)))
|
||||||
ASSERT(isnan(GLM(vec4_min)(v5)))
|
// ASSERT(isnan(GLM(vec4_min)(v5)))
|
||||||
ASSERT(test_eq(GLM(vec4_min)(v6), -11.0f))
|
ASSERT(test_eq(GLM(vec4_min)(v6), -11.0f))
|
||||||
|
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec4_isnan) {
|
TEST_IMPL(GLM_PREFIX, vec4_isnan) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
||||||
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
||||||
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
||||||
@@ -1391,11 +1394,12 @@ TEST_IMPL(GLM_PREFIX, vec4_isnan) {
|
|||||||
ASSERT(GLM(vec4_isnan)(v4))
|
ASSERT(GLM(vec4_isnan)(v4))
|
||||||
ASSERT(GLM(vec4_isnan)(v5))
|
ASSERT(GLM(vec4_isnan)(v5))
|
||||||
ASSERT(!GLM(vec4_isnan)(v6))
|
ASSERT(!GLM(vec4_isnan)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec4_isinf) {
|
TEST_IMPL(GLM_PREFIX, vec4_isinf) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
||||||
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
||||||
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
||||||
@@ -1409,11 +1413,12 @@ TEST_IMPL(GLM_PREFIX, vec4_isinf) {
|
|||||||
ASSERT(GLM(vec4_isinf)(v4))
|
ASSERT(GLM(vec4_isinf)(v4))
|
||||||
ASSERT(!GLM(vec4_isinf)(v5))
|
ASSERT(!GLM(vec4_isinf)(v5))
|
||||||
ASSERT(!GLM(vec4_isinf)(v6))
|
ASSERT(!GLM(vec4_isinf)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec4_isvalid) {
|
TEST_IMPL(GLM_PREFIX, vec4_isvalid) {
|
||||||
|
#ifndef CGLM_FAST_MATH
|
||||||
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
vec4 v1 = {2.104f, -3.012f, -4.10f, -4.10f};
|
||||||
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
vec4 v2 = {-12.35f, -31.140f, -43.502f, -43.502f};
|
||||||
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
vec4 v3 = {INFINITY, 0.0f, 0.0f, 0.0f};
|
||||||
@@ -1427,7 +1432,7 @@ TEST_IMPL(GLM_PREFIX, vec4_isvalid) {
|
|||||||
ASSERT(!GLM(vec4_isvalid)(v4))
|
ASSERT(!GLM(vec4_isvalid)(v4))
|
||||||
ASSERT(!GLM(vec4_isvalid)(v5))
|
ASSERT(!GLM(vec4_isvalid)(v5))
|
||||||
ASSERT(GLM(vec4_isvalid)(v6))
|
ASSERT(GLM(vec4_isvalid)(v6))
|
||||||
|
#endif
|
||||||
TEST_SUCCESS
|
TEST_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1571,15 +1576,15 @@ TEST_IMPL(GLM_PREFIX, vec4_reflect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_IMPL(GLM_PREFIX, vec4_refract) {
|
TEST_IMPL(GLM_PREFIX, vec4_refract) {
|
||||||
vec4 I = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f, 0.0f}; /* Incoming vector */
|
vec4 v = {sqrtf(0.5f), -sqrtf(0.5f), 0.0f, 0.0f}; /* Incoming vector */
|
||||||
vec4 N = {0.0f, 1.0f, 0.0f, 0.0f}; /* Surface normal */
|
vec4 N = {0.0f, 1.0f, 0.0f, 0.0f}; /* Surface normal */
|
||||||
vec4 dest;
|
vec4 dest;
|
||||||
float eta;
|
float eta;
|
||||||
float r;
|
float r;
|
||||||
|
|
||||||
/* Water to Air (eta = 1.33/1.0) */
|
/* Water to Air (eta = 1.33/1.0) */
|
||||||
eta = 1.33f / 1.0f;
|
eta = 1.33f / 1.0f;
|
||||||
r = GLM(vec4_refract)(I, N, eta, dest);
|
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
ASSERT(r == true);
|
ASSERT(r == true);
|
||||||
@@ -1590,17 +1595,19 @@ TEST_IMPL(GLM_PREFIX, vec4_refract) {
|
|||||||
|
|
||||||
/* Air to Glass (eta = 1.0 / 1.5) */
|
/* Air to Glass (eta = 1.0 / 1.5) */
|
||||||
eta = 1.0f / 1.5f;
|
eta = 1.0f / 1.5f;
|
||||||
r = GLM(vec4_refract)(I, N, eta, dest);
|
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
|
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal
|
||||||
|
|
||||||
/* Glass to Water (eta = 1.5 / 1.33) */
|
/* Glass to Water (eta = 1.5 / 1.33) */
|
||||||
eta = 1.5f / 1.33f;
|
eta = 1.5f / 1.33f;
|
||||||
r = GLM(vec4_refract)(I, N, eta, dest);
|
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||||
|
ASSERT(r == true);
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
ASSERT(dest[1] < -sqrtf(0.5f)); // Expect bending towards the normal, less bending than air to glass
|
||||||
|
|
||||||
/* Diamond to Air (eta = 2.42 / 1.0) */
|
/* Diamond to Air (eta = 2.42 / 1.0) */
|
||||||
eta = 2.42f / 1.0f;
|
eta = 2.42f / 1.0f;
|
||||||
r = GLM(vec4_refract)(I, N, eta, dest);
|
r = GLM(vec4_refract)(v, N, eta, dest);
|
||||||
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
|
if (!(dest[0] == 0.0f && dest[1] == 0.0f && dest[2] == 0.0f && dest[3] == 0.0f)) {
|
||||||
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
/* High potential for total internal reflection, but if it occurs, expect significant bending */
|
||||||
ASSERT(dest[1] < -sqrtf(0.5f));
|
ASSERT(dest[1] < -sqrtf(0.5f));
|
||||||
|
|||||||
14
test/tests.h
14
test/tests.h
@@ -1494,13 +1494,13 @@ TEST_LIST {
|
|||||||
TEST_ENTRY(glm_mat2x4_transpose)
|
TEST_ENTRY(glm_mat2x4_transpose)
|
||||||
TEST_ENTRY(glm_mat2x4_scale)
|
TEST_ENTRY(glm_mat2x4_scale)
|
||||||
|
|
||||||
TEST_ENTRY(glm_mat2x4_copy)
|
TEST_ENTRY(glmc_mat2x4_copy)
|
||||||
TEST_ENTRY(glm_mat2x4_zero)
|
TEST_ENTRY(glmc_mat2x4_zero)
|
||||||
TEST_ENTRY(glm_mat2x4_make)
|
TEST_ENTRY(glmc_mat2x4_make)
|
||||||
TEST_ENTRY(glm_mat2x4_mul)
|
TEST_ENTRY(glmc_mat2x4_mul)
|
||||||
TEST_ENTRY(glm_mat2x4_mulv)
|
TEST_ENTRY(glmc_mat2x4_mulv)
|
||||||
TEST_ENTRY(glm_mat2x4_transpose)
|
TEST_ENTRY(glmc_mat2x4_transpose)
|
||||||
TEST_ENTRY(glm_mat2x4_scale)
|
TEST_ENTRY(glmc_mat2x4_scale)
|
||||||
|
|
||||||
/* camera (incl [LR]H cross [NZ]O) */
|
/* camera (incl [LR]H cross [NZ]O) */
|
||||||
TEST_ENTRY(glm_perspective_lh_zo)
|
TEST_ENTRY(glm_perspective_lh_zo)
|
||||||
|
|||||||
Reference in New Issue
Block a user