mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e1790ccf9 | ||
|
|
cc5f533fc9 | ||
|
|
2d63d7e0cd | ||
|
|
3738499927 | ||
|
|
1d527dc2f0 | ||
|
|
43c4d05d4a | ||
|
|
c5f5032fcc | ||
|
|
5d605ce372 | ||
|
|
c216c0cb7e | ||
|
|
eb8e0df6df | ||
|
|
1775bf7458 | ||
|
|
3adeac06f8 | ||
|
|
669777eb37 | ||
|
|
02f6c67393 | ||
|
|
564324f5d2 |
@@ -7,7 +7,7 @@
|
||||
#*****************************************************************************
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([cglm], [0.4.7], [info@recp.me])
|
||||
AC_INIT([cglm], [0.4.8], [info@recp.me])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'0.4.7'
|
||||
version = u'0.4.8'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = u'0.4.7'
|
||||
release = u'0.4.8'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -136,3 +136,38 @@ Functions documentation
|
||||
|
||||
Returns:
|
||||
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)
|
||||
|
||||
@@ -24,6 +24,7 @@ Functions:
|
||||
1. :c:func:`glm_vec4`
|
||||
#. :c:func:`glm_vec4_copy3`
|
||||
#. :c:func:`glm_vec4_copy`
|
||||
#. :c:func:`glm_vec4_ucopy`
|
||||
#. :c:func:`glm_vec4_zero`
|
||||
#. :c:func:`glm_vec4_one`
|
||||
#. :c:func:`glm_vec4_dot`
|
||||
@@ -89,6 +90,16 @@ Functions documentation
|
||||
| *[in]* **v** source
|
||||
| *[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)
|
||||
|
||||
makes all members zero
|
||||
|
||||
@@ -151,7 +151,7 @@ glm_inv_tr(mat4 mat) {
|
||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||
glm_inv_tr_sse2(mat);
|
||||
#else
|
||||
CGLM_ALIGN(16) mat3 r;
|
||||
CGLM_ALIGN_MAT mat3 r;
|
||||
CGLM_ALIGN(16) vec3 t;
|
||||
|
||||
/* rotate */
|
||||
|
||||
@@ -244,7 +244,7 @@ glm_scale_uni(mat4 m, float s) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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;
|
||||
|
||||
c = cosf(angle);
|
||||
@@ -269,7 +269,7 @@ glm_rotate_x(mat4 m, float angle, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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;
|
||||
|
||||
c = cosf(angle);
|
||||
@@ -294,7 +294,7 @@ glm_rotate_y(mat4 m, float angle, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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;
|
||||
|
||||
c = cosf(angle);
|
||||
@@ -351,7 +351,7 @@ glm_rotate_make(mat4 m, float angle, vec3 axis) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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_mul_rot(m, rot, m);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ extern "C" {
|
||||
#include "call/io.h"
|
||||
#include "call/project.h"
|
||||
#include "call/sphere.h"
|
||||
#include "call/ease.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
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 */
|
||||
@@ -37,6 +37,10 @@ CGLM_EXPORT
|
||||
void
|
||||
glmc_vec4_copy(vec4 v, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec4_ucopy(vec4 v, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_vec4_dot(vec4 a, vec4 b);
|
||||
|
||||
@@ -25,5 +25,6 @@
|
||||
#include "io.h"
|
||||
#include "project.h"
|
||||
#include "sphere.h"
|
||||
#include "ease.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) * 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 */
|
||||
@@ -81,7 +81,7 @@ glm_mat3_copy(mat3 mat, mat3 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ glm_mat3_transpose_to(mat3 m, mat3 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat3_transpose(mat3 m) {
|
||||
CGLM_ALIGN(16) mat3 tmp;
|
||||
CGLM_ALIGN_MAT mat3 tmp;
|
||||
|
||||
tmp[0][1] = m[1][0];
|
||||
tmp[0][2] = m[2][0];
|
||||
|
||||
@@ -139,7 +139,7 @@ glm_mat4_copy(mat4 mat, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -742,7 +742,7 @@ glm_quat_rotatev(versor q, vec3 v, vec3 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
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_mul_rot(m, rot, dest);
|
||||
}
|
||||
|
||||
@@ -26,13 +26,25 @@
|
||||
# define CGLM_ALIGN_IF(X) /* no alignment */
|
||||
#endif
|
||||
|
||||
#ifdef __AVX__
|
||||
# define CGLM_ALIGN_MAT CGLM_ALIGN(32)
|
||||
#else
|
||||
# define CGLM_ALIGN_MAT CGLM_ALIGN(16)
|
||||
#endif
|
||||
|
||||
typedef float vec2[2];
|
||||
typedef CGLM_ALIGN_IF(8) float vec3[3];
|
||||
typedef int ivec3[3];
|
||||
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 CGLM_ALIGN_IF(16) vec4 mat4[4];
|
||||
#endif
|
||||
|
||||
|
||||
typedef vec4 versor;
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
#define cglm_util_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
|
||||
@@ -142,6 +146,17 @@ glm_clamp(float val, float minVal, float 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
|
||||
*
|
||||
@@ -154,7 +169,52 @@ glm_clamp(float val, float minVal, float maxVal) {
|
||||
CGLM_INLINE
|
||||
float
|
||||
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 */
|
||||
|
||||
@@ -736,7 +736,7 @@ glm_vec_lerp(vec3 from, vec3 to, float t, vec3 dest) {
|
||||
vec3 s, v;
|
||||
|
||||
/* 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_mulv(s, v, v);
|
||||
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_copy3(vec4 a, vec3 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_norm2(vec4 v);
|
||||
CGLM_INLINE float glm_vec4_norm(vec4 vec);
|
||||
@@ -120,6 +121,23 @@ glm_vec4_copy(vec4 v, vec4 dest) {
|
||||
#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
|
||||
*
|
||||
@@ -698,7 +716,7 @@ glm_vec4_lerp(vec4 from, vec4 to, float t, vec4 dest) {
|
||||
vec4 s, v;
|
||||
|
||||
/* 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_mulv(s, v, v);
|
||||
glm_vec4_add(from, v, dest);
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
|
||||
#define CGLM_VERSION_MAJOR 0
|
||||
#define CGLM_VERSION_MINOR 4
|
||||
#define CGLM_VERSION_PATCH 7
|
||||
#define CGLM_VERSION_PATCH 8
|
||||
|
||||
#endif /* cglm_version_h */
|
||||
|
||||
@@ -56,7 +56,8 @@ cglm_HEADERS = include/cglm/version.h \
|
||||
include/cglm/box.h \
|
||||
include/cglm/color.h \
|
||||
include/cglm/project.h \
|
||||
include/cglm/sphere.h
|
||||
include/cglm/sphere.h \
|
||||
include/cglm/ease.h
|
||||
|
||||
cglm_calldir=$(includedir)/cglm/call
|
||||
cglm_call_HEADERS = include/cglm/call/mat4.h \
|
||||
@@ -72,7 +73,8 @@ cglm_call_HEADERS = include/cglm/call/mat4.h \
|
||||
include/cglm/call/frustum.h \
|
||||
include/cglm/call/box.h \
|
||||
include/cglm/call/project.h \
|
||||
include/cglm/call/sphere.h
|
||||
include/cglm/call/sphere.h \
|
||||
include/cglm/call/ease.h
|
||||
|
||||
cglm_simddir=$(includedir)/cglm/simd
|
||||
cglm_simd_HEADERS = include/cglm/simd/intrin.h
|
||||
@@ -104,7 +106,8 @@ libcglm_la_SOURCES=\
|
||||
src/frustum.c \
|
||||
src/box.c \
|
||||
src/project.c \
|
||||
src/sphere.c
|
||||
src/sphere.c \
|
||||
src/ease.c
|
||||
|
||||
test_tests_SOURCES=\
|
||||
test/src/test_common.c \
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -38,6 +38,12 @@ glmc_vec4_copy(vec4 v, vec4 dest) {
|
||||
glm_vec4_copy(v, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_vec4_ucopy(vec4 v, vec4 dest) {
|
||||
glm_vec4_ucopy(v, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_vec4_dot(vec4 a, vec4 b) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<ClCompile Include="..\src\box.c" />
|
||||
<ClCompile Include="..\src\cam.c" />
|
||||
<ClCompile Include="..\src\dllmain.c" />
|
||||
<ClCompile Include="..\src\ease.c" />
|
||||
<ClCompile Include="..\src\euler.c" />
|
||||
<ClCompile Include="..\src\frustum.c" />
|
||||
<ClCompile Include="..\src\io.c" />
|
||||
@@ -43,6 +44,7 @@
|
||||
<ClInclude Include="..\include\cglm\call\affine.h" />
|
||||
<ClInclude Include="..\include\cglm\call\box.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\frustum.h" />
|
||||
<ClInclude Include="..\include\cglm\call\io.h" />
|
||||
@@ -58,6 +60,7 @@
|
||||
<ClInclude Include="..\include\cglm\cglm.h" />
|
||||
<ClInclude Include="..\include\cglm\color.h" />
|
||||
<ClInclude Include="..\include\cglm\common.h" />
|
||||
<ClInclude Include="..\include\cglm\ease.h" />
|
||||
<ClInclude Include="..\include\cglm\euler.h" />
|
||||
<ClInclude Include="..\include\cglm\frustum.h" />
|
||||
<ClInclude Include="..\include\cglm\io.h" />
|
||||
|
||||
@@ -81,6 +81,9 @@
|
||||
<ClCompile Include="..\src\sphere.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\ease.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\config.h">
|
||||
@@ -224,5 +227,11 @@
|
||||
<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>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user