mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08479f38ce | ||
|
|
dadae4b773 | ||
|
|
20360f2296 | ||
|
|
aa2b0f2631 | ||
|
|
280ac72fd8 | ||
|
|
7405d5e1d0 | ||
|
|
eefafefbae | ||
|
|
b9021978cb | ||
|
|
3fd12032e6 | ||
|
|
59ee8c1fd2 | ||
|
|
b00f2b9ccc | ||
|
|
d3c50147cb | ||
|
|
98da3daf82 | ||
|
|
2e1790ccf9 | ||
|
|
cc5f533fc9 | ||
|
|
2d63d7e0cd | ||
|
|
3738499927 | ||
|
|
1d527dc2f0 | ||
|
|
43c4d05d4a | ||
|
|
c5f5032fcc | ||
|
|
5d605ce372 | ||
|
|
c216c0cb7e | ||
|
|
eb8e0df6df | ||
|
|
1775bf7458 | ||
|
|
3adeac06f8 | ||
|
|
669777eb37 | ||
|
|
02f6c67393 | ||
|
|
564324f5d2 | ||
|
|
93e6c3c102 | ||
|
|
857265b892 | ||
|
|
fc14cedf89 | ||
|
|
7a80178357 | ||
|
|
720b617ee0 | ||
|
|
3dc9070909 | ||
|
|
6b2b4b4f12 | ||
|
|
c8fc460ba1 | ||
|
|
5b3aabc103 | ||
|
|
af812e86eb | ||
|
|
059bdfdd4b | ||
|
|
ef0653640f | ||
|
|
e5d61b3433 | ||
|
|
73c073cf32 | ||
|
|
1362bef50f | ||
|
|
7d783eeace | ||
|
|
e12e79b1a5 | ||
|
|
6cd3d52dc5 | ||
|
|
fb2cac9816 | ||
|
|
4e63325f55 | ||
|
|
96c3e604ff |
8
CREDITS
8
CREDITS
@@ -1,7 +1,7 @@
|
|||||||
This library [initially] used some [piece of] implementations
|
This library [initially] used some [piece of] implementations
|
||||||
(may include codes) from these open source projects/resources:
|
(may include codes) from these open source projects/resources:
|
||||||
|
|
||||||
1. Affine Transforms
|
1. Initial Affine Transforms
|
||||||
The original glm repo (g-truc), url: https://github.com/g-truc/glm
|
The original glm repo (g-truc), url: https://github.com/g-truc/glm
|
||||||
|
|
||||||
LICENSE[S]:
|
LICENSE[S]:
|
||||||
@@ -11,7 +11,7 @@ LICENSE[S]:
|
|||||||
|
|
||||||
FULL LICENSE: https://github.com/g-truc/glm/blob/master/copying.txt
|
FULL LICENSE: https://github.com/g-truc/glm/blob/master/copying.txt
|
||||||
|
|
||||||
2. Quaternions
|
2. Initial Quaternions
|
||||||
Anton's OpenGL 4 Tutorials book source code:
|
Anton's OpenGL 4 Tutorials book source code:
|
||||||
|
|
||||||
LICENSE:
|
LICENSE:
|
||||||
@@ -47,6 +47,8 @@ http://old.cescg.org/CESCG-2002/DSykoraJJelinek/
|
|||||||
7. Quaternions
|
7. Quaternions
|
||||||
Initial mat4_quat is borrowed from Apple's simd library
|
Initial mat4_quat is borrowed from Apple's simd library
|
||||||
|
|
||||||
|
|
||||||
8. Vector Rotation using Quaternion
|
8. Vector Rotation using Quaternion
|
||||||
https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion
|
https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion
|
||||||
|
|
||||||
|
9. Sphere AABB intersect
|
||||||
|
https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
# Description
|
# Description
|
||||||
s.name = "cglm"
|
s.name = "cglm"
|
||||||
s.version = "0.4.4"
|
s.version = "0.4.6"
|
||||||
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
|
s.summary = "📽 Optimized OpenGL/Graphics Math (glm) for C"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
cglm is math library for graphics programming for C. It is similar to original glm but it is written for C instead of C++ (you can use here too). See the documentation or README for all features.
|
cglm is math library for graphics programming for C. It is similar to original glm but it is written for C instead of C++ (you can use here too). See the documentation or README for all features.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#*****************************************************************************
|
#*****************************************************************************
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([cglm], [0.4.5], [info@recp.me])
|
AC_INIT([cglm], [0.4.9], [info@recp.me])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||||
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|||||||
@@ -45,3 +45,4 @@ Follow the :doc:`build` documentation for this
|
|||||||
util
|
util
|
||||||
io
|
io
|
||||||
call
|
call
|
||||||
|
sphere
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ Functions:
|
|||||||
#. :c:func:`glm_aabb_isvalid`
|
#. :c:func:`glm_aabb_isvalid`
|
||||||
#. :c:func:`glm_aabb_size`
|
#. :c:func:`glm_aabb_size`
|
||||||
#. :c:func:`glm_aabb_radius`
|
#. :c:func:`glm_aabb_radius`
|
||||||
|
#. :c:func:`glm_aabb_center`
|
||||||
|
#. :c:func:`glm_aabb_aabb`
|
||||||
|
#. :c:func:`glm_aabb_sphere`
|
||||||
|
#. :c:func:`glm_aabb_point`
|
||||||
|
#. :c:func:`glm_aabb_contains`
|
||||||
|
|
||||||
Functions documentation
|
Functions documentation
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -131,3 +136,46 @@ Functions documentation
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **box** bounding box
|
| *[in]* **box** bounding box
|
||||||
|
|
||||||
|
.. c:function:: void glm_aabb_center(vec3 box[2], vec3 dest)
|
||||||
|
|
||||||
|
| computes center point of AABB
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **box** bounding box
|
||||||
|
| *[out]* **dest** center of bounding box
|
||||||
|
|
||||||
|
.. c:function:: bool glm_aabb_aabb(vec3 box[2], vec3 other[2])
|
||||||
|
|
||||||
|
| check if two AABB intersects
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **box** bounding box
|
||||||
|
| *[out]* **other** other bounding box
|
||||||
|
|
||||||
|
.. c:function:: bool glm_aabb_sphere(vec3 box[2], vec4 s)
|
||||||
|
|
||||||
|
| check if AABB intersects with sphere
|
||||||
|
|
||||||
|
| https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
||||||
|
| Solid Box - Solid Sphere test.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **box** solid bounding box
|
||||||
|
| *[out]* **s** solid sphere
|
||||||
|
|
||||||
|
.. c:function:: bool glm_aabb_point(vec3 box[2], vec3 point)
|
||||||
|
|
||||||
|
| check if point is inside of AABB
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **box** bounding box
|
||||||
|
| *[out]* **point** point
|
||||||
|
|
||||||
|
.. c:function:: bool glm_aabb_contains(vec3 box[2], vec3 other[2])
|
||||||
|
|
||||||
|
| check if AABB contains other AABB
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **box** bounding box
|
||||||
|
| *[out]* **other** other bounding box
|
||||||
|
|||||||
@@ -167,6 +167,8 @@ Functions documentation
|
|||||||
|
|
||||||
| set up view matrix
|
| set up view matrix
|
||||||
|
|
||||||
|
**NOTE:** The UP vector must not be parallel to the line of sight from the eye point to the reference point.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **eye** eye vector
|
| *[in]* **eye** eye vector
|
||||||
| *[in]* **center** center vector
|
| *[in]* **center** center vector
|
||||||
@@ -181,6 +183,8 @@ Functions documentation
|
|||||||
target self then this might be useful. Because you need to get target
|
target self then this might be useful. Because you need to get target
|
||||||
from direction.
|
from direction.
|
||||||
|
|
||||||
|
**NOTE:** The UP vector must not be parallel to the line of sight from the eye point to the reference point.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
| *[in]* **eye** eye vector
|
| *[in]* **eye** eye vector
|
||||||
| *[in]* **center** direction vector
|
| *[in]* **center** direction vector
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = u'0.4.5'
|
version = u'0.4.9'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = u'0.4.5'
|
release = u'0.4.9'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ Functions:
|
|||||||
|
|
||||||
1. :c:func:`glm_mat3_copy`
|
1. :c:func:`glm_mat3_copy`
|
||||||
#. :c:func:`glm_mat3_identity`
|
#. :c:func:`glm_mat3_identity`
|
||||||
|
#. :c:func:`glm_mat3_identity_array`
|
||||||
#. :c:func:`glm_mat3_mul`
|
#. :c:func:`glm_mat3_mul`
|
||||||
#. :c:func:`glm_mat3_transpose_to`
|
#. :c:func:`glm_mat3_transpose_to`
|
||||||
#. :c:func:`glm_mat3_transpose`
|
#. :c:func:`glm_mat3_transpose`
|
||||||
#. :c:func:`glm_mat3_mulv`
|
#. :c:func:`glm_mat3_mulv`
|
||||||
|
#. :c:func:`glm_mat3_quat`
|
||||||
#. :c:func:`glm_mat3_scale`
|
#. :c:func:`glm_mat3_scale`
|
||||||
#. :c:func:`glm_mat3_det`
|
#. :c:func:`glm_mat3_det`
|
||||||
#. :c:func:`glm_mat3_inv`
|
#. :c:func:`glm_mat3_inv`
|
||||||
@@ -48,6 +50,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[out]* **mat** matrix
|
| *[out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3_identity_array(mat3 * __restrict mat, size_t count)
|
||||||
|
|
||||||
|
make given matrix array's each element identity matrix
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of matrices
|
||||||
|
|
||||||
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
.. c:function:: void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest)
|
||||||
|
|
||||||
multiply m1 and m2 to dest
|
multiply m1 and m2 to dest
|
||||||
@@ -89,6 +99,14 @@ Functions documentation
|
|||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** destination (result, column vector)
|
| *[out]* **dest** destination (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat3_quat(mat3 m, versor dest)
|
||||||
|
|
||||||
|
convert mat3 to quaternion
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** rotation matrix
|
||||||
|
| *[out]* **dest** destination quaternion
|
||||||
|
|
||||||
.. c:function:: void glm_mat3_scale(mat3 m, float s)
|
.. c:function:: void glm_mat3_scale(mat3 m, float s)
|
||||||
|
|
||||||
multiply matrix with scalar
|
multiply matrix with scalar
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ Functions:
|
|||||||
1. :c:func:`glm_mat4_ucopy`
|
1. :c:func:`glm_mat4_ucopy`
|
||||||
#. :c:func:`glm_mat4_copy`
|
#. :c:func:`glm_mat4_copy`
|
||||||
#. :c:func:`glm_mat4_identity`
|
#. :c:func:`glm_mat4_identity`
|
||||||
|
#. :c:func:`glm_mat4_identity_array`
|
||||||
#. :c:func:`glm_mat4_pick3`
|
#. :c:func:`glm_mat4_pick3`
|
||||||
#. :c:func:`glm_mat4_pick3t`
|
#. :c:func:`glm_mat4_pick3t`
|
||||||
#. :c:func:`glm_mat4_ins3`
|
#. :c:func:`glm_mat4_ins3`
|
||||||
@@ -32,6 +33,7 @@ Functions:
|
|||||||
#. :c:func:`glm_mat4_mulN`
|
#. :c:func:`glm_mat4_mulN`
|
||||||
#. :c:func:`glm_mat4_mulv`
|
#. :c:func:`glm_mat4_mulv`
|
||||||
#. :c:func:`glm_mat4_mulv3`
|
#. :c:func:`glm_mat4_mulv3`
|
||||||
|
#. :c:func:`glm_mat4_quat`
|
||||||
#. :c:func:`glm_mat4_transpose_to`
|
#. :c:func:`glm_mat4_transpose_to`
|
||||||
#. :c:func:`glm_mat4_transpose`
|
#. :c:func:`glm_mat4_transpose`
|
||||||
#. :c:func:`glm_mat4_scale_p`
|
#. :c:func:`glm_mat4_scale_p`
|
||||||
@@ -68,6 +70,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[out]* **mat** matrix
|
| *[out]* **mat** matrix
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4_identity_array(mat4 * __restrict mat, size_t count)
|
||||||
|
|
||||||
|
make given matrix array's each element identity matrix
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in,out]* **mat** matrix array (must be aligned (16/32) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of matrices
|
||||||
|
|
||||||
.. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest)
|
.. c:function:: void glm_mat4_pick3(mat4 mat, mat3 dest)
|
||||||
|
|
||||||
copy upper-left of mat4 to mat3
|
copy upper-left of mat4 to mat3
|
||||||
@@ -146,6 +156,14 @@ Functions documentation
|
|||||||
| *[in]* **v** vec3 (right, column vector)
|
| *[in]* **v** vec3 (right, column vector)
|
||||||
| *[out]* **dest** vec3 (result, column vector)
|
| *[out]* **dest** vec3 (result, column vector)
|
||||||
|
|
||||||
|
.. c:function:: void glm_mat4_quat(mat4 m, versor dest)
|
||||||
|
|
||||||
|
convert mat4's rotation part to quaternion
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **m** affine matrix
|
||||||
|
| *[out]* **dest** destination quaternion
|
||||||
|
|
||||||
.. c:function:: void glm_mat4_transpose_to(mat4 m, mat4 dest)
|
.. c:function:: void glm_mat4_transpose_to(mat4 m, mat4 dest)
|
||||||
|
|
||||||
transpose mat4 and store in dest
|
transpose mat4 and store in dest
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ Macros:
|
|||||||
Functions:
|
Functions:
|
||||||
|
|
||||||
1. :c:func:`glm_quat_identity`
|
1. :c:func:`glm_quat_identity`
|
||||||
|
#. :c:func:`glm_quat_identity_array`
|
||||||
#. :c:func:`glm_quat_init`
|
#. :c:func:`glm_quat_init`
|
||||||
#. :c:func:`glm_quat`
|
#. :c:func:`glm_quat`
|
||||||
#. :c:func:`glm_quatv`
|
#. :c:func:`glm_quatv`
|
||||||
@@ -70,6 +71,14 @@ Functions documentation
|
|||||||
Parameters:
|
Parameters:
|
||||||
| *[in, out]* **q** quaternion
|
| *[in, out]* **q** quaternion
|
||||||
|
|
||||||
|
.. c:function:: void glm_quat_identity_array(versor * __restrict q, size_t count)
|
||||||
|
|
||||||
|
| make given quaternion array's each element identity quaternion
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in, out]* **q** quat array (must be aligned (16) if alignment is not disabled)
|
||||||
|
| *[in]* **count** count of quaternions
|
||||||
|
|
||||||
.. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w)
|
.. c:function:: void glm_quat_init(versor q, float x, float y, float z, float w)
|
||||||
|
|
||||||
| inits quaternion with given values
|
| inits quaternion with given values
|
||||||
|
|||||||
74
docs/source/sphere.rst
Normal file
74
docs/source/sphere.rst
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
.. default-domain:: C
|
||||||
|
|
||||||
|
Sphere
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
Header: cglm/sphere.h
|
||||||
|
|
||||||
|
**Definition of sphere:**
|
||||||
|
|
||||||
|
Sphere Representation in cglm is *vec4*: **[center.x, center.y, center.z, radii]**
|
||||||
|
|
||||||
|
You can call any vec3 function by pasing sphere. Because first three elements
|
||||||
|
defines center of sphere.
|
||||||
|
|
||||||
|
Table of contents (click to go):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
|
||||||
|
1. :c:func:`glm_sphere_radii`
|
||||||
|
#. :c:func:`glm_sphere_transform`
|
||||||
|
#. :c:func:`glm_sphere_merge`
|
||||||
|
#. :c:func:`glm_sphere_sphere`
|
||||||
|
#. :c:func:`glm_sphere_point`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: float glm_sphere_radii(vec4 s)
|
||||||
|
|
||||||
|
| helper for getting sphere radius
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s** sphere
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
returns radii
|
||||||
|
|
||||||
|
.. c:function:: void glm_sphere_transform(vec4 s, mat4 m, vec4 dest)
|
||||||
|
|
||||||
|
| apply transform to sphere, it is just wrapper for glm_mat4_mulv3
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s** sphere
|
||||||
|
| *[in]* **m** transform matrix
|
||||||
|
| *[out]* **dest** transformed sphere
|
||||||
|
|
||||||
|
.. c:function:: void glm_sphere_merge(vec4 s1, vec4 s2, vec4 dest)
|
||||||
|
|
||||||
|
| merges two spheres and creates a new one
|
||||||
|
|
||||||
|
two sphere must be in same space, for instance if one in world space then
|
||||||
|
the other must be in world space too, not in local space.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s1** sphere 1
|
||||||
|
| *[in]* **s2** sphere 2
|
||||||
|
| *[out]* **dest** merged/extended sphere
|
||||||
|
|
||||||
|
.. c:function:: bool glm_sphere_sphere(vec4 s1, vec4 s2)
|
||||||
|
|
||||||
|
| check if two sphere intersects
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s1** sphere
|
||||||
|
| *[in]* **s2** other sphere
|
||||||
|
|
||||||
|
.. c:function:: bool glm_sphere_point(vec4 s, vec3 point)
|
||||||
|
|
||||||
|
| check if sphere intersects with point
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s** sphere
|
||||||
|
| *[in]* **point** point
|
||||||
@@ -136,3 +136,38 @@ Functions documentation
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
interpolated value
|
interpolated value
|
||||||
|
|
||||||
|
.. c:function:: bool glm_eq(float a, float b)
|
||||||
|
|
||||||
|
check if two float equal with using EPSILON
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **a** a
|
||||||
|
| *[in]* **b** b
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
true if a and b equals
|
||||||
|
|
||||||
|
.. c:function:: float glm_percent(float from, float to, float current)
|
||||||
|
|
||||||
|
percentage of current value between start and end value
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **from** from value
|
||||||
|
| *[in]* **to** to value
|
||||||
|
| *[in]* **current** value between from and to values
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
clamped normalized percent (0-100 in 0-1)
|
||||||
|
|
||||||
|
.. c:function:: float glm_percentc(float from, float to, float current)
|
||||||
|
|
||||||
|
clamped percentage of current value between start and end value
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **from** from value
|
||||||
|
| *[in]* **to** to value
|
||||||
|
| *[in]* **current** value between from and to values
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
clamped normalized percent (0-100 in 0-1)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ Functions:
|
|||||||
#. :c:func:`glm_vec_inv_to`
|
#. :c:func:`glm_vec_inv_to`
|
||||||
#. :c:func:`glm_vec_normalize`
|
#. :c:func:`glm_vec_normalize`
|
||||||
#. :c:func:`glm_vec_normalize_to`
|
#. :c:func:`glm_vec_normalize_to`
|
||||||
|
#. :c:func:`glm_vec_distance2`
|
||||||
#. :c:func:`glm_vec_distance`
|
#. :c:func:`glm_vec_distance`
|
||||||
#. :c:func:`glm_vec_angle`
|
#. :c:func:`glm_vec_angle`
|
||||||
#. :c:func:`glm_vec_rotate`
|
#. :c:func:`glm_vec_rotate`
|
||||||
@@ -366,6 +367,17 @@ Functions documentation
|
|||||||
| *[in]* **v2** vector2
|
| *[in]* **v2** vector2
|
||||||
| *[out]* **dest** center point
|
| *[out]* **dest** center point
|
||||||
|
|
||||||
|
.. c:function:: float glm_vec_distance2(vec3 v1, vec3 v2)
|
||||||
|
|
||||||
|
squared distance between two vectors
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **mat** vector1
|
||||||
|
| *[in]* **row1** vector2
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
| squared distance (distance * distance)
|
||||||
|
|
||||||
.. c:function:: float glm_vec_distance(vec3 v1, vec3 v2)
|
.. c:function:: float glm_vec_distance(vec3 v1, vec3 v2)
|
||||||
|
|
||||||
distance between two vectors
|
distance between two vectors
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Functions:
|
|||||||
1. :c:func:`glm_vec4`
|
1. :c:func:`glm_vec4`
|
||||||
#. :c:func:`glm_vec4_copy3`
|
#. :c:func:`glm_vec4_copy3`
|
||||||
#. :c:func:`glm_vec4_copy`
|
#. :c:func:`glm_vec4_copy`
|
||||||
|
#. :c:func:`glm_vec4_ucopy`
|
||||||
#. :c:func:`glm_vec4_zero`
|
#. :c:func:`glm_vec4_zero`
|
||||||
#. :c:func:`glm_vec4_one`
|
#. :c:func:`glm_vec4_one`
|
||||||
#. :c:func:`glm_vec4_dot`
|
#. :c:func:`glm_vec4_dot`
|
||||||
@@ -89,6 +90,16 @@ Functions documentation
|
|||||||
| *[in]* **v** source
|
| *[in]* **v** source
|
||||||
| *[in]* **dest** destination
|
| *[in]* **dest** destination
|
||||||
|
|
||||||
|
.. c:function:: void glm_vec4_ucopy(vec4 v, vec4 dest)
|
||||||
|
|
||||||
|
copy all members of [a] to [dest]
|
||||||
|
|
||||||
|
| alignment is not required
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **v** source
|
||||||
|
| *[in]* **dest** destination
|
||||||
|
|
||||||
.. c:function:: void glm_vec4_zero(vec4 v)
|
.. c:function:: void glm_vec4_zero(vec4 v)
|
||||||
|
|
||||||
makes all members zero
|
makes all members zero
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ glm_inv_tr(mat4 mat) {
|
|||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||||
glm_inv_tr_sse2(mat);
|
glm_inv_tr_sse2(mat);
|
||||||
#else
|
#else
|
||||||
CGLM_ALIGN(16) mat3 r;
|
CGLM_ALIGN_MAT mat3 r;
|
||||||
CGLM_ALIGN(16) vec3 t;
|
CGLM_ALIGN(16) vec3 t;
|
||||||
|
|
||||||
/* rotate */
|
/* rotate */
|
||||||
|
|||||||
@@ -44,48 +44,6 @@ CGLM_INLINE
|
|||||||
void
|
void
|
||||||
glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest);
|
glm_mat4_mul(mat4 m1, mat4 m2, mat4 dest);
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief translate existing transform matrix by v vector
|
|
||||||
* and store result in dest
|
|
||||||
*
|
|
||||||
* @param[in] m affine transfrom
|
|
||||||
* @param[in] v translate vector [x, y, z]
|
|
||||||
* @param[out] dest translated matrix
|
|
||||||
*/
|
|
||||||
CGLM_INLINE
|
|
||||||
void
|
|
||||||
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
|
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
|
||||||
|
|
||||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
|
||||||
glmm_store(dest[3],
|
|
||||||
_mm_add_ps(_mm_add_ps(_mm_mul_ps(glmm_load(t[0]),
|
|
||||||
_mm_set1_ps(v[0])),
|
|
||||||
_mm_mul_ps(glmm_load(t[1]),
|
|
||||||
_mm_set1_ps(v[1]))),
|
|
||||||
_mm_add_ps(_mm_mul_ps(glmm_load(t[2]),
|
|
||||||
_mm_set1_ps(v[2])),
|
|
||||||
glmm_load(t[3]))))
|
|
||||||
;
|
|
||||||
|
|
||||||
glmm_store(dest[0], glmm_load(m[0]));
|
|
||||||
glmm_store(dest[1], glmm_load(m[1]));
|
|
||||||
glmm_store(dest[2], glmm_load(m[2]));
|
|
||||||
#else
|
|
||||||
vec4 v1, v2, v3;
|
|
||||||
|
|
||||||
glm_vec4_scale(t[0], v[0], v1);
|
|
||||||
glm_vec4_scale(t[1], v[1], v2);
|
|
||||||
glm_vec4_scale(t[2], v[2], v3);
|
|
||||||
|
|
||||||
glm_vec4_add(v1, t[3], t[3]);
|
|
||||||
glm_vec4_add(v2, t[3], t[3]);
|
|
||||||
glm_vec4_add(v3, t[3], t[3]);
|
|
||||||
|
|
||||||
glm__memcpy(float, dest, t, sizeof(mat4));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief translate existing transform matrix by v vector
|
* @brief translate existing transform matrix by v vector
|
||||||
* and stores result in same matrix
|
* and stores result in same matrix
|
||||||
@@ -119,6 +77,23 @@ glm_translate(mat4 m, vec3 v) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief translate existing transform matrix by v vector
|
||||||
|
* and store result in dest
|
||||||
|
*
|
||||||
|
* source matrix will remain same
|
||||||
|
*
|
||||||
|
* @param[in] m affine transfrom
|
||||||
|
* @param[in] v translate vector [x, y, z]
|
||||||
|
* @param[out] dest translated matrix
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_translate_to(mat4 m, vec3 v, mat4 dest) {
|
||||||
|
glm_mat4_copy(m, dest);
|
||||||
|
glm_translate(dest, v);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief translate existing transform matrix by x factor
|
* @brief translate existing transform matrix by x factor
|
||||||
*
|
*
|
||||||
@@ -194,8 +169,8 @@ glm_translate_z(mat4 m, float z) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_translate_make(mat4 m, vec3 v) {
|
glm_translate_make(mat4 m, vec3 v) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
glm_mat4_identity(m);
|
||||||
glm_translate_to(t, v, m);
|
glm_vec_copy(v, m[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -225,8 +200,10 @@ glm_scale_to(mat4 m, vec3 v, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_scale_make(mat4 m, vec3 v) {
|
glm_scale_make(mat4 m, vec3 v) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
glm_mat4_identity(m);
|
||||||
glm_scale_to(t, v, m);
|
m[0][0] = v[0];
|
||||||
|
m[1][1] = v[1];
|
||||||
|
m[2][2] = v[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -252,7 +229,7 @@ glm_scale(mat4 m, vec3 v) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_scale_uni(mat4 m, float s) {
|
glm_scale_uni(mat4 m, float s) {
|
||||||
vec3 v = { s, s, s };
|
CGLM_ALIGN(8) vec3 v = { s, s, s };
|
||||||
glm_scale_to(m, v, m);
|
glm_scale_to(m, v, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +244,7 @@ glm_scale_uni(mat4 m, float s) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -292,7 +269,7 @@ glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -317,7 +294,7 @@ glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_z(mat4 m, float angle, mat4 dest) {
|
glm_rotate_z(mat4 m, float angle, mat4 dest) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
float c, s;
|
float c, s;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -343,7 +320,7 @@ glm_rotate_z(mat4 m, float angle, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_make(mat4 m, float angle, vec3 axis) {
|
glm_rotate_make(mat4 m, float angle, vec3 axis) {
|
||||||
vec3 axisn, v, vs;
|
CGLM_ALIGN(8) vec3 axisn, v, vs;
|
||||||
float c;
|
float c;
|
||||||
|
|
||||||
c = cosf(angle);
|
c = cosf(angle);
|
||||||
@@ -374,7 +351,7 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate(mat4 m, float angle, vec3 axis) {
|
glm_rotate(mat4 m, float angle, vec3 axis) {
|
||||||
mat4 rot;
|
CGLM_ALIGN_MAT mat4 rot;
|
||||||
glm_rotate_make(rot, angle, axis);
|
glm_rotate_make(rot, angle, axis);
|
||||||
glm_mul_rot(m, rot, m);
|
glm_mul_rot(m, rot, m);
|
||||||
}
|
}
|
||||||
@@ -391,7 +368,7 @@ glm_rotate(mat4 m, float angle, vec3 axis) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
|
glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
|
||||||
vec3 pivotInv;
|
CGLM_ALIGN(8) vec3 pivotInv;
|
||||||
|
|
||||||
glm_vec_inv_to(pivot, pivotInv);
|
glm_vec_inv_to(pivot, pivotInv);
|
||||||
|
|
||||||
@@ -416,12 +393,11 @@ glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) {
|
glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) {
|
||||||
vec3 pivotInv;
|
CGLM_ALIGN(8) vec3 pivotInv;
|
||||||
|
|
||||||
glm_vec_inv_to(pivot, pivotInv);
|
glm_vec_inv_to(pivot, pivotInv);
|
||||||
|
|
||||||
glm_mat4_identity(m);
|
glm_translate_make(m, pivot);
|
||||||
glm_vec_copy(pivot, m[3]);
|
|
||||||
glm_rotate(m, angle, axis);
|
glm_rotate(m, angle, axis);
|
||||||
glm_translate(m, pivotInv);
|
glm_translate(m, pivotInv);
|
||||||
}
|
}
|
||||||
@@ -451,9 +427,8 @@ glm_decompose_scalev(mat4 m, vec3 s) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
bool
|
bool
|
||||||
glm_uniscaled(mat4 m) {
|
glm_uniscaled(mat4 m) {
|
||||||
vec3 s;
|
CGLM_ALIGN(8) vec3 s;
|
||||||
glm_decompose_scalev(m, s);
|
glm_decompose_scalev(m, s);
|
||||||
|
|
||||||
return glm_vec_eq_all(s);
|
return glm_vec_eq_all(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,8 +443,8 @@ glm_uniscaled(mat4 m) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
|
glm_decompose_rs(mat4 m, mat4 r, vec3 s) {
|
||||||
vec4 t = {0.0f, 0.0f, 0.0f, 1.0f};
|
CGLM_ALIGN(16) vec4 t = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
vec3 v;
|
CGLM_ALIGN(8) vec3 v;
|
||||||
|
|
||||||
glm_vec4_copy(m[0], r[0]);
|
glm_vec4_copy(m[0], r[0]);
|
||||||
glm_vec4_copy(m[1], r[1]);
|
glm_vec4_copy(m[1], r[1]);
|
||||||
|
|||||||
@@ -200,4 +200,84 @@ glm_aabb_radius(vec3 box[2]) {
|
|||||||
return glm_aabb_size(box) * 0.5f;
|
return glm_aabb_size(box) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief computes center point of AABB
|
||||||
|
*
|
||||||
|
* @param[in] box bounding box
|
||||||
|
* @param[out] dest center of bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_aabb_center(vec3 box[2], vec3 dest) {
|
||||||
|
glm_vec_center(box[0], box[1], dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if two AABB intersects
|
||||||
|
*
|
||||||
|
* @param[in] box bounding box
|
||||||
|
* @param[in] other other bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_aabb_aabb(vec3 box[2], vec3 other[2]) {
|
||||||
|
return (box[0][0] <= other[1][0] && box[1][0] >= other[0][0])
|
||||||
|
&& (box[0][1] <= other[1][1] && box[1][1] >= other[0][1])
|
||||||
|
&& (box[0][2] <= other[1][2] && box[1][2] >= other[0][2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if AABB intersects with sphere
|
||||||
|
*
|
||||||
|
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
|
||||||
|
* Solid Box - Solid Sphere test.
|
||||||
|
*
|
||||||
|
* @param[in] box solid bounding box
|
||||||
|
* @param[in] s solid sphere
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_aabb_sphere(vec3 box[2], vec4 s) {
|
||||||
|
float dmin;
|
||||||
|
int a, b, c;
|
||||||
|
|
||||||
|
a = s[0] >= box[0][0];
|
||||||
|
b = s[1] >= box[0][1];
|
||||||
|
c = s[2] >= box[0][2];
|
||||||
|
|
||||||
|
dmin = glm_pow2(s[0] - box[a][0])
|
||||||
|
+ glm_pow2(s[1] - box[b][1])
|
||||||
|
+ glm_pow2(s[2] - box[c][2]);
|
||||||
|
|
||||||
|
return dmin <= glm_pow2(s[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if point is inside of AABB
|
||||||
|
*
|
||||||
|
* @param[in] box bounding box
|
||||||
|
* @param[in] point point
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_aabb_point(vec3 box[2], vec3 point) {
|
||||||
|
return (point[0] >= box[0][0] && point[0] <= box[1][0])
|
||||||
|
&& (point[1] >= box[0][1] && point[1] <= box[1][1])
|
||||||
|
&& (point[2] >= box[0][2] && point[2] <= box[1][2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if AABB contains other AABB
|
||||||
|
*
|
||||||
|
* @param[in] box bounding box
|
||||||
|
* @param[in] other other bounding box
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_aabb_contains(vec3 box[2], vec3 other[2]) {
|
||||||
|
return (box[0][0] <= other[0][0] && box[1][0] >= other[1][0])
|
||||||
|
&& (box[0][1] <= other[0][1] && box[1][1] >= other[1][1])
|
||||||
|
&& (box[0][2] <= other[0][2] && box[1][2] >= other[1][2]);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* cglm_box_h */
|
#endif /* cglm_box_h */
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ extern "C" {
|
|||||||
#include "call/box.h"
|
#include "call/box.h"
|
||||||
#include "call/io.h"
|
#include "call/io.h"
|
||||||
#include "call/project.h"
|
#include "call/project.h"
|
||||||
|
#include "call/sphere.h"
|
||||||
|
#include "call/ease.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,20 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s);
|
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s);
|
||||||
|
|
||||||
|
/* affine-mat */
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mul(mat4 m1, mat4 m2, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_inv_tr(mat4 mat);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,6 +32,46 @@ glmc_aabb_crop_until(vec3 box[2],
|
|||||||
vec3 clampBox[2],
|
vec3 clampBox[2],
|
||||||
vec3 dest[2]);
|
vec3 dest[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_frustum(vec3 box[2], vec4 planes[6]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb_invalidate(vec3 box[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_isvalid(vec3 box[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb_size(vec3 box[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb_radius(vec3 box[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb_center(vec3 box[2], vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_aabb(vec3 box[2], vec3 other[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_point(vec3 box[2], vec3 point);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_contains(vec3 box[2], vec3 other[2]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_sphere(vec3 box[2], vec4 s);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,6 +33,26 @@ glmc_ortho(float left,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb(vec3 box[2], mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_default(float aspect, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_default_s(float aspect, float size, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_perspective(float fovy,
|
glmc_perspective(float fovy,
|
||||||
@@ -41,6 +61,14 @@ glmc_perspective(float fovy,
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest);
|
mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_default(float aspect, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize(float aspect, mat4 proj);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
glmc_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
||||||
@@ -53,6 +81,58 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest);
|
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp(mat4 proj,
|
||||||
|
float * __restrict nearVal,
|
||||||
|
float * __restrict farVal,
|
||||||
|
float * __restrict top,
|
||||||
|
float * __restrict bottom,
|
||||||
|
float * __restrict left,
|
||||||
|
float * __restrict right);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decompv(mat4 proj, float dest[6]);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_x(mat4 proj,
|
||||||
|
float * __restrict left,
|
||||||
|
float * __restrict right);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_y(mat4 proj,
|
||||||
|
float * __restrict top,
|
||||||
|
float * __restrict bottom);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_z(mat4 proj,
|
||||||
|
float * __restrict nearVal,
|
||||||
|
float * __restrict farVal);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_far(mat4 proj, float * __restrict farVal);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_near(mat4 proj, float * __restrict nearVal);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_persp_fovy(mat4 proj);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_persp_aspect(mat4 proj);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_sizes(mat4 proj, float fovy, vec4 dest);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
140
include/cglm/call/ease.h
Normal file
140
include/cglm/call/ease.h
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_ease_h
|
||||||
|
#define cglmc_ease_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_linear(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_inout(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_out(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_in(float t);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_inout(float t);
|
||||||
|
|
||||||
|
#endif /* cglmc_ease_h */
|
||||||
@@ -24,6 +24,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat3_identity(mat3 mat);
|
glmc_mat3_identity(mat3 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
||||||
@@ -40,6 +44,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest);
|
glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_quat(mat3 m, versor dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_scale(mat3 m, float s);
|
glmc_mat3_scale(mat3 m, float s);
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat4_identity(mat4 mat);
|
glmc_mat4_identity(mat4 mat);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_pick3(mat4 mat, mat3 dest);
|
glmc_mat4_pick3(mat4 mat, mat3 dest);
|
||||||
@@ -53,6 +57,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest);
|
glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_quat(mat4 m, versor dest);
|
glmc_mat4_quat(mat4 m, versor dest);
|
||||||
@@ -85,6 +93,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_mat4_inv_precise(mat4 mat, mat4 dest);
|
glmc_mat4_inv_precise(mat4 mat, mat4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_inv_fast(mat4 mat, mat4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_swap_col(mat4 mat, int col1, int col2);
|
glmc_mat4_swap_col(mat4 mat, int col1, int col2);
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_quat_identity(versor q);
|
glmc_quat_identity(versor q);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_quat_identity_array(versor * __restrict q, size_t count);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_init(versor q, float x, float y, float z, float w);
|
glmc_quat_init(versor q, float x, float y, float z, float w);
|
||||||
|
|||||||
36
include/cglm/call/sphere.h
Normal file
36
include/cglm/call/sphere.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglmc_sphere_h
|
||||||
|
#define cglmc_sphere_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../cglm.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_sphere_radii(vec4 s);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_sphere_transform(vec4 s, mat4 m, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_sphere_merge(vec4 s1, vec4 s2, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_sphere_sphere(vec4 s1, vec4 s2);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_sphere_point(vec4 s, vec3 point);
|
||||||
|
|
||||||
|
#endif /* cglmc_sphere_h */
|
||||||
@@ -136,6 +136,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec_rotate_m4(mat4 m, vec3 v, vec3 dest);
|
glmc_vec_rotate_m4(mat4 m, vec3 v, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec_rotate_m3(mat3 m, vec3 v, vec3 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec_proj(vec3 a, vec3 b, vec3 dest);
|
glmc_vec_proj(vec3 a, vec3 b, vec3 dest);
|
||||||
@@ -144,6 +148,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec_center(vec3 v1, vec3 v2, vec3 dest);
|
glmc_vec_center(vec3 v1, vec3 v2, vec3 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_vec_distance2(vec3 v1, vec3 v2);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec_distance(vec3 v1, vec3 v2);
|
glmc_vec_distance(vec3 v1, vec3 v2);
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ CGLM_EXPORT
|
|||||||
void
|
void
|
||||||
glmc_vec4_copy(vec4 v, vec4 dest);
|
glmc_vec4_copy(vec4 v, vec4 dest);
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_ucopy(vec4 v, vec4 dest);
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec4_dot(vec4 a, vec4 b);
|
glmc_vec4_dot(vec4 a, vec4 b);
|
||||||
|
|||||||
@@ -198,26 +198,15 @@ glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_ortho_default(float aspect,
|
glm_ortho_default(float aspect, mat4 dest) {
|
||||||
mat4 dest) {
|
|
||||||
if (aspect >= 1.0f) {
|
if (aspect >= 1.0f) {
|
||||||
glm_ortho(-1.0f * aspect,
|
glm_ortho(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||||
1.0f * aspect,
|
|
||||||
-1.0f,
|
|
||||||
1.0f,
|
|
||||||
-100.0f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm_ortho(-1.0f,
|
aspect = 1.0f / aspect;
|
||||||
1.0f,
|
|
||||||
-1.0f / aspect,
|
glm_ortho(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||||
1.0f / aspect,
|
|
||||||
-100.0f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -291,13 +280,8 @@ glm_perspective(float fovy,
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_default(float aspect,
|
glm_perspective_default(float aspect, mat4 dest) {
|
||||||
mat4 dest) {
|
glm_perspective(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||||
glm_perspective((float)CGLM_PI_4,
|
|
||||||
aspect,
|
|
||||||
0.01f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -310,8 +294,7 @@ glm_perspective_default(float aspect,
|
|||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_resize(float aspect,
|
glm_perspective_resize(float aspect, mat4 proj) {
|
||||||
mat4 proj) {
|
|
||||||
if (proj[0][0] == 0.0f)
|
if (proj[0][0] == 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -321,6 +304,9 @@ glm_perspective_resize(float aspect,
|
|||||||
/*!
|
/*!
|
||||||
* @brief set up view matrix
|
* @brief set up view matrix
|
||||||
*
|
*
|
||||||
|
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||||
|
* the eye point to the reference point
|
||||||
|
*
|
||||||
* @param[in] eye eye vector
|
* @param[in] eye eye vector
|
||||||
* @param[in] center center vector
|
* @param[in] center center vector
|
||||||
* @param[in] up up vector
|
* @param[in] up up vector
|
||||||
@@ -332,7 +318,7 @@ glm_lookat(vec3 eye,
|
|||||||
vec3 center,
|
vec3 center,
|
||||||
vec3 up,
|
vec3 up,
|
||||||
mat4 dest) {
|
mat4 dest) {
|
||||||
vec3 f, u, s;
|
CGLM_ALIGN(8) vec3 f, u, s;
|
||||||
|
|
||||||
glm_vec_sub(center, eye, f);
|
glm_vec_sub(center, eye, f);
|
||||||
glm_vec_normalize(f);
|
glm_vec_normalize(f);
|
||||||
@@ -364,6 +350,9 @@ glm_lookat(vec3 eye,
|
|||||||
* convenient wrapper for lookat: if you only have direction not target self
|
* convenient wrapper for lookat: if you only have direction not target self
|
||||||
* then this might be useful. Because you need to get target from direction.
|
* then this might be useful. Because you need to get target from direction.
|
||||||
*
|
*
|
||||||
|
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||||
|
* the eye point to the reference point
|
||||||
|
*
|
||||||
* @param[in] eye eye vector
|
* @param[in] eye eye vector
|
||||||
* @param[in] dir direction vector
|
* @param[in] dir direction vector
|
||||||
* @param[in] up up vector
|
* @param[in] up up vector
|
||||||
@@ -372,7 +361,7 @@ glm_lookat(vec3 eye,
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||||
vec3 target;
|
CGLM_ALIGN(8) vec3 target;
|
||||||
glm_vec_add(eye, dir, target);
|
glm_vec_add(eye, dir, target);
|
||||||
glm_lookat(eye, target, up, dest);
|
glm_lookat(eye, target, up, dest);
|
||||||
}
|
}
|
||||||
@@ -390,7 +379,7 @@ glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
|
glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
|
||||||
vec3 up;
|
CGLM_ALIGN(8) vec3 up;
|
||||||
glm_vec_ortho(dir, up);
|
glm_vec_ortho(dir, up);
|
||||||
glm_look(eye, dir, up, dest);
|
glm_look(eye, dir, up, dest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
#include "sphere.h"
|
||||||
|
#include "ease.h"
|
||||||
|
|
||||||
#endif /* cglm_h */
|
#endif /* cglm_h */
|
||||||
|
|||||||
317
include/cglm/ease.h
Normal file
317
include/cglm/ease.h
Normal file
@@ -0,0 +1,317 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_ease_h
|
||||||
|
#define cglm_ease_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_linear(float t) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_sine_in(float t) {
|
||||||
|
return sinf((t - 1.0f) * GLM_PI_2f) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_sine_out(float t) {
|
||||||
|
return sinf(t * GLM_PI_2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_sine_inout(float t) {
|
||||||
|
return 0.5f * (1.0f - cosf(t * GLM_PIf));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quad_in(float t) {
|
||||||
|
return t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quad_out(float t) {
|
||||||
|
return -(t * (t - 2.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quad_inout(float t) {
|
||||||
|
float tt;
|
||||||
|
|
||||||
|
tt = t * t;
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 2.0f * tt;
|
||||||
|
|
||||||
|
return (-2.0f * tt) + (4.0f * t) - 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_cubic_in(float t) {
|
||||||
|
return t * t * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_cubic_out(float t) {
|
||||||
|
float f;
|
||||||
|
f = t - 1.0f;
|
||||||
|
return f * f * f + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_cubic_inout(float t) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 4.0f * t * t * t;
|
||||||
|
|
||||||
|
f = 2.0f * t - 2.0f;
|
||||||
|
|
||||||
|
return 0.5f * f * f * f + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quart_in(float t) {
|
||||||
|
float f;
|
||||||
|
f = t * t;
|
||||||
|
return f * f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quart_out(float t) {
|
||||||
|
float f;
|
||||||
|
|
||||||
|
f = t - 1.0f;
|
||||||
|
|
||||||
|
return f * f * f * (1.0f - t) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quart_inout(float t) {
|
||||||
|
float f, g;
|
||||||
|
|
||||||
|
if (t < 0.5f) {
|
||||||
|
f = t * t;
|
||||||
|
return 8.0f * f * f;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = t - 1.0f;
|
||||||
|
g = f * f;
|
||||||
|
|
||||||
|
return -8.0f * g * g + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quint_in(float t) {
|
||||||
|
float f;
|
||||||
|
f = t * t;
|
||||||
|
return f * f * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quint_out(float t) {
|
||||||
|
float f, g;
|
||||||
|
|
||||||
|
f = t - 1.0f;
|
||||||
|
g = f * f;
|
||||||
|
|
||||||
|
return g * g * f + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_quint_inout(float t) {
|
||||||
|
float f, g;
|
||||||
|
|
||||||
|
if (t < 0.5f) {
|
||||||
|
f = t * t;
|
||||||
|
return 16.0f * f * f * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = 2.0f * t - 2.0f;
|
||||||
|
g = f * f;
|
||||||
|
|
||||||
|
return 0.5f * g * g * f + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_exp_in(float t) {
|
||||||
|
if (t == 0.0f)
|
||||||
|
return t;
|
||||||
|
|
||||||
|
return powf(2.0f, 10.0f * (t - 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_exp_out(float t) {
|
||||||
|
if (t == 1.0f)
|
||||||
|
return t;
|
||||||
|
|
||||||
|
return 1.0f - powf(2.0f, -10.0f * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_exp_inout(float t) {
|
||||||
|
if (t == 0.0f || t == 1.0f)
|
||||||
|
return t;
|
||||||
|
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 0.5f * powf(2.0f, (20.0f * t) - 10.0f);
|
||||||
|
|
||||||
|
return -0.5f * powf(2.0f, (-20.0f * t) + 10.0f) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_circ_in(float t) {
|
||||||
|
return 1.0f - sqrtf(1.0f - (t * t));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_circ_out(float t) {
|
||||||
|
return sqrtf((2.0f - t) * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_circ_inout(float t) {
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 0.5f * (1.0f - sqrtf(1.0f - 4.0f * (t * t)));
|
||||||
|
|
||||||
|
return 0.5f * (sqrtf(-((2.0f * t) - 3.0f) * ((2.0f * t) - 1.0f)) + 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_back_in(float t) {
|
||||||
|
float o, z;
|
||||||
|
|
||||||
|
o = 1.70158f;
|
||||||
|
z = ((o + 1.0f) * t) - o;
|
||||||
|
|
||||||
|
return t * t * z;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_back_out(float t) {
|
||||||
|
float o, z, n;
|
||||||
|
|
||||||
|
o = 1.70158f;
|
||||||
|
n = t - 1.0f;
|
||||||
|
z = (o + 1.0f) * n + o;
|
||||||
|
|
||||||
|
return n * n * z + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_back_inout(float t) {
|
||||||
|
float o, z, n, m, s, x;
|
||||||
|
|
||||||
|
o = 1.70158f;
|
||||||
|
s = o * 1.525f;
|
||||||
|
x = 0.5;
|
||||||
|
n = t / 0.5f;
|
||||||
|
|
||||||
|
if (n < 1.0f) {
|
||||||
|
z = (s + 1) * n - s;
|
||||||
|
m = n * n * z;
|
||||||
|
return x * m;
|
||||||
|
}
|
||||||
|
|
||||||
|
n -= 2.0f;
|
||||||
|
z = (s + 1.0f) * n + s;
|
||||||
|
m = (n * n * z) + 2;
|
||||||
|
|
||||||
|
return x * m;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_elast_in(float t) {
|
||||||
|
return sinf(13.0f * GLM_PI_2f * t) * powf(2.0f, 10.0f * (t - 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_elast_out(float t) {
|
||||||
|
return sinf(-13.0f * GLM_PI_2f * (t + 1.0f)) * powf(2.0f, -10.0f * t) + 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_elast_inout(float t) {
|
||||||
|
float a;
|
||||||
|
|
||||||
|
a = 2.0f * t;
|
||||||
|
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 0.5f * sinf(13.0f * GLM_PI_2f * a)
|
||||||
|
* powf(2.0f, 10.0f * (a - 1.0f));
|
||||||
|
|
||||||
|
return 0.5f * (sinf(-13.0f * GLM_PI_2f * a)
|
||||||
|
* powf(2.0f, -10.0f * (a - 1.0f)) + 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_bounce_out(float t) {
|
||||||
|
float tt;
|
||||||
|
|
||||||
|
tt = t * t;
|
||||||
|
|
||||||
|
if (t < (4.0f / 11.0f))
|
||||||
|
return (121.0f * tt) / 16.0f;
|
||||||
|
|
||||||
|
if (t < 8.0f / 11.0f)
|
||||||
|
return ((363.0f / 40.0f) * tt) - ((99.0f / 10.0f) * t) + (17.0f / 5.0f);
|
||||||
|
|
||||||
|
if (t < (9.0f / 10.0f))
|
||||||
|
return (4356.0f / 361.0f) * tt
|
||||||
|
- (35442.0f / 1805.0f) * t
|
||||||
|
+ (16061.0f / 1805.0f);
|
||||||
|
|
||||||
|
return ((54.0f / 5.0f) * tt) - ((513.0f / 25.0f) * t) + (268.0f / 25.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_bounce_in(float t) {
|
||||||
|
return 1.0f - glm_ease_bounce_out(1.0f - t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_ease_bounce_inout(float t) {
|
||||||
|
if (t < 0.5f)
|
||||||
|
return 0.5f * (1.0f - glm_ease_bounce_out(t * 2.0f));
|
||||||
|
|
||||||
|
return 0.5f * glm_ease_bounce_out(t * 2.0f - 1.0f) + 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglm_ease_h */
|
||||||
@@ -84,12 +84,12 @@ glm_euler_angles(mat4 m, vec3 dest) {
|
|||||||
thetaZ = atan2f(-m10, m00);
|
thetaZ = atan2f(-m10, m00);
|
||||||
} else { /* m20 == -1 */
|
} else { /* m20 == -1 */
|
||||||
/* Not a unique solution */
|
/* Not a unique solution */
|
||||||
thetaY = -CGLM_PI_2;
|
thetaY = -GLM_PI_2f;
|
||||||
thetaX = -atan2f(m01, m11);
|
thetaX = -atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
}
|
}
|
||||||
} else { /* m20 == +1 */
|
} else { /* m20 == +1 */
|
||||||
thetaY = CGLM_PI_2;
|
thetaY = GLM_PI_2f;
|
||||||
thetaX = atan2f(m01, m11);
|
thetaX = atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
Functions:
|
Functions:
|
||||||
CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest);
|
CGLM_INLINE void glm_mat3_copy(mat3 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_identity(mat3 mat);
|
CGLM_INLINE void glm_mat3_identity(mat3 mat);
|
||||||
|
CGLM_INLINE void glm_mat3_identity_array(mat3 * restrict mat, size_t count);
|
||||||
CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
CGLM_INLINE void glm_mat3_mul(mat3 m1, mat3 m2, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
|
CGLM_INLINE void glm_mat3_transpose_to(mat3 m, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat3_transpose(mat3 m);
|
CGLM_INLINE void glm_mat3_transpose(mat3 m);
|
||||||
@@ -81,10 +82,29 @@ glm_mat3_copy(mat3 mat, mat3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3_identity(mat3 mat) {
|
glm_mat3_identity(mat3 mat) {
|
||||||
mat3 t = GLM_MAT3_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
|
||||||
glm_mat3_copy(t, mat);
|
glm_mat3_copy(t, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix array's each element identity matrix
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix array (must be aligned (16/32)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of matrices
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat3_identity_array(mat3 * __restrict mat, size_t count) {
|
||||||
|
CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_mat3_copy(t, mat[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply m1 and m2 to dest
|
* @brief multiply m1 and m2 to dest
|
||||||
*
|
*
|
||||||
@@ -155,7 +175,7 @@ glm_mat3_transpose_to(mat3 m, mat3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat3_transpose(mat3 m) {
|
glm_mat3_transpose(mat3 m) {
|
||||||
mat3 tmp;
|
CGLM_ALIGN_MAT mat3 tmp;
|
||||||
|
|
||||||
tmp[0][1] = m[1][0];
|
tmp[0][1] = m[1][0];
|
||||||
tmp[0][2] = m[2][0];
|
tmp[0][2] = m[2][0];
|
||||||
@@ -189,9 +209,9 @@ glm_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief convert mat4's rotation part to quaternion
|
* @brief convert mat3 to quaternion
|
||||||
*
|
*
|
||||||
* @param[in] m left matrix
|
* @param[in] m rotation matrix
|
||||||
* @param[out] dest destination quaternion
|
* @param[out] dest destination quaternion
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_ucopy(mat4 mat, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_copy(mat4 mat, mat4 dest);
|
||||||
CGLM_INLINE void glm_mat4_identity(mat4 mat);
|
CGLM_INLINE void glm_mat4_identity(mat4 mat);
|
||||||
|
CGLM_INLINE void glm_mat4_identity_array(mat4 * restrict mat, size_t count);
|
||||||
CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest);
|
CGLM_INLINE void glm_mat4_pick3(mat4 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest);
|
CGLM_INLINE void glm_mat4_pick3t(mat4 mat, mat3 dest);
|
||||||
CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest);
|
CGLM_INLINE void glm_mat4_ins3(mat3 mat, mat4 dest);
|
||||||
@@ -139,10 +140,29 @@ glm_mat4_copy(mat4 mat, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_identity(mat4 mat) {
|
glm_mat4_identity(mat4 mat) {
|
||||||
mat4 t = GLM_MAT4_IDENTITY_INIT;
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
glm_mat4_copy(t, mat);
|
glm_mat4_copy(t, mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given matrix array's each element identity matrix
|
||||||
|
*
|
||||||
|
* @param[in, out] mat matrix array (must be aligned (16/32)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of matrices
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_mat4_identity_array(mat4 * __restrict mat, size_t count) {
|
||||||
|
CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_mat4_copy(t, mat[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief copy upper-left of mat4 to mat3
|
* @brief copy upper-left of mat4 to mat3
|
||||||
*
|
*
|
||||||
@@ -323,7 +343,7 @@ glm_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
|
|||||||
/*!
|
/*!
|
||||||
* @brief convert mat4's rotation part to quaternion
|
* @brief convert mat4's rotation part to quaternion
|
||||||
*
|
*
|
||||||
* @param[in] m left matrix
|
* @param[in] m affine matrix
|
||||||
* @param[out] dest destination quaternion
|
* @param[out] dest destination quaternion
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
@@ -370,20 +390,20 @@ glm_mat4_quat(mat4 m, versor dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief multiply vector with mat4's mat3 part(rotation)
|
* @brief multiply vector with mat4
|
||||||
*
|
*
|
||||||
* @param[in] m mat4(affine transform)
|
* @param[in] m mat4(affine transform)
|
||||||
* @param[in] v vec3
|
* @param[in] v vec3
|
||||||
* @param[out] dest vec3
|
* @param[in] last 4th item to make it vec4
|
||||||
|
* @param[out] dest result vector (vec3)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_mulv3(mat4 m, vec3 v, vec3 dest) {
|
glm_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) {
|
||||||
vec3 res;
|
vec4 res;
|
||||||
res[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2];
|
glm_vec4(v, last, res);
|
||||||
res[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2];
|
glm_mat4_mulv(m, res, res);
|
||||||
res[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2];
|
glm_vec3(res, dest);
|
||||||
glm_vec_copy(res, dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -586,7 +606,7 @@ glm_mat4_inv_fast(mat4 mat, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_swap_col(mat4 mat, int col1, int col2) {
|
glm_mat4_swap_col(mat4 mat, int col1, int col2) {
|
||||||
vec4 tmp;
|
CGLM_ALIGN(16) vec4 tmp;
|
||||||
glm_vec4_copy(mat[col1], tmp);
|
glm_vec4_copy(mat[col1], tmp);
|
||||||
glm_vec4_copy(mat[col2], mat[col1]);
|
glm_vec4_copy(mat[col2], mat[col1]);
|
||||||
glm_vec4_copy(tmp, mat[col2]);
|
glm_vec4_copy(tmp, mat[col2]);
|
||||||
@@ -602,7 +622,7 @@ glm_mat4_swap_col(mat4 mat, int col1, int col2) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_mat4_swap_row(mat4 mat, int row1, int row2) {
|
glm_mat4_swap_row(mat4 mat, int row1, int row2) {
|
||||||
vec4 tmp;
|
CGLM_ALIGN(16) vec4 tmp;
|
||||||
tmp[0] = mat[0][row1];
|
tmp[0] = mat[0][row1];
|
||||||
tmp[1] = mat[1][row1];
|
tmp[1] = mat[1][row1];
|
||||||
tmp[2] = mat[2][row1];
|
tmp[2] = mat[2][row1];
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ glm_unproject(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
|
glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
|
||||||
vec4 pos4, vone = GLM_VEC4_ONE_INIT;
|
CGLM_ALIGN(16) vec4 pos4, vone = GLM_VEC4_ONE_INIT;
|
||||||
|
|
||||||
glm_vec4(pos, 1.0f, pos4);
|
glm_vec4(pos, 1.0f, pos4);
|
||||||
|
|
||||||
|
|||||||
@@ -99,10 +99,29 @@ glm_translate(mat4 m, vec3 v);
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_identity(versor q) {
|
glm_quat_identity(versor q) {
|
||||||
versor v = GLM_QUAT_IDENTITY_INIT;
|
CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT;
|
||||||
glm_vec4_copy(v, q);
|
glm_vec4_copy(v, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief make given quaternion array's each element identity quaternion
|
||||||
|
*
|
||||||
|
* @param[in, out] q quat array (must be aligned (16)
|
||||||
|
* if alignment is not disabled)
|
||||||
|
*
|
||||||
|
* @param[in] count count of quaternions
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_quat_identity_array(versor * __restrict q, size_t count) {
|
||||||
|
CGLM_ALIGN(16) versor v = GLM_QUAT_IDENTITY_INIT;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
glm_vec4_copy(v, q[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief inits quaterion with raw values
|
* @brief inits quaterion with raw values
|
||||||
*
|
*
|
||||||
@@ -131,7 +150,7 @@ glm_quat_init(versor q, float x, float y, float z, float w) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quatv(versor q, float angle, vec3 axis) {
|
glm_quatv(versor q, float angle, vec3 axis) {
|
||||||
vec3 k;
|
CGLM_ALIGN(8) vec3 k;
|
||||||
float a, c, s;
|
float a, c, s;
|
||||||
|
|
||||||
a = angle * 0.5f;
|
a = angle * 0.5f;
|
||||||
@@ -158,7 +177,7 @@ glm_quatv(versor q, float angle, vec3 axis) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat(versor q, float angle, float x, float y, float z) {
|
glm_quat(versor q, float angle, float x, float y, float z) {
|
||||||
vec3 axis = {x, y, z};
|
CGLM_ALIGN(8) vec3 axis = {x, y, z};
|
||||||
glm_quatv(q, angle, axis);
|
glm_quatv(q, angle, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +286,7 @@ glm_quat_conjugate(versor q, versor dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_inv(versor q, versor dest) {
|
glm_quat_inv(versor q, versor dest) {
|
||||||
versor conj;
|
CGLM_ALIGN(8) versor conj;
|
||||||
glm_quat_conjugate(q, conj);
|
glm_quat_conjugate(q, conj);
|
||||||
glm_vec4_scale(conj, 1.0f / glm_vec4_norm2(q), dest);
|
glm_vec4_scale(conj, 1.0f / glm_vec4_norm2(q), dest);
|
||||||
}
|
}
|
||||||
@@ -603,7 +622,7 @@ glm_quat_lerp(versor from, versor to, float t, versor dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_slerp(versor from, versor to, float t, versor dest) {
|
glm_quat_slerp(versor from, versor to, float t, versor dest) {
|
||||||
vec4 q1, q2;
|
CGLM_ALIGN(16) vec4 q1, q2;
|
||||||
float cosTheta, sinTheta, angle;
|
float cosTheta, sinTheta, angle;
|
||||||
|
|
||||||
cosTheta = glm_quat_dot(from, to);
|
cosTheta = glm_quat_dot(from, to);
|
||||||
@@ -646,15 +665,12 @@ glm_quat_slerp(versor from, versor to, float t, versor dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_look(vec3 eye, versor ori, mat4 dest) {
|
glm_quat_look(vec3 eye, versor ori, mat4 dest) {
|
||||||
vec4 t;
|
|
||||||
|
|
||||||
/* orientation */
|
/* orientation */
|
||||||
glm_quat_mat4t(ori, dest);
|
glm_quat_mat4t(ori, dest);
|
||||||
|
|
||||||
/* translate */
|
/* translate */
|
||||||
glm_vec4(eye, 1.0f, t);
|
glm_mat4_mulv3(dest, eye, 1.0f, dest[3]);
|
||||||
glm_mat4_mulv(dest, t, t);
|
glm_vec_flipsign(dest[3]);
|
||||||
glm_vec_flipsign_to(t, dest[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -668,12 +684,12 @@ glm_quat_look(vec3 eye, versor ori, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
|
glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
|
||||||
vec3 axis;
|
CGLM_ALIGN(8) vec3 axis;
|
||||||
float dot, angle;
|
float dot, angle;
|
||||||
|
|
||||||
dot = glm_vec_dot(dir, fwd);
|
dot = glm_vec_dot(dir, fwd);
|
||||||
if (fabsf(dot + 1.0f) < 0.000001f) {
|
if (fabsf(dot + 1.0f) < 0.000001f) {
|
||||||
glm_quat_init(dest, up[0], up[1], up[2], CGLM_PI);
|
glm_quat_init(dest, up[0], up[1], up[2], GLM_PIf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +718,7 @@ glm_quat_for(vec3 dir, vec3 fwd, vec3 up, versor dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest) {
|
glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest) {
|
||||||
vec3 dir;
|
CGLM_ALIGN(8) vec3 dir;
|
||||||
glm_vec_sub(to, from, dir);
|
glm_vec_sub(to, from, dir);
|
||||||
glm_quat_for(dir, fwd, up, dest);
|
glm_quat_for(dir, fwd, up, dest);
|
||||||
}
|
}
|
||||||
@@ -717,8 +733,8 @@ glm_quat_forp(vec3 from, vec3 to, vec3 fwd, vec3 up, versor dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
|
glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
|
||||||
versor p;
|
CGLM_ALIGN(16) versor p;
|
||||||
vec3 u, v1, v2;
|
CGLM_ALIGN(8) vec3 u, v1, v2;
|
||||||
float s;
|
float s;
|
||||||
|
|
||||||
glm_quat_normalize_to(q, p);
|
glm_quat_normalize_to(q, p);
|
||||||
@@ -745,7 +761,7 @@ glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_rotate(mat4 m, versor q, mat4 dest) {
|
glm_quat_rotate(mat4 m, versor q, mat4 dest) {
|
||||||
mat4 rot;
|
CGLM_ALIGN_MAT mat4 rot;
|
||||||
glm_quat_mat4(q, rot);
|
glm_quat_mat4(q, rot);
|
||||||
glm_mul_rot(m, rot, dest);
|
glm_mul_rot(m, rot, dest);
|
||||||
}
|
}
|
||||||
@@ -760,7 +776,7 @@ glm_quat_rotate(mat4 m, versor q, mat4 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) {
|
glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) {
|
||||||
vec3 pivotInv;
|
CGLM_ALIGN(8) vec3 pivotInv;
|
||||||
|
|
||||||
glm_vec_inv_to(pivot, pivotInv);
|
glm_vec_inv_to(pivot, pivotInv);
|
||||||
|
|
||||||
@@ -784,12 +800,11 @@ glm_quat_rotate_at(mat4 m, versor q, vec3 pivot) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) {
|
glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) {
|
||||||
vec3 pivotInv;
|
CGLM_ALIGN(8) vec3 pivotInv;
|
||||||
|
|
||||||
glm_vec_inv_to(pivot, pivotInv);
|
glm_vec_inv_to(pivot, pivotInv);
|
||||||
|
|
||||||
glm_mat4_identity(m);
|
glm_translate_make(m, pivot);
|
||||||
glm_vec_copy(pivot, m[3]);
|
|
||||||
glm_quat_rotate(m, q, m);
|
glm_quat_rotate(m, q, m);
|
||||||
glm_translate(m, pivotInv);
|
glm_translate(m, pivotInv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,21 +27,24 @@ glm_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
||||||
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
||||||
|
|
||||||
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
|
/* 0x03: 0b00000011 */
|
||||||
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000000); /* l k j i l k j i */
|
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
|
||||||
|
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
|
||||||
|
|
||||||
/* f f f f a a a a */
|
/* f f f f a a a a */
|
||||||
/* g g g g c c c c */
|
/* h h h h c c c c */
|
||||||
/* e e e e b b b b */
|
/* e e e e b b b b */
|
||||||
y7 = _mm256_permute_ps(y0, 0b10101010);
|
/* g g g g d d d d */
|
||||||
y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0));
|
y6 = _mm256_permutevar_ps(y0, _mm256_set_epi32(1, 1, 1, 1, 0, 0, 0, 0));
|
||||||
|
y7 = _mm256_permutevar_ps(y0, _mm256_set_epi32(3, 3, 3, 3, 2, 2, 2, 2));
|
||||||
y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1));
|
y8 = _mm256_permutevar_ps(y0, _mm256_set_epi32(0, 0, 0, 0, 1, 1, 1, 1));
|
||||||
|
y9 = _mm256_permutevar_ps(y0, _mm256_set_epi32(2, 2, 2, 2, 3, 3, 3, 3));
|
||||||
|
|
||||||
glmm_store256(dest[0],
|
glmm_store256(dest[0],
|
||||||
_mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6),
|
_mm256_add_ps(_mm256_add_ps(_mm256_mul_ps(y2, y6),
|
||||||
_mm256_mul_ps(y4, y8)),
|
_mm256_mul_ps(y3, y7)),
|
||||||
_mm256_mul_ps(y5, y7)));
|
_mm256_add_ps(_mm256_mul_ps(y4, y8),
|
||||||
|
_mm256_mul_ps(y5, y9))));
|
||||||
|
|
||||||
/* n n n n i i i i */
|
/* n n n n i i i i */
|
||||||
/* p p p p k k k k */
|
/* p p p p k k k k */
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ glm_mat4_mul_avx(mat4 m1, mat4 m2, mat4 dest) {
|
|||||||
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
y2 = glmm_load256(m1[0]); /* h g f e d c b a */
|
||||||
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
y3 = glmm_load256(m1[2]); /* p o n m l k j i */
|
||||||
|
|
||||||
y4 = _mm256_permute2f128_ps(y2, y2, 0b00000011); /* d c b a h g f e */
|
/* 0x03: 0b00000011 */
|
||||||
y5 = _mm256_permute2f128_ps(y3, y3, 0b00000011); /* l k j i p o n m */
|
y4 = _mm256_permute2f128_ps(y2, y2, 0x03); /* d c b a h g f e */
|
||||||
|
y5 = _mm256_permute2f128_ps(y3, y3, 0x03); /* l k j i p o n m */
|
||||||
|
|
||||||
/* f f f f a a a a */
|
/* f f f f a a a a */
|
||||||
/* h h h h c c c c */
|
/* h h h h c c c c */
|
||||||
|
|||||||
99
include/cglm/sphere.h
Normal file
99
include/cglm/sphere.h
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cglm_sphere_h
|
||||||
|
#define cglm_sphere_h
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "mat4.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sphere Representation in cglm: [center.x, center.y, center.z, radii]
|
||||||
|
|
||||||
|
You could use this representation or you can convert it to vec4 before call
|
||||||
|
any function
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief helper for getting sphere radius
|
||||||
|
*
|
||||||
|
* @param[in] s sphere
|
||||||
|
*
|
||||||
|
* @return returns radii
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_sphere_radii(vec4 s) {
|
||||||
|
return s[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief apply transform to sphere, it is just wrapper for glm_mat4_mulv3
|
||||||
|
*
|
||||||
|
* @param[in] s sphere
|
||||||
|
* @param[in] m transform matrix
|
||||||
|
* @param[out] dest transformed sphere
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_sphere_transform(vec4 s, mat4 m, vec4 dest) {
|
||||||
|
glm_mat4_mulv3(m, s, 1.0f, dest);
|
||||||
|
dest[3] = s[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief merges two spheres and creates a new one
|
||||||
|
*
|
||||||
|
* two sphere must be in same space, for instance if one in world space then
|
||||||
|
* the other must be in world space too, not in local space.
|
||||||
|
*
|
||||||
|
* @param[in] s1 sphere 1
|
||||||
|
* @param[in] s2 sphere 2
|
||||||
|
* @param[out] dest merged/extended sphere
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_sphere_merge(vec4 s1, vec4 s2, vec4 dest) {
|
||||||
|
float dist, radii;
|
||||||
|
|
||||||
|
dist = glm_vec_distance(s1, s2);
|
||||||
|
radii = dist + s1[3] + s2[3];
|
||||||
|
|
||||||
|
radii = glm_max(radii, s1[3]);
|
||||||
|
radii = glm_max(radii, s2[3]);
|
||||||
|
|
||||||
|
glm_vec_center(s1, s2, dest);
|
||||||
|
dest[3] = radii;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if two sphere intersects
|
||||||
|
*
|
||||||
|
* @param[in] s1 sphere
|
||||||
|
* @param[in] s2 other sphere
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_sphere_sphere(vec4 s1, vec4 s2) {
|
||||||
|
return glm_vec_distance2(s1, s2) <= glm_pow2(s1[3] + s2[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if sphere intersects with point
|
||||||
|
*
|
||||||
|
* @param[in] s sphere
|
||||||
|
* @param[in] point point
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_sphere_point(vec4 s, vec3 point) {
|
||||||
|
float rr;
|
||||||
|
rr = s[3] * s[3];
|
||||||
|
return glm_vec_distance2(point, s) <= rr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* cglm_sphere_h */
|
||||||
@@ -26,18 +26,58 @@
|
|||||||
# define CGLM_ALIGN_IF(X) /* no alignment */
|
# define CGLM_ALIGN_IF(X) /* no alignment */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __AVX__
|
||||||
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(32)
|
||||||
|
#else
|
||||||
|
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef float vec2[2];
|
typedef float vec2[2];
|
||||||
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
||||||
typedef int ivec3[3];
|
typedef int ivec3[3];
|
||||||
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
typedef CGLM_ALIGN_IF(16) float vec4[4];
|
||||||
|
|
||||||
|
#ifdef __AVX__
|
||||||
|
typedef CGLM_ALIGN_IF(32) vec3 mat3[3];
|
||||||
|
typedef CGLM_ALIGN_IF(32) vec4 mat4[4];
|
||||||
|
#else
|
||||||
typedef vec3 mat3[3];
|
typedef vec3 mat3[3];
|
||||||
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef vec4 versor;
|
typedef vec4 versor;
|
||||||
|
|
||||||
#define CGLM_PI ((float)M_PI)
|
#define GLM_E 2.71828182845904523536028747135266250 /* e */
|
||||||
#define CGLM_PI_2 ((float)M_PI_2)
|
#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
|
||||||
#define CGLM_PI_4 ((float)M_PI_4)
|
#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
|
||||||
|
#define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */
|
||||||
|
#define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */
|
||||||
|
#define GLM_PI 3.14159265358979323846264338327950288 /* pi */
|
||||||
|
#define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
|
||||||
|
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
|
||||||
|
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
|
||||||
|
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
|
||||||
|
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
|
||||||
|
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
|
||||||
|
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
|
||||||
|
|
||||||
|
#define GLM_Ef ((float)GLM_E)
|
||||||
|
#define GLM_LOG2Ef ((float)GLM_LOG2E)
|
||||||
|
#define GLM_LOG10Ef ((float)GLM_LOG10E)
|
||||||
|
#define GLM_LN2f ((float)GLM_LN2)
|
||||||
|
#define GLM_LN10f ((float)GLM_LN10)
|
||||||
|
#define GLM_PIf ((float)GLM_PI)
|
||||||
|
#define GLM_PI_2f ((float)GLM_PI_2)
|
||||||
|
#define GLM_PI_4f ((float)GLM_PI_4)
|
||||||
|
#define GLM_1_PIf ((float)GLM_1_PI)
|
||||||
|
#define GLM_2_PIf ((float)GLM_2_PI)
|
||||||
|
#define GLM_2_SQRTPIf ((float)GLM_2_SQRTPI)
|
||||||
|
#define GLM_SQRT2f ((float)GLM_SQRT2)
|
||||||
|
#define GLM_SQRT1_2f ((float)GLM_SQRT1_2)
|
||||||
|
|
||||||
|
/* DEPRECATED! use GLM_PI and friends */
|
||||||
|
#define CGLM_PI GLM_PIf
|
||||||
|
#define CGLM_PI_2 GLM_PI_2f
|
||||||
|
#define CGLM_PI_4 GLM_PI_4f
|
||||||
|
|
||||||
#endif /* cglm_types_h */
|
#endif /* cglm_types_h */
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
#define cglm_util_h
|
#define cglm_util_h
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define GLM_MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||||
|
#define GLM_MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief get sign of 32 bit integer as +1, -1, 0
|
* @brief get sign of 32 bit integer as +1, -1, 0
|
||||||
@@ -54,7 +58,7 @@ glm_signf(float val) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_rad(float deg) {
|
glm_rad(float deg) {
|
||||||
return deg * CGLM_PI / 180.0f;
|
return deg * GLM_PIf / 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -65,7 +69,7 @@ glm_rad(float deg) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_deg(float rad) {
|
glm_deg(float rad) {
|
||||||
return rad * 180.0f / CGLM_PI;
|
return rad * 180.0f / GLM_PIf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -76,7 +80,7 @@ glm_deg(float rad) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_make_rad(float *deg) {
|
glm_make_rad(float *deg) {
|
||||||
*deg = *deg * CGLM_PI / 180.0f;
|
*deg = *deg * GLM_PIf / 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -87,7 +91,7 @@ glm_make_rad(float *deg) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_make_deg(float *rad) {
|
glm_make_deg(float *rad) {
|
||||||
*rad = *rad * 180.0f / CGLM_PI;
|
*rad = *rad * 180.0f / GLM_PIf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -98,7 +102,6 @@ glm_make_deg(float *rad) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_pow2(float x) {
|
glm_pow2(float x) {
|
||||||
|
|
||||||
return x * x;
|
return x * x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +146,17 @@ glm_clamp(float val, float minVal, float maxVal) {
|
|||||||
return glm_min(glm_max(val, minVal), maxVal);
|
return glm_min(glm_max(val, minVal), maxVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief clamp a number to zero and one
|
||||||
|
*
|
||||||
|
* @param[in] val value to clamp
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_clamp_zo(float val) {
|
||||||
|
return glm_clamp(val, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief linear interpolation between two number
|
* @brief linear interpolation between two number
|
||||||
*
|
*
|
||||||
@@ -155,7 +169,52 @@ glm_clamp(float val, float minVal, float maxVal) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_lerp(float from, float to, float t) {
|
glm_lerp(float from, float to, float t) {
|
||||||
return from + glm_clamp(t, 0.0f, 1.0f) * (to - from);
|
return from + glm_clamp_zo(t) * (to - from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief check if two float equal with using EPSILON
|
||||||
|
*
|
||||||
|
* @param[in] a a
|
||||||
|
* @param[in] b b
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
bool
|
||||||
|
glm_eq(float a, float b) {
|
||||||
|
return fabsf(a - b) <= FLT_EPSILON;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief percentage of current value between start and end value
|
||||||
|
*
|
||||||
|
* maybe fraction could be alternative name.
|
||||||
|
*
|
||||||
|
* @param[in] from from value
|
||||||
|
* @param[in] to to value
|
||||||
|
* @param[in] current current value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_percent(float from, float to, float current) {
|
||||||
|
float t;
|
||||||
|
|
||||||
|
if ((t = to - from) == 0.0f)
|
||||||
|
return 1.0f;
|
||||||
|
|
||||||
|
return (current - from) / t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief clamped percentage of current value between start and end value
|
||||||
|
*
|
||||||
|
* @param[in] from from value
|
||||||
|
* @param[in] to to value
|
||||||
|
* @param[in] current current value
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_percentc(float from, float to, float current) {
|
||||||
|
return glm_clamp(glm_percent(from, to, current), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* cglm_util_h */
|
#endif /* cglm_util_h */
|
||||||
|
|||||||
@@ -454,8 +454,7 @@ glm_vec_inv(vec3 v) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_vec_inv_to(vec3 v, vec3 dest) {
|
glm_vec_inv_to(vec3 v, vec3 dest) {
|
||||||
glm_vec_copy(v, dest);
|
glm_vec_flipsign_to(v, dest);
|
||||||
glm_vec_flipsign(dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -634,6 +633,21 @@ glm_vec_center(vec3 v1, vec3 v2, vec3 dest) {
|
|||||||
glm_vec_scale(dest, 0.5f, dest);
|
glm_vec_scale(dest, 0.5f, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief squared distance between two vectors
|
||||||
|
*
|
||||||
|
* @param[in] v1 vector1
|
||||||
|
* @param[in] v2 vector2
|
||||||
|
* @return returns squared distance (distance * distance)
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
float
|
||||||
|
glm_vec_distance2(vec3 v1, vec3 v2) {
|
||||||
|
return glm_pow2(v2[0] - v1[0])
|
||||||
|
+ glm_pow2(v2[1] - v1[1])
|
||||||
|
+ glm_pow2(v2[2] - v1[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief distance between two vectors
|
* @brief distance between two vectors
|
||||||
*
|
*
|
||||||
@@ -644,9 +658,7 @@ glm_vec_center(vec3 v1, vec3 v2, vec3 dest) {
|
|||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
glm_vec_distance(vec3 v1, vec3 v2) {
|
glm_vec_distance(vec3 v1, vec3 v2) {
|
||||||
return sqrtf(glm_pow2(v2[0] - v1[0])
|
return sqrtf(glm_vec_distance2(v1, v2));
|
||||||
+ glm_pow2(v2[1] - v1[1])
|
|
||||||
+ glm_pow2(v2[2] - v1[2]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -724,7 +736,7 @@ glm_vec_lerp(vec3 from, vec3 to, float t, vec3 dest) {
|
|||||||
vec3 s, v;
|
vec3 s, v;
|
||||||
|
|
||||||
/* from + s * (to - from) */
|
/* from + s * (to - from) */
|
||||||
glm_vec_broadcast(glm_clamp(t, 0.0f, 1.0f), s);
|
glm_vec_broadcast(glm_clamp_zo(t), s);
|
||||||
glm_vec_sub(to, from, v);
|
glm_vec_sub(to, from, v);
|
||||||
glm_vec_mulv(s, v, v);
|
glm_vec_mulv(s, v, v);
|
||||||
glm_vec_add(from, v, dest);
|
glm_vec_add(from, v, dest);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
CGLM_INLINE void glm_vec4(vec3 v3, float last, vec4 dest);
|
CGLM_INLINE void glm_vec4(vec3 v3, float last, vec4 dest);
|
||||||
CGLM_INLINE void glm_vec4_copy3(vec4 a, vec3 dest);
|
CGLM_INLINE void glm_vec4_copy3(vec4 a, vec3 dest);
|
||||||
CGLM_INLINE void glm_vec4_copy(vec4 v, vec4 dest);
|
CGLM_INLINE void glm_vec4_copy(vec4 v, vec4 dest);
|
||||||
|
CGLM_INLINE void glm_vec4_ucopy(vec4 v, vec4 dest);
|
||||||
CGLM_INLINE float glm_vec4_dot(vec4 a, vec4 b);
|
CGLM_INLINE float glm_vec4_dot(vec4 a, vec4 b);
|
||||||
CGLM_INLINE float glm_vec4_norm2(vec4 v);
|
CGLM_INLINE float glm_vec4_norm2(vec4 v);
|
||||||
CGLM_INLINE float glm_vec4_norm(vec4 vec);
|
CGLM_INLINE float glm_vec4_norm(vec4 vec);
|
||||||
@@ -120,6 +121,23 @@ glm_vec4_copy(vec4 v, vec4 dest) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief copy all members of [a] to [dest]
|
||||||
|
*
|
||||||
|
* alignment is not required
|
||||||
|
*
|
||||||
|
* @param[in] v source
|
||||||
|
* @param[out] dest destination
|
||||||
|
*/
|
||||||
|
CGLM_INLINE
|
||||||
|
void
|
||||||
|
glm_vec4_ucopy(vec4 v, vec4 dest) {
|
||||||
|
dest[0] = v[0];
|
||||||
|
dest[1] = v[1];
|
||||||
|
dest[2] = v[2];
|
||||||
|
dest[3] = v[3];
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief make vector zero
|
* @brief make vector zero
|
||||||
*
|
*
|
||||||
@@ -698,7 +716,7 @@ glm_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest) {
|
|||||||
vec4 s, v;
|
vec4 s, v;
|
||||||
|
|
||||||
/* from + s * (to - from) */
|
/* from + s * (to - from) */
|
||||||
glm_vec4_broadcast(glm_clamp(t, 0.0f, 1.0f), s);
|
glm_vec4_broadcast(glm_clamp_zo(t), s);
|
||||||
glm_vec4_sub(to, from, v);
|
glm_vec4_sub(to, from, v);
|
||||||
glm_vec4_mulv(s, v, v);
|
glm_vec4_mulv(s, v, v);
|
||||||
glm_vec4_add(from, v, dest);
|
glm_vec4_add(from, v, dest);
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
#define CGLM_VERSION_MAJOR 0
|
#define CGLM_VERSION_MAJOR 0
|
||||||
#define CGLM_VERSION_MINOR 4
|
#define CGLM_VERSION_MINOR 4
|
||||||
#define CGLM_VERSION_PATCH 5
|
#define CGLM_VERSION_PATCH 9
|
||||||
|
|
||||||
#endif /* cglm_version_h */
|
#endif /* cglm_version_h */
|
||||||
|
|||||||
12
makefile.am
12
makefile.am
@@ -55,7 +55,9 @@ cglm_HEADERS = include/cglm/version.h \
|
|||||||
include/cglm/frustum.h \
|
include/cglm/frustum.h \
|
||||||
include/cglm/box.h \
|
include/cglm/box.h \
|
||||||
include/cglm/color.h \
|
include/cglm/color.h \
|
||||||
include/cglm/project.h
|
include/cglm/project.h \
|
||||||
|
include/cglm/sphere.h \
|
||||||
|
include/cglm/ease.h
|
||||||
|
|
||||||
cglm_calldir=$(includedir)/cglm/call
|
cglm_calldir=$(includedir)/cglm/call
|
||||||
cglm_call_HEADERS = include/cglm/call/mat4.h \
|
cglm_call_HEADERS = include/cglm/call/mat4.h \
|
||||||
@@ -70,7 +72,9 @@ cglm_call_HEADERS = include/cglm/call/mat4.h \
|
|||||||
include/cglm/call/plane.h \
|
include/cglm/call/plane.h \
|
||||||
include/cglm/call/frustum.h \
|
include/cglm/call/frustum.h \
|
||||||
include/cglm/call/box.h \
|
include/cglm/call/box.h \
|
||||||
include/cglm/call/project.h
|
include/cglm/call/project.h \
|
||||||
|
include/cglm/call/sphere.h \
|
||||||
|
include/cglm/call/ease.h
|
||||||
|
|
||||||
cglm_simddir=$(includedir)/cglm/simd
|
cglm_simddir=$(includedir)/cglm/simd
|
||||||
cglm_simd_HEADERS = include/cglm/simd/intrin.h
|
cglm_simd_HEADERS = include/cglm/simd/intrin.h
|
||||||
@@ -101,7 +105,9 @@ libcglm_la_SOURCES=\
|
|||||||
src/plane.c \
|
src/plane.c \
|
||||||
src/frustum.c \
|
src/frustum.c \
|
||||||
src/box.c \
|
src/box.c \
|
||||||
src/project.c
|
src/project.c \
|
||||||
|
src/sphere.c \
|
||||||
|
src/ease.c
|
||||||
|
|
||||||
test_tests_SOURCES=\
|
test_tests_SOURCES=\
|
||||||
test/src/test_common.c \
|
test/src/test_common.c \
|
||||||
|
|||||||
18
src/affine.c
18
src/affine.c
@@ -133,3 +133,21 @@ void
|
|||||||
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s) {
|
glmc_decompose(mat4 m, vec4 t, mat4 r, vec3 s) {
|
||||||
glm_decompose(m, t, r, s);
|
glm_decompose(m, t, r, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mul(mat4 m1, mat4 m2, mat4 dest) {
|
||||||
|
glm_mul(m1, m2, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mul_rot(mat4 m1, mat4 m2, mat4 dest) {
|
||||||
|
glm_mul_rot(m1, m2, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_inv_tr(mat4 mat) {
|
||||||
|
glm_inv_tr(mat);
|
||||||
|
}
|
||||||
|
|||||||
60
src/box.c
60
src/box.c
@@ -34,3 +34,63 @@ glmc_aabb_crop_until(vec3 box[2],
|
|||||||
vec3 dest[2]) {
|
vec3 dest[2]) {
|
||||||
glm_aabb_crop_until(box, cropBox, clampBox, dest);
|
glm_aabb_crop_until(box, cropBox, clampBox, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_frustum(vec3 box[2], vec4 planes[6]) {
|
||||||
|
return glm_aabb_frustum(box, planes);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb_invalidate(vec3 box[2]) {
|
||||||
|
glm_aabb_invalidate(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_isvalid(vec3 box[2]) {
|
||||||
|
return glm_aabb_isvalid(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb_size(vec3 box[2]) {
|
||||||
|
return glm_aabb_size(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_aabb_radius(vec3 box[2]) {
|
||||||
|
return glm_aabb_radius(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_aabb_center(vec3 box[2], vec3 dest) {
|
||||||
|
glm_aabb_center(box, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_aabb(vec3 box[2], vec3 other[2]) {
|
||||||
|
return glm_aabb_aabb(box, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_point(vec3 box[2], vec3 point) {
|
||||||
|
return glm_aabb_point(box, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_contains(vec3 box[2], vec3 other[2]) {
|
||||||
|
return glm_aabb_contains(box, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_aabb_sphere(vec3 box[2], vec4 s) {
|
||||||
|
return glm_aabb_sphere(box, s);
|
||||||
|
}
|
||||||
|
|||||||
114
src/cam.c
114
src/cam.c
@@ -44,6 +44,36 @@ glmc_ortho(float left,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb(vec3 box[2], mat4 dest) {
|
||||||
|
glm_ortho_aabb(box, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) {
|
||||||
|
glm_ortho_aabb_p(box, padding, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
|
||||||
|
glm_ortho_aabb_pz(box, padding, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_default(float aspect, mat4 dest) {
|
||||||
|
glm_ortho_default(aspect, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_ortho_default_s(float aspect, float size, mat4 dest) {
|
||||||
|
glm_ortho_default_s(aspect, size, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_perspective(float fovy,
|
glmc_perspective(float fovy,
|
||||||
@@ -58,6 +88,18 @@ glmc_perspective(float fovy,
|
|||||||
dest);
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_default(float aspect, mat4 dest) {
|
||||||
|
glm_perspective_default(aspect, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_perspective_resize(float aspect, mat4 proj) {
|
||||||
|
glm_perspective_resize(aspect, proj);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_lookat(vec3 eye,
|
glmc_lookat(vec3 eye,
|
||||||
@@ -78,3 +120,75 @@ void
|
|||||||
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
|
glmc_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
|
||||||
glm_look_anyup(eye, dir, dest);
|
glm_look_anyup(eye, dir, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp(mat4 proj,
|
||||||
|
float * __restrict nearVal,
|
||||||
|
float * __restrict farVal,
|
||||||
|
float * __restrict top,
|
||||||
|
float * __restrict bottom,
|
||||||
|
float * __restrict left,
|
||||||
|
float * __restrict right) {
|
||||||
|
glm_persp_decomp(proj, nearVal, farVal, top, bottom, left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decompv(mat4 proj, float dest[6]) {
|
||||||
|
glm_persp_decompv(proj, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_x(mat4 proj,
|
||||||
|
float * __restrict left,
|
||||||
|
float * __restrict right) {
|
||||||
|
glm_persp_decomp_x(proj, left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_y(mat4 proj,
|
||||||
|
float * __restrict top,
|
||||||
|
float * __restrict bottom) {
|
||||||
|
glm_persp_decomp_y(proj, top, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_z(mat4 proj,
|
||||||
|
float * __restrict nearVal,
|
||||||
|
float * __restrict farVal) {
|
||||||
|
glm_persp_decomp_z(proj, nearVal, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_far(mat4 proj, float * __restrict farVal) {
|
||||||
|
glm_persp_decomp_far(proj, farVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_decomp_near(mat4 proj, float * __restrict nearVal) {
|
||||||
|
glm_persp_decomp_near(proj, nearVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_persp_fovy(mat4 proj) {
|
||||||
|
return glm_persp_fovy(proj);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_persp_aspect(mat4 proj) {
|
||||||
|
return glm_persp_aspect(proj);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_persp_sizes(mat4 proj, float fovy, vec4 dest) {
|
||||||
|
glm_persp_sizes(proj, fovy, dest);
|
||||||
|
}
|
||||||
|
|||||||
195
src/ease.c
Normal file
195
src/ease.c
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../include/cglm/cglm.h"
|
||||||
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_linear(float t) {
|
||||||
|
return glm_ease_linear(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_in(float t) {
|
||||||
|
return glm_ease_sine_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_out(float t) {
|
||||||
|
return glm_ease_sine_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_sine_inout(float t) {
|
||||||
|
return glm_ease_sine_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_in(float t) {
|
||||||
|
return glm_ease_quad_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_out(float t) {
|
||||||
|
return glm_ease_quad_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quad_inout(float t) {
|
||||||
|
return glm_ease_quad_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_in(float t) {
|
||||||
|
return glm_ease_cubic_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_out(float t) {
|
||||||
|
return glm_ease_cubic_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_cubic_inout(float t) {
|
||||||
|
return glm_ease_cubic_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_in(float t) {
|
||||||
|
return glm_ease_quart_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_out(float t) {
|
||||||
|
return glm_ease_quart_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quart_inout(float t) {
|
||||||
|
return glm_ease_quart_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_in(float t) {
|
||||||
|
return glm_ease_quint_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_out(float t) {
|
||||||
|
return glm_ease_quint_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_quint_inout(float t) {
|
||||||
|
return glm_ease_quint_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_in(float t) {
|
||||||
|
return glm_ease_exp_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_out(float t) {
|
||||||
|
return glm_ease_exp_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_exp_inout(float t) {
|
||||||
|
return glm_ease_exp_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_in(float t) {
|
||||||
|
return glm_ease_circ_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_out(float t) {
|
||||||
|
return glm_ease_circ_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_circ_inout(float t) {
|
||||||
|
return glm_ease_circ_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_in(float t) {
|
||||||
|
return glm_ease_back_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_out(float t) {
|
||||||
|
return glm_ease_back_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_back_inout(float t) {
|
||||||
|
return glm_ease_back_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_in(float t) {
|
||||||
|
return glm_ease_elast_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_out(float t) {
|
||||||
|
return glm_ease_elast_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_elast_inout(float t) {
|
||||||
|
return glm_ease_elast_inout(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_out(float t) {
|
||||||
|
return glm_ease_bounce_out(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_in(float t) {
|
||||||
|
return glm_ease_bounce_in(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_ease_bounce_inout(float t) {
|
||||||
|
return glm_ease_bounce_inout(t);
|
||||||
|
}
|
||||||
12
src/mat3.c
12
src/mat3.c
@@ -20,6 +20,12 @@ glmc_mat3_identity(mat3 mat) {
|
|||||||
glm_mat3_identity(mat);
|
glm_mat3_identity(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_identity_array(mat3 * __restrict mat, size_t count) {
|
||||||
|
glm_mat3_identity_array(mat, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) {
|
glmc_mat3_mul(mat3 m1, mat3 m2, mat3 dest) {
|
||||||
@@ -44,6 +50,12 @@ glmc_mat3_mulv(mat3 m, vec3 v, vec3 dest) {
|
|||||||
glm_mat3_mulv(m, v, dest);
|
glm_mat3_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat3_quat(mat3 m, versor dest) {
|
||||||
|
glm_mat3_quat(m, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat3_scale(mat3 m, float s) {
|
glmc_mat3_scale(mat3 m, float s) {
|
||||||
|
|||||||
18
src/mat4.c
18
src/mat4.c
@@ -26,6 +26,12 @@ glmc_mat4_identity(mat4 mat) {
|
|||||||
glm_mat4_identity(mat);
|
glm_mat4_identity(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_identity_array(mat4 * __restrict mat, size_t count) {
|
||||||
|
glm_mat4_identity_array(mat, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_pick3(mat4 mat, mat3 dest) {
|
glmc_mat4_pick3(mat4 mat, mat3 dest) {
|
||||||
@@ -62,6 +68,12 @@ glmc_mat4_mulv(mat4 m, vec4 v, vec4 dest) {
|
|||||||
glm_mat4_mulv(m, v, dest);
|
glm_mat4_mulv(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_mulv3(mat4 m, vec3 v, float last, vec3 dest) {
|
||||||
|
glm_mat4_mulv3(m, v, last, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_quat(mat4 m, versor dest) {
|
glmc_mat4_quat(mat4 m, versor dest) {
|
||||||
@@ -110,6 +122,12 @@ glmc_mat4_inv_precise(mat4 mat, mat4 dest) {
|
|||||||
glm_mat4_inv_precise(mat, dest);
|
glm_mat4_inv_precise(mat, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_mat4_inv_fast(mat4 mat, mat4 dest) {
|
||||||
|
glm_mat4_inv_fast(mat, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_mat4_swap_col(mat4 mat, int col1, int col2) {
|
glmc_mat4_swap_col(mat4 mat, int col1, int col2) {
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
#include "../include/cglm/cglm.h"
|
#include "../include/cglm/cglm.h"
|
||||||
#include "../include/cglm/call.h"
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_identity(versor q) {
|
glmc_quat_identity(versor q) {
|
||||||
glm_quat_identity(q);
|
glm_quat_identity(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_quat_identity_array(versor * __restrict q, size_t count) {
|
||||||
|
glm_quat_identity_array(q, count);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_quat_init(versor q, float x, float y, float z, float w) {
|
glmc_quat_init(versor q, float x, float y, float z, float w) {
|
||||||
|
|||||||
39
src/sphere.c
Normal file
39
src/sphere.c
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c), Recep Aslantas.
|
||||||
|
*
|
||||||
|
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||||
|
* Full license can be found in the LICENSE file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../include/cglm/cglm.h"
|
||||||
|
#include "../include/cglm/call.h"
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_sphere_radii(vec4 s) {
|
||||||
|
return glm_sphere_radii(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_sphere_transform(vec4 s, mat4 m, vec4 dest) {
|
||||||
|
glm_sphere_transform(s, m, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_sphere_merge(vec4 s1, vec4 s2, vec4 dest) {
|
||||||
|
glm_sphere_merge(s1, s2, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_sphere_sphere(vec4 s1, vec4 s2) {
|
||||||
|
return glm_sphere_sphere(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
bool
|
||||||
|
glmc_sphere_point(vec4 s, vec3 point) {
|
||||||
|
return glm_sphere_point(s, point);
|
||||||
|
}
|
||||||
12
src/vec3.c
12
src/vec3.c
@@ -188,6 +188,12 @@ glmc_vec_rotate_m4(mat4 m, vec3 v, vec3 dest) {
|
|||||||
glm_vec_rotate_m4(m, v, dest);
|
glm_vec_rotate_m4(m, v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec_rotate_m3(mat3 m, vec3 v, vec3 dest) {
|
||||||
|
glm_vec_rotate_m3(m, v, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
void
|
void
|
||||||
glmc_vec_proj(vec3 a, vec3 b, vec3 dest) {
|
glmc_vec_proj(vec3 a, vec3 b, vec3 dest) {
|
||||||
@@ -200,6 +206,12 @@ glmc_vec_center(vec3 v1, vec3 v2, vec3 dest) {
|
|||||||
glm_vec_center(v1, v2, dest);
|
glm_vec_center(v1, v2, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
float
|
||||||
|
glmc_vec_distance2(vec3 v1, vec3 v2) {
|
||||||
|
return glm_vec_distance2(v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec_distance(vec3 v1, vec3 v2) {
|
glmc_vec_distance(vec3 v1, vec3 v2) {
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ glmc_vec4_copy(vec4 v, vec4 dest) {
|
|||||||
glm_vec4_copy(v, dest);
|
glm_vec4_copy(v, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGLM_EXPORT
|
||||||
|
void
|
||||||
|
glmc_vec4_ucopy(vec4 v, vec4 dest) {
|
||||||
|
glm_vec4_ucopy(v, dest);
|
||||||
|
}
|
||||||
|
|
||||||
CGLM_EXPORT
|
CGLM_EXPORT
|
||||||
float
|
float
|
||||||
glmc_vec4_dot(vec4 a, vec4 b) {
|
glmc_vec4_dot(vec4 a, vec4 b) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ test_affine(void **state) {
|
|||||||
mat4 t1, t2, t3, t4, t5;
|
mat4 t1, t2, t3, t4, t5;
|
||||||
|
|
||||||
/* test translate is postmultiplied */
|
/* test translate is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -21,16 +21,16 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test rotate is postmultiplied */
|
/* test rotate is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate(t2, M_PI_4, GLM_YUP);
|
glm_rotate(t2, GLM_PI_4f, GLM_YUP);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test scale is postmultiplied */
|
/* test scale is postmultiplied */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
glm_scale_make(t4, (vec3){3, 5, 6});
|
glm_scale_make(t4, (vec3){3, 5, 6});
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t3, t5);
|
test_assert_mat4_eq(t3, t5);
|
||||||
|
|
||||||
/* test translate_x */
|
/* test translate_x */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 0, 0});
|
glm_translate_make(t2, (vec3){34, 0, 0});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -49,7 +49,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test translate_y */
|
/* test translate_y */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){0, 57, 0});
|
glm_translate_make(t2, (vec3){0, 57, 0});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -57,7 +57,7 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test translate_z */
|
/* test translate_z */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){0, 0, 36});
|
glm_translate_make(t2, (vec3){0, 0, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
glmc_mat4_mul(t1, t2, t3); /* R * T */
|
||||||
@@ -65,43 +65,43 @@ test_affine(void **state) {
|
|||||||
test_assert_mat4_eq(t1, t3);
|
test_assert_mat4_eq(t1, t3);
|
||||||
|
|
||||||
/* test rotate_x */
|
/* test rotate_x */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){1, 0, 0});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){1, 0, 0});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_x(t2, M_PI_4, t2);
|
glm_rotate_x(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate_y */
|
/* test rotate_y */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 1, 0});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 1, 0});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_y(t2, M_PI_4, t2);
|
glm_rotate_y(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate_z */
|
/* test rotate_z */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
|
|
||||||
glm_rotate_z(t2, M_PI_4, t2);
|
glm_rotate_z(t2, GLM_PI_4f, t2);
|
||||||
test_assert_mat4_eq(t2, t3);
|
test_assert_mat4_eq(t2, t3);
|
||||||
|
|
||||||
/* test rotate */
|
/* test rotate */
|
||||||
glmc_rotate_make(t1, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate_make(t1, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
|
|
||||||
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
glmc_mat4_mul(t2, t1, t3); /* T * R */
|
||||||
glmc_rotate(t2, M_PI_4, (vec3){0, 0, 1});
|
glmc_rotate(t2, GLM_PI_4f, (vec3){0, 0, 1});
|
||||||
|
|
||||||
test_assert_mat4_eq(t3, t2);
|
test_assert_mat4_eq(t3, t2);
|
||||||
|
|
||||||
/* test scale_uni */
|
/* test scale_uni */
|
||||||
glmc_rotate_make(t1, M_PI_4, GLM_YUP);
|
glmc_rotate_make(t1, GLM_PI_4f, GLM_YUP);
|
||||||
glm_translate_make(t2, (vec3){34, 57, 36});
|
glm_translate_make(t2, (vec3){34, 57, 36});
|
||||||
glm_scale_make(t4, (vec3){3, 3, 3});
|
glm_scale_make(t4, (vec3){3, 3, 3});
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<ClCompile Include="..\src\box.c" />
|
<ClCompile Include="..\src\box.c" />
|
||||||
<ClCompile Include="..\src\cam.c" />
|
<ClCompile Include="..\src\cam.c" />
|
||||||
<ClCompile Include="..\src\dllmain.c" />
|
<ClCompile Include="..\src\dllmain.c" />
|
||||||
|
<ClCompile Include="..\src\ease.c" />
|
||||||
<ClCompile Include="..\src\euler.c" />
|
<ClCompile Include="..\src\euler.c" />
|
||||||
<ClCompile Include="..\src\frustum.c" />
|
<ClCompile Include="..\src\frustum.c" />
|
||||||
<ClCompile Include="..\src\io.c" />
|
<ClCompile Include="..\src\io.c" />
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
<ClCompile Include="..\src\plane.c" />
|
<ClCompile Include="..\src\plane.c" />
|
||||||
<ClCompile Include="..\src\project.c" />
|
<ClCompile Include="..\src\project.c" />
|
||||||
<ClCompile Include="..\src\quat.c" />
|
<ClCompile Include="..\src\quat.c" />
|
||||||
|
<ClCompile Include="..\src\sphere.c" />
|
||||||
<ClCompile Include="..\src\vec3.c" />
|
<ClCompile Include="..\src\vec3.c" />
|
||||||
<ClCompile Include="..\src\vec4.c" />
|
<ClCompile Include="..\src\vec4.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -42,6 +44,7 @@
|
|||||||
<ClInclude Include="..\include\cglm\call\affine.h" />
|
<ClInclude Include="..\include\cglm\call\affine.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\box.h" />
|
<ClInclude Include="..\include\cglm\call\box.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\cam.h" />
|
<ClInclude Include="..\include\cglm\call\cam.h" />
|
||||||
|
<ClInclude Include="..\include\cglm\call\ease.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\euler.h" />
|
<ClInclude Include="..\include\cglm\call\euler.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\frustum.h" />
|
<ClInclude Include="..\include\cglm\call\frustum.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\io.h" />
|
<ClInclude Include="..\include\cglm\call\io.h" />
|
||||||
@@ -50,12 +53,14 @@
|
|||||||
<ClInclude Include="..\include\cglm\call\plane.h" />
|
<ClInclude Include="..\include\cglm\call\plane.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\project.h" />
|
<ClInclude Include="..\include\cglm\call\project.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\quat.h" />
|
<ClInclude Include="..\include\cglm\call\quat.h" />
|
||||||
|
<ClInclude Include="..\include\cglm\call\sphere.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\vec3.h" />
|
<ClInclude Include="..\include\cglm\call\vec3.h" />
|
||||||
<ClInclude Include="..\include\cglm\call\vec4.h" />
|
<ClInclude Include="..\include\cglm\call\vec4.h" />
|
||||||
<ClInclude Include="..\include\cglm\cam.h" />
|
<ClInclude Include="..\include\cglm\cam.h" />
|
||||||
<ClInclude Include="..\include\cglm\cglm.h" />
|
<ClInclude Include="..\include\cglm\cglm.h" />
|
||||||
<ClInclude Include="..\include\cglm\color.h" />
|
<ClInclude Include="..\include\cglm\color.h" />
|
||||||
<ClInclude Include="..\include\cglm\common.h" />
|
<ClInclude Include="..\include\cglm\common.h" />
|
||||||
|
<ClInclude Include="..\include\cglm\ease.h" />
|
||||||
<ClInclude Include="..\include\cglm\euler.h" />
|
<ClInclude Include="..\include\cglm\euler.h" />
|
||||||
<ClInclude Include="..\include\cglm\frustum.h" />
|
<ClInclude Include="..\include\cglm\frustum.h" />
|
||||||
<ClInclude Include="..\include\cglm\io.h" />
|
<ClInclude Include="..\include\cglm\io.h" />
|
||||||
@@ -72,6 +77,7 @@
|
|||||||
<ClInclude Include="..\include\cglm\simd\sse2\mat3.h" />
|
<ClInclude Include="..\include\cglm\simd\sse2\mat3.h" />
|
||||||
<ClInclude Include="..\include\cglm\simd\sse2\mat4.h" />
|
<ClInclude Include="..\include\cglm\simd\sse2\mat4.h" />
|
||||||
<ClInclude Include="..\include\cglm\simd\sse2\quat.h" />
|
<ClInclude Include="..\include\cglm\simd\sse2\quat.h" />
|
||||||
|
<ClInclude Include="..\include\cglm\sphere.h" />
|
||||||
<ClInclude Include="..\include\cglm\types.h" />
|
<ClInclude Include="..\include\cglm\types.h" />
|
||||||
<ClInclude Include="..\include\cglm\util.h" />
|
<ClInclude Include="..\include\cglm\util.h" />
|
||||||
<ClInclude Include="..\include\cglm\vec3-ext.h" />
|
<ClInclude Include="..\include\cglm\vec3-ext.h" />
|
||||||
|
|||||||
@@ -78,6 +78,12 @@
|
|||||||
<ClCompile Include="..\src\project.c">
|
<ClCompile Include="..\src\project.c">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\sphere.c">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\ease.c">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\src\config.h">
|
<ClInclude Include="..\src\config.h">
|
||||||
@@ -215,5 +221,17 @@
|
|||||||
<ClInclude Include="..\include\cglm\call\project.h">
|
<ClInclude Include="..\include\cglm\call\project.h">
|
||||||
<Filter>include\cglm\call</Filter>
|
<Filter>include\cglm\call</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\cglm\call\sphere.h">
|
||||||
|
<Filter>include\cglm\call</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\cglm\sphere.h">
|
||||||
|
<Filter>include\cglm</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\cglm\call\ease.h">
|
||||||
|
<Filter>include\cglm\call</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\cglm\ease.h">
|
||||||
|
<Filter>include\cglm</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user