Compare commits

..

25 Commits

Author SHA1 Message Date
Recep Aslantas
7e5d1f435f Merge pull request #244 from geckor14/master
Remove unused variable
2022-03-18 12:39:29 +03:00
geckor14
851a58cedb Remove unused variable
The most recent version of Apple Clang (13.1.6) on macOS complains r3 is an unused variable. With -Werror enabled, this breaks the build.
2022-03-18 18:42:19 +11:00
Recep Aslantas
6fa1cefcc2 Merge pull request #243 from Sand3r-/patch-1
Fix a bug in glm_lookat_lh
2022-03-09 09:38:26 +03:00
Michał Gallus
7e211e1f49 Fix bug in view_lh.h #2
Reverse order of parameters in the second crossproduct
2022-03-08 01:42:43 +01:00
Michał Gallus
7d47b7f1fd Fix a bug in glm_lookat_lh
Fix the order of arguments passed to glm_vec3_crossn to avoid the negation of X axis.
2022-03-08 01:29:35 +01:00
Recep Aslantas
2a4748d452 fix glm_pickmatrix()'s param type 2022-01-31 02:56:39 +03:00
Recep Aslantas
f20bf0aaaf Merge pull request #236 from recp/ivec
add missing ivec types
2022-01-07 00:23:32 +03:00
Recep Aslantas
3a141b7cc8 extend unions for struct api 2022-01-06 18:12:46 +03:00
Recep Aslantas
5cd1a4ab44 add missing ivec types 2022-01-06 18:01:35 +03:00
Recep Aslantas
897f2afd88 Merge pull request #234 from madebr/sse3_header
Header containing sse3 intrinsics is pmmintrin.h
2021-12-31 17:51:30 +03:00
Anonymous Maarten
68e3a072e8 Header containing sse3 intrinsics is pmmintrin.h 2021-12-29 08:48:55 +01:00
Recep Aslantas
282ea84dc0 Merge pull request #231 from omar-polo/master
set PACKAGE_VERSION so it gets substituted in cglm.pc.in by cmake
2021-11-22 11:20:20 +03:00
Omar Polo
2d5506d15d set PACKAGE_VERSION so it gets substituted in cglm.pc.in by cmake
otherwise it ends up being an empty string and the installed pc has a
bogus line:

	Version:
2021-11-21 21:04:59 +01:00
Recep Aslantas
87f561fb06 Merge pull request #229 from mxi/vec2-ext-complex
Add complex routines to `vec2-ext`
2021-11-10 10:09:09 +03:00
Maxim Kasyanenko
522b18bda9 Add tests 2021-11-08 17:53:39 -08:00
Maxim Kasyanenko
b7178749ee Forgot to add the dynamic implementation file itself 2021-11-08 17:53:27 -08:00
Maxim Kasyanenko
98c708281f Syntax errors 2021-11-08 17:52:47 -08:00
Maxim Kasyanenko
896ba0a0f9 Add dynamic/struct versions of routines 2021-11-08 17:52:31 -08:00
Maxim Kasyanenko
4603816330 Forgot return type 2021-11-08 17:09:28 -08:00
Maxim Kasyanenko
9f5cc3a745 Implement a few complex routines 2021-11-08 16:28:55 -08:00
Recep Aslantas
bde653b607 Update CMakeLists.txt 2021-10-28 19:10:19 +03:00
Recep Aslantas
ede72ca412 Merge pull request #225 from podsvirov/fix-win32-shared
win: fix shared library name and destination
2021-10-17 18:09:18 +03:00
Konstantin Podsvirov
8e784e762f win: fix shared library name and destination 2021-10-10 12:02:44 +03:00
Recep Aslantas
82d1050c63 update GLM_FLT_EPSILON to use 1e-5 instead of 1e-6 2021-10-06 21:08:55 +03:00
Recep Aslantas
0631598d08 now working on v0.8.5 2021-08-18 05:03:59 +03:00
19 changed files with 267 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8.2)
project(cglm VERSION 0.8.4 LANGUAGES C)
project(cglm VERSION 0.8.5 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)
@@ -47,7 +47,10 @@ include(GNUInstallDirs)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
if(NOT CPack_CMake_INCLUDED)
include(CPack)
endif()
# Target Start
add_library(${PROJECT_NAME}
@@ -97,6 +100,12 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
if(WIN32)
# Because SOVERSION has no effect to file naming on Windows
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR})
endif()
target_include_directories(${PROJECT_NAME}
PUBLIC
$<INSTALL_INTERFACE:include>
@@ -122,7 +131,7 @@ install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN ".*" EXCLUDE)
@@ -143,6 +152,7 @@ set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(PACKAGE_VERSION "${PROJECT_VERSION}")
configure_file(${CMAKE_CURRENT_LIST_DIR}/cglm.pc.in ${CMAKE_BINARY_DIR}/cglm.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/cglm.pc

View File

@@ -7,7 +7,7 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.8.4], [info@recp.me])
AC_INIT([cglm], [0.8.5], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.

View File

@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.8.4'
version = u'0.8.5'
# The full version, including alpha/beta/rc tags.
release = u'0.8.4'
release = u'0.8.5'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -149,6 +149,18 @@ CGLM_EXPORT
void
glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_complex_mul(vec2 a, vec2 b, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_complex_div(vec2 a, vec2 b, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_complex_conjugate(vec2 a, vec2 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -37,8 +37,8 @@ glm_lookat_lh(vec3 eye, vec3 center, vec3 up, mat4 dest) {
glm_vec3_sub(center, eye, f);
glm_vec3_normalize(f);
glm_vec3_crossn(f, up, s);
glm_vec3_cross(s, f, u);
glm_vec3_crossn(up, f, s);
glm_vec3_cross(f, s, u);
dest[0][0] = s[0];
dest[0][1] = u[0];

View File

@@ -44,7 +44,7 @@
#ifndef CGLM_USE_DEFAULT_EPSILON
# ifndef GLM_FLT_EPSILON
# define GLM_FLT_EPSILON 1e-6
# define GLM_FLT_EPSILON 1e-5
# endif
#else
# define GLM_FLT_EPSILON FLT_EPSILON

View File

@@ -124,7 +124,7 @@ glm_project(vec3 pos, mat4 m, vec4 vp, vec3 dest) {
*/
CGLM_INLINE
void
glm_pickmatrix(vec3 center, vec2 size, vec4 vp, mat4 dest) {
glm_pickmatrix(vec2 center, vec2 size, vec4 vp, mat4 dest) {
mat4 res;
vec3 v;

View File

@@ -34,7 +34,7 @@
#endif
#if defined(__SSE3__)
# include <x86intrin.h>
# include <pmmintrin.h>
# ifndef CGLM_SIMD_x86
# define CGLM_SIMD_x86
# endif

View File

@@ -86,13 +86,12 @@ CGLM_INLINE
void
glm_inv_tr_neon(mat4 mat) {
float32x4x4_t vmat;
glmm_128 r0, r1, r2, r3, x0;
glmm_128 r0, r1, r2, x0;
vmat = vld4q_f32(mat[0]);
r0 = vmat.val[0];
r1 = vmat.val[1];
r2 = vmat.val[2];
r3 = vmat.val[3];
x0 = glmm_fmadd(r0, glmm_splat_w(r0),
glmm_fmadd(r1, glmm_splat_w(r1),

View File

@@ -111,7 +111,7 @@ glms_project(vec3s pos, mat4s m, vec4s vp) {
*/
CGLM_INLINE
mat4s
glms_pickmatrix(vec3s center, vec2s size, vec4s vp) {
glms_pickmatrix(vec2s center, vec2s size, vec4s vp) {
mat4s res;
glm_pickmatrix(center.raw, size.raw, vp.raw, res.raw);
return res;

View File

@@ -195,4 +195,45 @@ glms_vec2_sqrt(vec2s v) {
return r;
}
/*!
* @brief treat vectors as complex numbers and multiply them as such.
*
* @param[in] a left number
* @param[in] b right number
* @param[out] dest destination number
*/
CGLM_INLINE
vec2s
glms_vec2_complex_mul(vec2s a, vec2s b, vec2s dest) {
glm_vec2_complex_mul(a.raw, b.raw, dest.raw);
return dest;
}
/*!
* @brief treat vectors as complex numbers and divide them as such.
*
* @param[in] a left number (numerator)
* @param[in] b right number (denominator)
* @param[out] dest destination number
*/
CGLM_INLINE
vec2s
glms_vec2_complex_div(vec2s a, vec2s b, vec2s dest) {
glm_vec2_complex_div(a.raw, b.raw, dest.raw);
return dest;
}
/*!
* @brief treat the vector as a complex number and conjugate it as such.
*
* @param[in] a the number
* @param[out] dest destination number
*/
CGLM_INLINE
vec2s
glms_vec2_complex_conjugate(vec2s a, vec2s dest) {
glm_vec2_complex_conjugate(a.raw, dest.raw);
return dest;
}
#endif /* cglms_vec2s_ext_h */

View File

@@ -47,6 +47,21 @@ typedef union vec2s {
float x;
float y;
};
struct {
float r;
float i;
};
struct {
float u;
float v;
};
struct {
float s;
float t;
};
#endif
} vec2s;
@@ -58,9 +73,40 @@ typedef union vec3s {
float y;
float z;
};
struct {
float r;
float g;
float b;
};
#endif
} vec3s;
typedef union ivec2s {
ivec2 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
int x;
int y;
};
struct {
int r;
int i;
};
struct {
int u;
int v;
};
struct {
int s;
int t;
};
#endif
} ivec2s;
typedef union ivec3s {
ivec3 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
@@ -69,9 +115,34 @@ typedef union ivec3s {
int y;
int z;
};
struct {
int r;
int g;
int b;
};
#endif
} ivec3s;
typedef union ivec4s {
ivec4 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
struct {
int x;
int y;
int z;
int w;
};
struct {
int r;
int g;
int b;
int a;
};
#endif
} ivec4s;
typedef union CGLM_ALIGN_IF(16) vec4s {
vec4 raw;
#if CGLM_USE_ANONYMOUS_STRUCT
@@ -81,6 +152,13 @@ typedef union CGLM_ALIGN_IF(16) vec4s {
float z;
float w;
};
struct {
float r;
float g;
float b;
float a;
};
#endif
} vec4s;

View File

@@ -42,9 +42,12 @@
#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
typedef int ivec2[2];
typedef int ivec3[3];
typedef int ivec4[4];
typedef float vec2[2];
typedef float vec3[3];
typedef int ivec3[3];
typedef CGLM_ALIGN_IF(16) float vec4[4];
typedef vec4 versor; /* |x, y, z, w| -> w is the last */
typedef vec3 mat3[3];

View File

@@ -20,6 +20,9 @@
CGLM_INLINE bool glm_vec2_isvalid(vec2 v);
CGLM_INLINE void glm_vec2_sign(vec2 v, vec2 dest);
CGLM_INLINE void glm_vec2_sqrt(vec2 v, vec2 dest);
CGLM_INLINE void glm_vec2_complex_mul(vec2 a, vec2 b, vec2 dest)
CGLM_INLINE void glm_vec2_complex_div(vec2 a, vec2 b, vec2 dest)
CGLM_INLINE void glm_vec2_complex_conjugate(vec2 a, vec2 dest)
*/
#ifndef cglm_vec2_ext_h
@@ -186,4 +189,53 @@ glm_vec2_sqrt(vec2 v, vec2 dest) {
dest[1] = sqrtf(v[1]);
}
/*!
* @brief treat vectors as complex numbers and multiply them as such.
*
* @param[in] a left number
* @param[in] b right number
* @param[out] dest destination number
*/
CGLM_INLINE
void
glm_vec2_complex_mul(vec2 a, vec2 b, vec2 dest) {
float tr, ti;
tr = a[0] * b[0] - a[1] * b[1];
ti = a[0] * b[1] + a[1] * b[0];
dest[0] = tr;
dest[1] = ti;
}
/*!
* @brief treat vectors as complex numbers and divide them as such.
*
* @param[in] a left number (numerator)
* @param[in] b right number (denominator)
* @param[out] dest destination number
*/
CGLM_INLINE
void
glm_vec2_complex_div(vec2 a, vec2 b, vec2 dest) {
float tr, ti;
float const ibnorm2 = 1.0f / (b[0] * b[0] + b[1] * b[1]);
tr = ibnorm2 * (a[0] * b[0] + a[1] * b[1]);
ti = ibnorm2 * (a[1] * b[0] - a[0] * b[1]);
dest[0] = tr;
dest[1] = ti;
}
/*!
* @brief treat the vector as a complex number and conjugate it as such.
*
* @param[in] a the number
* @param[out] dest destination number
*/
CGLM_INLINE
void
glm_vec2_complex_conjugate(vec2 a, vec2 dest) {
dest[0] = a[0];
dest[1] = -a[1];
}
#endif /* cglm_vec2_ext_h */

View File

@@ -10,6 +10,6 @@
#define CGLM_VERSION_MAJOR 0
#define CGLM_VERSION_MINOR 8
#define CGLM_VERSION_PATCH 4
#define CGLM_VERSION_PATCH 5
#endif /* cglm_version_h */

View File

@@ -1,5 +1,5 @@
project('cglm', 'c',
version : '0.8.4',
version : '0.8.5',
license : 'mit',
default_options : [
'c_std=c11',

View File

@@ -211,3 +211,21 @@ void
glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) {
glm_vec2_lerp(from, to, t, dest);
}
CGLM_EXPORT
void
glmc_vec2_complex_mul(vec2 a, vec2 b, vec2 dest) {
glm_vec2_complex_mul(a, b, dest);
}
CGLM_EXPORT
void
glmc_vec2_complex_div(vec2 a, vec2 b, vec2 dest) {
glm_vec2_complex_div(a, b, dest);
}
CGLM_EXPORT
void
glmc_vec2_complex_conjugate(vec2 a, vec2 dest) {
glm_vec2_complex_conjugate(a, dest);
}

View File

@@ -594,3 +594,32 @@ TEST_IMPL(GLM_PREFIX, vec2_lerp) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, vec2_complex_mul) {
vec2 v1 = { 3.0f, 5.0f },
v2 = { 7.0f, 11.0f },
v3 = { cosf(M_PI/4.0f), sinf(M_PI/4.0f) };
GLM(vec2_complex_mul)(v1, v2, v2);
ASSERTIFY(test_assert_vec2_eq(v2, (vec2){ -34, 68 }))
GLM(vec2_complex_mul)(v3, v3, v3);
ASSERTIFY(test_assert_vec2_eq(v3, (vec2){ 0.0f, 1.0f }))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, vec2_complex_div) {
vec2 v1 = { -34.0f, 68.0f },
v2 = { 3.0f, 5.0f },
v3 = { cosf(M_PI/4.0f), sinf(M_PI/4.0f) },
v4 = { cosf(M_PI/4.0f), -sinf(M_PI/4.0f) };
GLM(vec2_complex_div)(v1, v2, v2);
ASSERTIFY(test_assert_vec2_eq(v2, (vec2){ 7.0f, 11.0f }))
GLM(vec2_complex_div)(v3, v4, v4);
ASSERTIFY(test_assert_vec2_eq(v4, (vec2){ 0.0f, 1.0f }))
TEST_SUCCESS
}

View File

@@ -382,6 +382,8 @@ TEST_DECLARE(glm_vec2_maxv)
TEST_DECLARE(glm_vec2_minv)
TEST_DECLARE(glm_vec2_clamp)
TEST_DECLARE(glm_vec2_lerp)
TEST_DECLARE(glm_vec2_complex_mul)
TEST_DECLARE(glm_vec2_complex_div)
TEST_DECLARE(glmc_vec2)
@@ -418,6 +420,8 @@ TEST_DECLARE(glmc_vec2_maxv)
TEST_DECLARE(glmc_vec2_minv)
TEST_DECLARE(glmc_vec2_clamp)
TEST_DECLARE(glmc_vec2_lerp)
TEST_DECLARE(glmc_vec2_complex_mul)
TEST_DECLARE(glmc_vec2_complex_div)
/* vec3 */
TEST_DECLARE(MACRO_GLM_VEC3_ONE_INIT)
@@ -1112,6 +1116,8 @@ TEST_LIST {
TEST_ENTRY(glm_vec2_minv)
TEST_ENTRY(glm_vec2_clamp)
TEST_ENTRY(glm_vec2_lerp)
TEST_ENTRY(glm_vec2_complex_mul)
TEST_ENTRY(glm_vec2_complex_div)
TEST_ENTRY(glmc_vec2)
TEST_ENTRY(glmc_vec2_copy)
@@ -1147,6 +1153,8 @@ TEST_LIST {
TEST_ENTRY(glmc_vec2_minv)
TEST_ENTRY(glmc_vec2_clamp)
TEST_ENTRY(glmc_vec2_lerp)
TEST_ENTRY(glmc_vec2_complex_mul)
TEST_ENTRY(glmc_vec2_complex_div)
/* vec3 */
/* Macros */