Compare commits

..

25 Commits

Author SHA1 Message Date
Recep Aslantas
2e1790ccf9 Merge pull request #59 from jonathanplatzer/avx
Fix alignment issue when using AVX
2018-07-19 11:38:55 +03:00
Jonathan Platzer
cc5f533fc9 Add macro for automatic alignment of matrices 2018-07-19 10:14:30 +02:00
Jonathan Platzer
2d63d7e0cd Fix alignment issue when using AVX 2018-07-18 12:03:38 +02:00
Recep Aslantas
3738499927 update doc for vec4_ucopy 2018-07-14 12:12:15 +03:00
Recep Aslantas
1d527dc2f0 unalignned version for vec4_copy 2018-07-14 12:03:42 +03:00
Recep Aslantas
43c4d05d4a new version for clamp: clamp to zero and one 2018-07-12 11:39:56 +03:00
Recep Aslantas
c5f5032fcc fix function params docs 2018-07-10 11:42:18 +03:00
Recep Aslantas
5d605ce372 avoid zero division for percent
* two value may be same, in this case now returns 1.
* to must be >= from and current <= to && current >= from
2018-07-10 10:54:31 +03:00
Recep Aslantas
c216c0cb7e add MIN and MAX macros
because we could use min/max for intergers too. it may not guarantee that MIN and MAX macros will always be defined by compiler
2018-06-26 15:27:53 +03:00
Recep Aslantas
eb8e0df6df update version 2018-06-21 10:54:53 +03:00
Recep Aslantas
1775bf7458 Merge pull request #57 from recp/anim
Animation Utils
2018-06-21 10:48:19 +03:00
Recep Aslantas
3adeac06f8 update build files 2018-06-21 10:07:51 +03:00
Recep Aslantas
669777eb37 additional utils 2018-06-18 17:55:25 +03:00
Recep Aslantas
02f6c67393 improve easing funcs 2018-06-15 08:55:59 +03:00
Recep Aslantas
564324f5d2 easing functions 2018-06-10 10:29:02 +03:00
Recep Aslantas
93e6c3c102 Merge pull request #56 from recp/sphere
aabb and sphere intersect functions
2018-06-09 18:43:54 +03:00
Recep Aslantas
857265b892 sphere point intersection 2018-06-09 18:21:29 +03:00
Recep Aslantas
fc14cedf89 update version 2018-06-09 18:10:54 +03:00
Recep Aslantas
7a80178357 improve quat_look 2018-06-09 18:10:44 +03:00
Recep Aslantas
720b617ee0 sphere and aabb 2018-05-30 23:42:22 +03:00
Recep Aslantas
3dc9070909 squared distance for vec3 2018-05-30 23:35:59 +03:00
Recep Aslantas
6b2b4b4f12 implement glm_aabb_sphere as GraphicsGems Solid Box - Solid Sphere test 2018-05-30 23:00:18 +03:00
Recep Aslantas
c8fc460ba1 add support for spheres 2018-05-29 23:29:09 +03:00
Recep Aslantas
5b3aabc103 aabb intersect functions
* AABB vs AABB
* AABB vs Point
* AABB vs Sphere
* AABB contains AABB
2018-05-29 23:19:39 +03:00
Recep Aslantas
af812e86eb add a note to clarify up vector restriction for glm_lookat and glm_look 2018-05-29 11:30:38 +03:00
39 changed files with 1308 additions and 37 deletions

View File

@@ -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

View File

@@ -7,7 +7,7 @@
#***************************************************************************** #*****************************************************************************
AC_PREREQ([2.69]) AC_PREREQ([2.69])
AC_INIT([cglm], [0.4.6], [info@recp.me]) AC_INIT([cglm], [0.4.8], [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])

View File

@@ -45,3 +45,4 @@ Follow the :doc:`build` documentation for this
util util
io io
call call
sphere

View File

@@ -29,6 +29,10 @@ Functions:
#. :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_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
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
@@ -137,6 +141,41 @@ Functions documentation
| computes center point of AABB | 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: Parameters:
| *[in]* **box** bounding box | *[in]* **box** bounding box
| *[out]* **box** center of 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

View File

@@ -167,11 +167,13 @@ 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
| *[in]* **up** up vector | *[in]* **up** up vector
| *[out]* **dest** result matrix | *[out]* **dest** result matrix
.. c:function:: void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) .. c:function:: void glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest)
@@ -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

View File

@@ -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.6' version = u'0.4.8'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = u'0.4.6' release = u'0.4.8'
# 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.

74
docs/source/sphere.rst Normal file
View 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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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 */

View File

@@ -244,7 +244,7 @@ glm_scale_uni(mat4 m, float s) {
CGLM_INLINE CGLM_INLINE
void void
glm_rotate_x(mat4 m, float angle, mat4 dest) { glm_rotate_x(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT; CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s; float c, s;
c = cosf(angle); c = cosf(angle);
@@ -269,7 +269,7 @@ glm_rotate_x(mat4 m, float angle, mat4 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_rotate_y(mat4 m, float angle, mat4 dest) { glm_rotate_y(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT; CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s; float c, s;
c = cosf(angle); c = cosf(angle);
@@ -294,7 +294,7 @@ glm_rotate_y(mat4 m, float angle, mat4 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_rotate_z(mat4 m, float angle, mat4 dest) { glm_rotate_z(mat4 m, float angle, mat4 dest) {
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT; CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
float c, s; float c, s;
c = cosf(angle); c = cosf(angle);
@@ -351,7 +351,7 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
CGLM_INLINE CGLM_INLINE
void void
glm_rotate(mat4 m, float angle, vec3 axis) { glm_rotate(mat4 m, float angle, vec3 axis) {
CGLM_ALIGN(16) mat4 rot; CGLM_ALIGN_MAT mat4 rot;
glm_rotate_make(rot, angle, axis); glm_rotate_make(rot, angle, axis);
glm_mul_rot(m, rot, m); glm_mul_rot(m, rot, m);
} }

View File

@@ -212,4 +212,72 @@ glm_aabb_center(vec3 box[2], vec3 dest) {
glm_vec_center(box[0], box[1], 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 */

View File

@@ -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
} }

View File

@@ -56,6 +56,22 @@ CGLM_EXPORT
void void
glmc_aabb_center(vec3 box[2], vec3 dest); 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

140
include/cglm/call/ease.h Normal file
View 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 */

View 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 */

View File

@@ -148,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);

View File

@@ -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);

View File

@@ -321,6 +321,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
@@ -364,6 +367,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

View File

@@ -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
View 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) * CGLM_PI_2) + 1.0f;
}
CGLM_INLINE
float
glm_ease_sine_out(float t) {
return sinf(t * CGLM_PI_2);
}
CGLM_INLINE
float
glm_ease_sine_inout(float t) {
return 0.5f * (1.0f - cosf(t * CGLM_PI));
}
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 * CGLM_PI_2 * t) * powf(2.0f, 10.0f * (t - 1.0f));
}
CGLM_INLINE
float
glm_ease_elast_out(float t) {
return sinf(-13.0f * CGLM_PI_2 * (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 * CGLM_PI_2 * a)
* powf(2.0f, 10.0f * (a - 1.0f));
return 0.5f * (sinf(-13.0f * CGLM_PI_2 * 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 */

View File

@@ -81,7 +81,7 @@ glm_mat3_copy(mat3 mat, mat3 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_mat3_identity(mat3 mat) { glm_mat3_identity(mat3 mat) {
CGLM_ALIGN(16) mat3 t = GLM_MAT3_IDENTITY_INIT; CGLM_ALIGN_MAT mat3 t = GLM_MAT3_IDENTITY_INIT;
glm_mat3_copy(t, mat); glm_mat3_copy(t, mat);
} }
@@ -155,7 +155,7 @@ glm_mat3_transpose_to(mat3 m, mat3 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_mat3_transpose(mat3 m) { glm_mat3_transpose(mat3 m) {
CGLM_ALIGN(16) mat3 tmp; CGLM_ALIGN_MAT mat3 tmp;
tmp[0][1] = m[1][0]; tmp[0][1] = m[1][0];
tmp[0][2] = m[2][0]; tmp[0][2] = m[2][0];

View File

@@ -139,7 +139,7 @@ glm_mat4_copy(mat4 mat, mat4 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_mat4_identity(mat4 mat) { glm_mat4_identity(mat4 mat) {
CGLM_ALIGN(16) mat4 t = GLM_MAT4_IDENTITY_INIT; CGLM_ALIGN_MAT mat4 t = GLM_MAT4_IDENTITY_INIT;
glm_mat4_copy(t, mat); glm_mat4_copy(t, mat);
} }

View File

@@ -646,15 +646,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) {
CGLM_ALIGN(16) 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]);
} }
/*! /*!
@@ -745,7 +742,7 @@ glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
CGLM_INLINE CGLM_INLINE
void void
glm_quat_rotate(mat4 m, versor q, mat4 dest) { glm_quat_rotate(mat4 m, versor q, mat4 dest) {
CGLM_ALIGN(16) mat4 rot; CGLM_ALIGN_MAT mat4 rot;
glm_quat_mat4(q, rot); glm_quat_mat4(q, rot);
glm_mul_rot(m, rot, dest); glm_mul_rot(m, rot, dest);
} }

99
include/cglm/sphere.h Normal file
View 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 */

View File

@@ -26,13 +26,25 @@
# 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];
typedef vec3 mat3[3]; #ifdef __AVX__
typedef CGLM_ALIGN_IF(32) vec3 mat3[3];
typedef CGLM_ALIGN_IF(32) vec4 mat4[4];
#else
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;

View File

@@ -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
@@ -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 */

View File

@@ -633,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
* *
@@ -643,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]));
} }
/*! /*!
@@ -723,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);

View File

@@ -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);

View File

@@ -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 6 #define CGLM_VERSION_PATCH 8
#endif /* cglm_version_h */ #endif /* cglm_version_h */

View File

@@ -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 \

View File

@@ -70,3 +70,27 @@ void
glmc_aabb_center(vec3 box[2], vec3 dest) { glmc_aabb_center(vec3 box[2], vec3 dest) {
glm_aabb_center(box, 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);
}

195
src/ease.c Normal file
View 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);
}

39
src/sphere.c Normal file
View 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);
}

View File

@@ -206,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) {

View File

@@ -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) {

View File

@@ -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" />

View File

@@ -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>