From ba2031d977a846786d8ef373d02c0f12e790d4dc Mon Sep 17 00:00:00 2001 From: acoto87 Date: Tue, 21 May 2019 16:45:34 -0500 Subject: [PATCH] - Rename `structs` folder to `struct` - Include files in `cglms.h` - Fix style issues (tabs to spaces, open brace without newline) --- include/cglm/cglms.h | 18 +- include/cglm/{structs => struct}/affine.h | 206 +++++++++--------- include/cglm/{structs => struct}/box.h | 86 ++++---- include/cglm/{structs => struct}/color.h | 2 +- include/cglm/{structs => struct}/curve.h | 2 +- include/cglm/{structs => struct}/frustum.h | 42 ++-- include/cglm/{structs => struct}/io.h | 10 +- include/cglm/{structs => struct}/mat3.h | 0 include/cglm/{structs => struct}/mat4.h | 6 +- include/cglm/{structs => struct}/plane.h | 4 +- include/cglm/{structs => struct}/project.h | 22 +- include/cglm/{structs => struct}/sphere.h | 0 include/cglm/{structs => struct}/vec3-ext.h | 32 +-- include/cglm/{structs => struct}/vec3.h | 225 ++++++++++---------- include/cglm/{structs => struct}/vec4-ext.h | 34 +-- include/cglm/{structs => struct}/vec4.h | 182 ++++++++-------- include/cglm/types-struct.h | 21 +- test/src/test_common.c | 12 +- 18 files changed, 447 insertions(+), 457 deletions(-) rename include/cglm/{structs => struct}/affine.h (53%) rename include/cglm/{structs => struct}/box.h (78%) rename include/cglm/{structs => struct}/color.h (93%) rename include/cglm/{structs => struct}/curve.h (96%) rename include/cglm/{structs => struct}/frustum.h (83%) rename include/cglm/{structs => struct}/io.h (90%) rename include/cglm/{structs => struct}/mat3.h (100%) rename include/cglm/{structs => struct}/mat4.h (99%) rename include/cglm/{structs => struct}/plane.h (93%) rename include/cglm/{structs => struct}/project.h (89%) rename include/cglm/{structs => struct}/sphere.h (100%) rename include/cglm/{structs => struct}/vec3-ext.h (81%) rename include/cglm/{structs => struct}/vec3.h (70%) rename include/cglm/{structs => struct}/vec4-ext.h (79%) rename include/cglm/{structs => struct}/vec4.h (70%) diff --git a/include/cglm/cglms.h b/include/cglm/cglms.h index 67dbfa4..0ecc8de 100644 --- a/include/cglm/cglms.h +++ b/include/cglm/cglms.h @@ -13,11 +13,19 @@ extern "C" { #include "cglm.h" #include "types-struct.h" -#include "structs/vec3.h" -#include "structs/vec4.h" -#include "structs/mat3.h" -#include "structs/mat4.h" -#include "structs/sphere.h" +#include "struct/vec3.h" +#include "struct/vec4.h" +#include "struct/mat3.h" +#include "struct/mat4.h" +#include "struct/affine.h" +#include "struct/frustum.h" +#include "struct/plane.h" +#include "struct/box.h" +#include "struct/color.h" +#include "struct/io.h" +#include "struct/project.h" +#include "struct/sphere.h" +#include "struct/curve.h" #ifdef __cplusplus } diff --git a/include/cglm/structs/affine.h b/include/cglm/struct/affine.h similarity index 53% rename from include/cglm/structs/affine.h rename to include/cglm/struct/affine.h index 481aaa3..0f753c5 100644 --- a/include/cglm/structs/affine.h +++ b/include/cglm/struct/affine.h @@ -8,25 +8,25 @@ /* Functions: CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v); - CGLM_INLINE mat4s glms_translate_x(mat4s m, float x); - CGLM_INLINE mat4s glms_translate_y(mat4s m, float y); - CGLM_INLINE mat4s glms_translate_z(mat4s m, float z); - CGLM_INLINE mat4s glms_translate_make(vec3s v); - CGLM_INLINE mat4s glms_scale_to(mat4s m, vec3s v); - CGLM_INLINE mat4s glms_scale_make(vec3s v); - CGLM_INLINE mat4s glms_scale(mat4s m, vec3s v); - CGLM_INLINE mat4s glms_scale_uni(mat4s m, float s); - CGLM_INLINE mat4s glmx_rotate_x(mat4s m, float angle); - CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle); - CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle); - CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis); - CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis); - CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis); - CGLM_INLINE mat4s glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis); - CGLM_INLINE vec3s glms_decompose_scalev(mat4s m); - CGLM_INLINE bool glms_uniscaled(mat4s m); - CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * r, vec3s * s); - CGLM_INLINE void glms_decompose(mat4s m, vec4s t, mat4s * r, vec3s * s); + CGLM_INLINE mat4s glms_translate_x(mat4s m, float x); + CGLM_INLINE mat4s glms_translate_y(mat4s m, float y); + CGLM_INLINE mat4s glms_translate_z(mat4s m, float z); + CGLM_INLINE mat4s glms_translate_make(vec3s v); + CGLM_INLINE mat4s glms_scale_to(mat4s m, vec3s v); + CGLM_INLINE mat4s glms_scale_make(vec3s v); + CGLM_INLINE mat4s glms_scale(mat4s m, vec3s v); + CGLM_INLINE mat4s glms_scale_uni(mat4s m, float s); + CGLM_INLINE mat4s glmx_rotate_x(mat4s m, float angle); + CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle); + CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle); + CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis); + CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis); + CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis); + CGLM_INLINE mat4s glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis); + CGLM_INLINE vec3s glms_decompose_scalev(mat4s m); + CGLM_INLINE bool glms_uniscaled(mat4s m); + CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * r, vec3s * s); + CGLM_INLINE void glms_decompose(mat4s m, vec4s t, mat4s * r, vec3s * s); */ #ifndef cglm_affines_h @@ -47,71 +47,71 @@ glms_mat4_mul(mat4s m1, mat4s m2); * @brief translate existing transform matrix by v vector * and stores result in same matrix * - * @param[in] m affine transfrom - * @param[in] v translate vector [x, y, z] - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] v translate vector [x, y, z] + * @returns affine transfrom */ CGLM_INLINE mat4s glms_translate(mat4s m, vec3s v) { - glm_translate(m.raw, v.raw); - return m; + glm_translate(m.raw, v.raw); + return m; } /*! * @brief translate existing transform matrix by x factor * - * @param[in] m affine transfrom - * @param[in] x x factor - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] x x factor + * @returns affine transfrom */ CGLM_INLINE mat4s glms_translate_x(mat4s m, float x) { - glm_translate_x(m.raw, x); - return m; + glm_translate_x(m.raw, x); + return m; } /*! * @brief translate existing transform matrix by y factor * - * @param[in] m affine transfrom - * @param[in] y y factor - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] y y factor + * @returns affine transfrom */ CGLM_INLINE mat4s glms_translate_y(mat4s m, float y) { - glm_translate_y(m.raw, y); - return m; + glm_translate_y(m.raw, y); + return m; } /*! * @brief translate existing transform matrix by z factor * - * @param[in] m affine transfrom - * @param[in] z z factor - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] z z factor + * @returns affine transfrom */ CGLM_INLINE mat4s glms_translate_z(mat4s m, float z) { - glm_translate_z(m.raw, z); - return m; + glm_translate_z(m.raw, z); + return m; } /*! * @brief creates NEW translate transform matrix by v vector * - * @param[in] v translate vector [x, y, z] - * @returns affine transfrom + * @param[in] v translate vector [x, y, z] + * @returns affine transfrom */ CGLM_INLINE mat4s glms_translate_make(vec3s v) { - mat4s m; - glm_translate_make(m.raw, v.raw); - return m; + mat4s m; + glm_translate_make(m.raw, v.raw); + return m; } /*! @@ -123,88 +123,88 @@ glms_translate_make(vec3s v) { CGLM_INLINE mat4s glms_scale_make(vec3s v) { - mat4s m; - glm_scale_make(m.raw, v.raw); - return m; + mat4s m; + glm_scale_make(m.raw, v.raw); + return m; } /*! * @brief scales existing transform matrix by v vector * and stores result in same matrix * - * @param[in] m affine transfrom - * @param[in] v scale vector [x, y, z] - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] v scale vector [x, y, z] + * @returns affine transfrom */ CGLM_INLINE mat4s glms_scale(mat4s m, vec3s v) { - mat4s r; + mat4s r; glm_scale_to(m.raw, v.raw, r.raw); - return r; + return r; } /*! * @brief applies uniform scale to existing transform matrix v = [s, s, s] * and stores result in same matrix * - * @param[in] m affine transfrom - * @param[in] s scale factor - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] s scale factor + * @returns affine transfrom */ CGLM_INLINE mat4s glms_scale_uni(mat4s m, float s) { - glm_scale_uni(m.raw, s); - return m; + glm_scale_uni(m.raw, s); + return m; } /*! * @brief rotate existing transform matrix around X axis by angle * and store result in dest * - * @param[in] m affine transfrom - * @param[in] angle angle (radians) - * @returns rotated matrix + * @param[in] m affine transfrom + * @param[in] angle angle (radians) + * @returns rotated matrix */ CGLM_INLINE mat4s glmx_rotate_x(mat4s m, float angle) { - mat4s r; - glm_rotate_x(m.raw, angle, r.raw); - return r; + mat4s r; + glm_rotate_x(m.raw, angle, r.raw); + return r; } /*! * @brief rotate existing transform matrix around Y axis by angle * and store result in dest * - * @param[in] m affine transfrom - * @param[in] angle angle (radians) - * @returns rotated matrix + * @param[in] m affine transfrom + * @param[in] angle angle (radians) + * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotate_y(mat4s m, float angle) { - mat4s r; - glm_rotate_y(m.raw, angle, r.raw); - return r; + mat4s r; + glm_rotate_y(m.raw, angle, r.raw); + return r; } /*! * @brief rotate existing transform matrix around Z axis by angle * and store result in dest * - * @param[in] m affine transfrom - * @param[in] angle angle (radians) - * @returns rotated matrix + * @param[in] m affine transfrom + * @param[in] angle angle (radians) + * @returns rotated matrix */ CGLM_INLINE mat4s glms_rotate_z(mat4s m, float angle) { - mat4s r; - glm_rotate_z(m.raw, angle, r.raw); - return r; + mat4s r; + glm_rotate_z(m.raw, angle, r.raw); + return r; } /*! @@ -212,48 +212,48 @@ glms_rotate_z(mat4s m, float angle) { * * axis will be normalized so you don't need to normalize it * - * @param[in] angle angle (radians) - * @param[in] axis axis - * @returns affine transfrom + * @param[in] angle angle (radians) + * @param[in] axis axis + * @returns affine transfrom */ CGLM_INLINE mat4s glms_rotate_make(float angle, vec3s axis) { - mat4s m; - glm_rotate_make(m.raw, angle, axis.raw); - return m; + mat4s m; + glm_rotate_make(m.raw, angle, axis.raw); + return m; } /*! * @brief rotate existing transform matrix around given axis by angle * - * @param[in] m affine transfrom - * @param[in] angle angle (radians) - * @param[in] axis axis - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] angle angle (radians) + * @param[in] axis axis + * @returns affine transfrom */ CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis) { - glm_rotate(m.raw, angle, axis.raw); - return m; + glm_rotate(m.raw, angle, axis.raw); + return m; } /*! * @brief rotate existing transform * around given axis by angle at given pivot point (rotation center) * - * @param[in] m affine transfrom - * @param[in] pivot rotation center - * @param[in] angle angle (radians) - * @param[in] axis axis - * @returns affine transfrom + * @param[in] m affine transfrom + * @param[in] pivot rotation center + * @param[in] angle angle (radians) + * @param[in] axis axis + * @returns affine transfrom */ CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis) { - glm_rotate_at(m.raw, pivot.raw, angle, axis.raw); - return m; + glm_rotate_at(m.raw, pivot.raw, angle, axis.raw); + return m; } /*! @@ -268,27 +268,27 @@ glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis) { * @param[in] pivot rotation center * @param[in] angle angle (radians) * @param[in] axis axis - * @returns affine transfrom + * @returns affine transfrom */ CGLM_INLINE mat4s glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis) { - glm_rotate_atm(m.raw, pivot.raw, angle, axis.raw); - return m; + glm_rotate_atm(m.raw, pivot.raw, angle, axis.raw); + return m; } /*! * @brief decompose scale vector * * @param[in] m affine transform - * @returns scale vector (Sx, Sy, Sz) + * @returns scale vector (Sx, Sy, Sz) */ CGLM_INLINE vec3s glms_decompose_scalev(mat4s m) { - vec3s r; - glm_decompose_scalev(m.raw, r.raw); - return r; + vec3s r; + glm_decompose_scalev(m.raw, r.raw); + return r; } /*! @@ -302,7 +302,7 @@ glms_decompose_scalev(mat4s m) { CGLM_INLINE bool glms_uniscaled(mat4s m) { - return glm_uniscaled(m.raw); + return glm_uniscaled(m.raw); } /*! @@ -316,7 +316,7 @@ glms_uniscaled(mat4s m) { CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * __restrict r, vec3s * __restrict s) { - glm_decompose_rs(m.raw, r->raw, s->raw); + glm_decompose_rs(m.raw, r->raw, s->raw); } /*! diff --git a/include/cglm/structs/box.h b/include/cglm/struct/box.h similarity index 78% rename from include/cglm/structs/box.h rename to include/cglm/struct/box.h index 4251bd7..9dc915e 100644 --- a/include/cglm/structs/box.h +++ b/include/cglm/struct/box.h @@ -25,12 +25,12 @@ CGLM_INLINE void glms_aabb_transform(vec3s box[2], mat4s m, vec3s dest[2]) { - vec3 rawBox[2]; - vec3 rawDest[2]; + vec3 rawBox[2]; + vec3 rawDest[2]; - glms_vec3_unpack(rawBox, box, 2); - glm_aabb_transform(rawBox, m.raw, rawDest); - glms_vec3_pack(dest, rawDest, 2); + glms_vec3_unpack(rawBox, box, 2); + glm_aabb_transform(rawBox, m.raw, rawDest); + glms_vec3_pack(dest, rawDest, 2); } /*! @@ -46,14 +46,14 @@ glms_aabb_transform(vec3s box[2], mat4s m, vec3s dest[2]) { CGLM_INLINE void glms_aabb_merge(vec3s box1[2], vec3s box2[2], vec3s dest[2]) { - vec3 rawBox1[2]; - vec3 rawBox2[2]; - vec3 rawDest[2]; + vec3 rawBox1[2]; + vec3 rawBox2[2]; + vec3 rawDest[2]; - glms_vec3_unpack(rawBox1, box1, 2); - glms_vec3_unpack(rawBox2, box2, 2); - glm_aabb_merge(rawBox1, rawBox2, rawDest); - glms_vec3_pack(dest, rawDest, 2); + glms_vec3_unpack(rawBox1, box1, 2); + glms_vec3_unpack(rawBox2, box2, 2); + glm_aabb_merge(rawBox1, rawBox2, rawDest); + glms_vec3_pack(dest, rawDest, 2); } /*! @@ -70,14 +70,14 @@ glms_aabb_merge(vec3s box1[2], vec3s box2[2], vec3s dest[2]) { CGLM_INLINE void glms_aabb_crop(vec3s box[2], vec3s cropBox[2], vec3s dest[2]) { - vec3 rawBox[2]; - vec3 rawCropBox[2]; - vec3 rawDest[2]; + vec3 rawBox[2]; + vec3 rawCropBox[2]; + vec3 rawDest[2]; - glms_vec3_unpack(rawBox, box, 2); - glms_vec3_unpack(rawCropBox, cropBox, 2); - glm_aabb_crop(rawBox, rawCropBox, rawDest); - glms_vec3_pack(dest, rawDest, 2); + glms_vec3_unpack(rawBox, box, 2); + glms_vec3_unpack(rawCropBox, cropBox, 2); + glm_aabb_crop(rawBox, rawCropBox, rawDest); + glms_vec3_pack(dest, rawDest, 2); } /*! @@ -119,12 +119,12 @@ glms_aabb_crop_until(vec3s box[2], CGLM_INLINE bool glms_aabb_frustum(vec3s box[2], vec4s planes[6]) { - vec3 rawBox[2]; - vec4 rawPlanes[6]; + vec3 rawBox[2]; + vec4 rawPlanes[6]; - glms_vec3_unpack(rawBox, box, 2); - glms_vec4_unpack(rawPlanes, planes, 6); - return glm_aabb_frustum(rawBox, rawPlanes); + glms_vec3_unpack(rawBox, box, 2); + glms_vec4_unpack(rawPlanes, planes, 6); + return glm_aabb_frustum(rawBox, rawPlanes); } /*! @@ -135,8 +135,6 @@ glms_aabb_frustum(vec3s box[2], vec4s planes[6]) { CGLM_INLINE void glms_aabb_invalidate(vec3s box[2]) { - // FIX: Modify param - // box[0] = glms_vec3_broadcast(FLT_MAX); box[1] = glms_vec3_broadcast(-FLT_MAX); } @@ -149,9 +147,9 @@ glms_aabb_invalidate(vec3s box[2]) { CGLM_INLINE bool glms_aabb_isvalid(vec3s box[2]) { - vec3 rawBox[2]; - glms_vec3_unpack(rawBox, box, 2); - return glm_aabb_isvalid(rawBox); + vec3 rawBox[2]; + glms_vec3_unpack(rawBox, box, 2); + return glm_aabb_isvalid(rawBox); } /*! @@ -197,11 +195,11 @@ glms_aabb_center(vec3s box[2]) { CGLM_INLINE bool glms_aabb_aabb(vec3s box[2], vec3s other[2]) { - vec3 rawBox[2]; - vec3 rawOther[2]; + vec3 rawBox[2]; + vec3 rawOther[2]; - glms_vec3_unpack(rawBox, box, 2); - glms_vec3_unpack(rawOther, other, 2); + glms_vec3_unpack(rawBox, box, 2); + glms_vec3_unpack(rawOther, other, 2); return glm_aabb_aabb(rawBox, rawOther); } @@ -217,10 +215,10 @@ glms_aabb_aabb(vec3s box[2], vec3s other[2]) { CGLM_INLINE bool glms_aabb_sphere(vec3s box[2], vec4s s) { - vec3 rawBox[2]; - - glms_vec3_unpack(rawBox, box, 2); - return glm_aabb_sphere(rawBox, s.raw); + vec3 rawBox[2]; + + glms_vec3_unpack(rawBox, box, 2); + return glm_aabb_sphere(rawBox, s.raw); } /*! @@ -232,9 +230,9 @@ glms_aabb_sphere(vec3s box[2], vec4s s) { CGLM_INLINE bool glms_aabb_point(vec3s box[2], vec3s point) { - vec3 rawBox[2]; + vec3 rawBox[2]; - glms_vec3_unpack(rawBox, box, 2); + glms_vec3_unpack(rawBox, box, 2); return glm_aabb_point(rawBox, point.raw); } @@ -247,12 +245,12 @@ glms_aabb_point(vec3s box[2], vec3s point) { CGLM_INLINE bool glms_aabb_contains(vec3s box[2], vec3s other[2]) { - vec3 rawBox[2]; - vec3 rawOther[2]; + vec3 rawBox[2]; + vec3 rawOther[2]; - glms_vec3_unpack(rawBox, box, 2); - glms_vec3_unpack(rawOther, other, 2); - return glm_aabb_contains(rawBox, rawOther); + glms_vec3_unpack(rawBox, box, 2); + glms_vec3_unpack(rawOther, other, 2); + return glm_aabb_contains(rawBox, rawOther); } #endif /* cglm_boxs_h */ diff --git a/include/cglm/structs/color.h b/include/cglm/struct/color.h similarity index 93% rename from include/cglm/structs/color.h rename to include/cglm/struct/color.h index 62cf5a8..e9ddc0c 100644 --- a/include/cglm/structs/color.h +++ b/include/cglm/struct/color.h @@ -21,7 +21,7 @@ CGLM_INLINE float glms_luminance(vec3s rgb) { - return glm_luminance(rgb.raw); + return glm_luminance(rgb.raw); } #endif /* cglm_colors_h */ diff --git a/include/cglm/structs/curve.h b/include/cglm/struct/curve.h similarity index 96% rename from include/cglm/structs/curve.h rename to include/cglm/struct/curve.h index 724b0be..0972f0f 100644 --- a/include/cglm/structs/curve.h +++ b/include/cglm/struct/curve.h @@ -34,7 +34,7 @@ CGLM_INLINE float glms_smc(float s, mat4s m, vec4s c) { - return glm_smc(s, m.raw, c.raw); + return glm_smc(s, m.raw, c.raw); } #endif /* cglm_curves_h */ diff --git a/include/cglm/structs/frustum.h b/include/cglm/struct/frustum.h similarity index 83% rename from include/cglm/structs/frustum.h rename to include/cglm/struct/frustum.h index 56bd165..98931f4 100644 --- a/include/cglm/structs/frustum.h +++ b/include/cglm/struct/frustum.h @@ -55,9 +55,9 @@ CGLM_INLINE void glms_frustum_planes(mat4s m, vec4s dest[6]) { - vec4 rawDest[6]; - glm_frustum_planes(m.raw, rawDest); - glms_vec4_pack(dest, rawDest, 6); + vec4 rawDest[6]; + glm_frustum_planes(m.raw, rawDest); + glms_vec4_pack(dest, rawDest, 6); } /*! @@ -86,9 +86,9 @@ glms_frustum_planes(mat4s m, vec4s dest[6]) { CGLM_INLINE void glms_frustum_corners(mat4s invMat, vec4s dest[8]) { - vec4 rawDest[8]; - glm_frustum_corners(invMat.raw, rawDest); - glms_vec4_pack(dest, rawDest, 8); + vec4 rawDest[8]; + glm_frustum_corners(invMat.raw, rawDest); + glms_vec4_pack(dest, rawDest, 8); } /*! @@ -100,12 +100,12 @@ glms_frustum_corners(mat4s invMat, vec4s dest[8]) { CGLM_INLINE vec4s glms_frustum_center(vec4s corners[8]) { - vec4 rawCorners[8]; - vec4s r; + vec4 rawCorners[8]; + vec4s r; - glms_vec4_unpack(rawCorners, corners, 8); - glm_frustum_center(rawCorners, r.raw); - return r; + glms_vec4_unpack(rawCorners, corners, 8); + glm_frustum_center(rawCorners, r.raw); + return r; } /*! @@ -118,12 +118,12 @@ glms_frustum_center(vec4s corners[8]) { CGLM_INLINE void glms_frustum_box(vec4s corners[8], mat4s m, vec3s box[2]) { - vec4 rawCorners[8]; - vec3 rawBox[2]; + vec4 rawCorners[8]; + vec3 rawBox[2]; - glms_vec4_unpack(rawCorners, corners, 8); - glm_frustum_box(rawCorners, m.raw, rawBox); - glms_vec3_pack(box, rawBox, 2); + glms_vec4_unpack(rawCorners, corners, 8); + glm_frustum_box(rawCorners, m.raw, rawBox); + glms_vec3_pack(box, rawBox, 2); } /*! @@ -144,12 +144,12 @@ glms_frustum_corners_at(vec4s corners[8], float splitDist, float farDist, vec4s planeCorners[4]) { - vec4 rawCorners[8]; - vec4 rawPlaneCorners[4]; + vec4 rawCorners[8]; + vec4 rawPlaneCorners[4]; - glms_vec4_unpack(rawCorners, corners, 8); - glm_frustum_corners_at(rawCorners, splitDist, farDist, rawPlaneCorners); - glms_vec4_pack(planeCorners, rawPlaneCorners, 8); + glms_vec4_unpack(rawCorners, corners, 8); + glm_frustum_corners_at(rawCorners, splitDist, farDist, rawPlaneCorners); + glms_vec4_pack(planeCorners, rawPlaneCorners, 8); } #endif /* cglm_frustums_h */ diff --git a/include/cglm/structs/io.h b/include/cglm/struct/io.h similarity index 90% rename from include/cglm/structs/io.h rename to include/cglm/struct/io.h index 2467d20..0a084e4 100644 --- a/include/cglm/structs/io.h +++ b/include/cglm/struct/io.h @@ -30,14 +30,14 @@ void glms_mat4_print(mat4s matrix, FILE * __restrict ostream) { - glm_mat4_print(matrix.raw, ostream); + glm_mat4_print(matrix.raw, ostream); } CGLM_INLINE void glms_mat3_print(mat3s matrix, FILE * __restrict ostream) { - glm_mat3_print(matrix.raw, ostream); + glm_mat3_print(matrix.raw, ostream); } CGLM_INLINE @@ -73,10 +73,10 @@ void glms_aabb_print(vec3s bbox[2], const char * __restrict tag, FILE * __restrict ostream) { - vec3 rawBbox[2]; + vec3 rawBbox[2]; - glms_vec3_unpack(rawBbox, bbox, 2); - glm_aabb_print(rawBbox, tag, ostream); + glms_vec3_unpack(rawBbox, bbox, 2); + glm_aabb_print(rawBbox, tag, ostream); } #endif /* cglm_ios_h */ diff --git a/include/cglm/structs/mat3.h b/include/cglm/struct/mat3.h similarity index 100% rename from include/cglm/structs/mat3.h rename to include/cglm/struct/mat3.h diff --git a/include/cglm/structs/mat4.h b/include/cglm/struct/mat4.h similarity index 99% rename from include/cglm/structs/mat4.h rename to include/cglm/struct/mat4.h index 40c7291..5947dc0 100644 --- a/include/cglm/structs/mat4.h +++ b/include/cglm/struct/mat4.h @@ -241,11 +241,11 @@ CGLM_INLINE mat4s glms_mat4_mulN(mat4s * __restrict matrices[], uint32_t len) { CGLM_ALIGN_MAT mat4s r = GLMS_MAT4_IDENTITY_INIT; - size_t i; + size_t i; for (i = 0; i < len; i++) { - r = glms_mat4_mul(r, *matrices[i]); - } + r = glms_mat4_mul(r, *matrices[i]); + } return r; } diff --git a/include/cglm/structs/plane.h b/include/cglm/struct/plane.h similarity index 93% rename from include/cglm/structs/plane.h rename to include/cglm/struct/plane.h index 6e23482..cea7e8c 100644 --- a/include/cglm/structs/plane.h +++ b/include/cglm/struct/plane.h @@ -33,8 +33,8 @@ CGLM_INLINE vec4s glms_plane_normalize(vec4s plane) { - glm_plane_normalize(plane.raw); - return plane; + glm_plane_normalize(plane.raw); + return plane; } #endif /* cglm_planes_h */ diff --git a/include/cglm/structs/project.h b/include/cglm/struct/project.h similarity index 89% rename from include/cglm/structs/project.h rename to include/cglm/struct/project.h index 1cbb137..d45ba3d 100644 --- a/include/cglm/structs/project.h +++ b/include/cglm/struct/project.h @@ -39,14 +39,14 @@ * @param[in] pos point/position in viewport coordinates * @param[in] invMat matrix (see brief) * @param[in] vp viewport as [x, y, width, height] - * @returns unprojected coordinates + * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unprojecti(vec3s pos, mat4s invMat, vec4s vp) { - vec3s r; - glm_unprojecti(pos.raw, invMat.raw, vp.raw, r.raw); - return r; + vec3s r; + glm_unprojecti(pos.raw, invMat.raw, vp.raw, r.raw); + return r; } /*! @@ -71,14 +71,14 @@ glms_unprojecti(vec3s pos, mat4s invMat, vec4s vp) { * @param[in] pos point/position in viewport coordinates * @param[in] m matrix (see brief) * @param[in] vp viewport as [x, y, width, height] - * @returns unprojected coordinates + * @returns unprojected coordinates */ CGLM_INLINE vec3s glms_unproject(vec3s pos, mat4s m, vec4s vp) { - vec3s r; - glm_unproject(pos.raw, m.raw, vp.raw, r.raw); - return r; + vec3s r; + glm_unproject(pos.raw, m.raw, vp.raw, r.raw); + return r; } /*! @@ -96,9 +96,9 @@ glms_unproject(vec3s pos, mat4s m, vec4s vp) { CGLM_INLINE vec3s glms_project(vec3s pos, mat4s m, vec4s vp) { - vec3s r; - glm_project(pos.raw, m.raw, vp.raw, r.raw); - return r; + vec3s r; + glm_project(pos.raw, m.raw, vp.raw, r.raw); + return r; } #endif /* cglm_projects_h */ diff --git a/include/cglm/structs/sphere.h b/include/cglm/struct/sphere.h similarity index 100% rename from include/cglm/structs/sphere.h rename to include/cglm/struct/sphere.h diff --git a/include/cglm/structs/vec3-ext.h b/include/cglm/struct/vec3-ext.h similarity index 81% rename from include/cglm/structs/vec3-ext.h rename to include/cglm/struct/vec3-ext.h index 2e5e729..53a1199 100644 --- a/include/cglm/structs/vec3-ext.h +++ b/include/cglm/struct/vec3-ext.h @@ -12,17 +12,17 @@ /* Functions: CGLM_INLINE vec3s glms_vec3_broadcast(float val); - CGLM_INLINE bool glms_vec3_eq(vec3s v, float val); - CGLM_INLINE bool glms_vec3_eq_eps(vec3s v, float val); - CGLM_INLINE bool glms_vec3_eq_all(vec3s v); - CGLM_INLINE bool glms_vec3_eqv(vec3s a, vec3s b); - CGLM_INLINE bool glms_vec3_eqv_eps(vec3s a, vec3s b); - CGLM_INLINE float glms_vec3_max(vec3s v); - CGLM_INLINE float glms_vec3_min(vec3s v); - CGLM_INLINE bool glms_vec3_isnan(vec3s v); - CGLM_INLINE bool glms_vec3_isinf(vec3s v); - CGLM_INLINE bool glms_vec3_isvalid(vec3s v); - CGLM_INLINE vec3s glms_vec3_sign(vec3s v); + CGLM_INLINE bool glms_vec3_eq(vec3s v, float val); + CGLM_INLINE bool glms_vec3_eq_eps(vec3s v, float val); + CGLM_INLINE bool glms_vec3_eq_all(vec3s v); + CGLM_INLINE bool glms_vec3_eqv(vec3s a, vec3s b); + CGLM_INLINE bool glms_vec3_eqv_eps(vec3s a, vec3s b); + CGLM_INLINE float glms_vec3_max(vec3s v); + CGLM_INLINE float glms_vec3_min(vec3s v); + CGLM_INLINE bool glms_vec3_isnan(vec3s v); + CGLM_INLINE bool glms_vec3_isinf(vec3s v); + CGLM_INLINE bool glms_vec3_isvalid(vec3s v); + CGLM_INLINE vec3s glms_vec3_sign(vec3s v); CGLM_INLINE vec3s glms_vec3_sqrt(vec3s v); */ @@ -37,8 +37,8 @@ /*! * @brief fill a vector with specified value * - * @param[in] val value - * @returns dest + * @param[in] val value + * @returns dest */ CGLM_INLINE vec3s @@ -170,8 +170,8 @@ glms_vec3_isvalid(vec3s v) { * * Important: It returns 0 for zero/NaN input * - * @param v vector - * @returns sign vector + * @param v vector + * @returns sign vector */ CGLM_INLINE vec3s @@ -185,7 +185,7 @@ glms_vec3_sign(vec3s v) { * @brief square root of each vector item * * @param[in] v vector - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s diff --git a/include/cglm/structs/vec3.h b/include/cglm/struct/vec3.h similarity index 70% rename from include/cglm/structs/vec3.h rename to include/cglm/struct/vec3.h index 766742b..06ad75f 100644 --- a/include/cglm/structs/vec3.h +++ b/include/cglm/struct/vec3.h @@ -17,53 +17,53 @@ Functions: CGLM_INLINE vec3s glms_vec3(vec4s v4); - CGLM_INLINE vec3s glms_vec3_copy(vec3s v); - CGLM_INLINE void glms_vec3_pack(vec3s dst[], vec3 src[], size_t len); - CGLM_INLINE void glms_vec3_unpack(vec3 dst[], vec3s src[], size_t len); - CGLM_INLINE vec3s glms_vec3_zero(); - CGLM_INLINE vec3s glms_vec3_one(); - CGLM_INLINE float glms_vec3_dot(vec3s a, vec3s b); - CGLM_INLINE float glms_vec3_norm2(vec3s v); - CGLM_INLINE float glms_vec3_norm(vec3s v); - CGLM_INLINE vec3s glms_vec3_add(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_adds(vec3s a, float s); - CGLM_INLINE vec3s glms_vec3_sub(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_subs(vec3s a, float s); - CGLM_INLINE vec3s glms_vec3_mul(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_scale(vec3s v, float s); - CGLM_INLINE vec3s glms_vec3_scale_as(vec3s v, float s); - CGLM_INLINE vec3s glms_vec3_div(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_divs(vec3s a, float s); - CGLM_INLINE vec3s glms_vec3_addadd(vec3s a, vec3s b, vec3s dest); - CGLM_INLINE vec3s glms_vec3_subadd(vec3s a, vec3s b, vec3s dest); - CGLM_INLINE vec3s glms_vec3_muladd(vec3s a, vec3s b, vec3s dest); - CGLM_INLINE vec3s glms_vec3_muladds(vec3s a, float s, vec3s dest); - CGLM_INLINE vec3s glms_vec3_maxadd(vec3s a, vec3s b, vec3s dest); - CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest); - CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v); - CGLM_INLINE vec3s glms_vec3_negate(vec3s v); - CGLM_INLINE vec3s glms_vec3_inv(vec3s v); - CGLM_INLINE vec3s glms_vec3_normalize(vec3s v); - CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b); - CGLM_INLINE float glms_vec3_distance(vec3s a, vec3s b); - CGLM_INLINE float glms_vec3_angle(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_rotate(vec3s v, float angle, vec3s axis); - CGLM_INLINE vec3s glms_vec3_rotate_m4(mat4s m, vec3s v); - CGLM_INLINE vec3s glms_vec3_rotate_m3(mat3s m, vec3s v); - CGLM_INLINE vec3s glms_vec3_proj(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_center(vec3s a, vec3s b); - CGLM_INLINE float glms_vec3_distance2(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_maxv(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_minv(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_vec3_ortho(vec3s v); - CGLM_INLINE vec3s glms_vec3_clamp(vec3s v, float minVal, float maxVal); - CGLM_INLINE vec3s glms_vec3_lerp(vec3s from, vec3s to, float t); + CGLM_INLINE vec3s glms_vec3_copy(vec3s v); + CGLM_INLINE void glms_vec3_pack(vec3s dst[], vec3 src[], size_t len); + CGLM_INLINE void glms_vec3_unpack(vec3 dst[], vec3s src[], size_t len); + CGLM_INLINE vec3s glms_vec3_zero(); + CGLM_INLINE vec3s glms_vec3_one(); + CGLM_INLINE float glms_vec3_dot(vec3s a, vec3s b); + CGLM_INLINE float glms_vec3_norm2(vec3s v); + CGLM_INLINE float glms_vec3_norm(vec3s v); + CGLM_INLINE vec3s glms_vec3_add(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_adds(vec3s a, float s); + CGLM_INLINE vec3s glms_vec3_sub(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_subs(vec3s a, float s); + CGLM_INLINE vec3s glms_vec3_mul(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_scale(vec3s v, float s); + CGLM_INLINE vec3s glms_vec3_scale_as(vec3s v, float s); + CGLM_INLINE vec3s glms_vec3_div(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_divs(vec3s a, float s); + CGLM_INLINE vec3s glms_vec3_addadd(vec3s a, vec3s b, vec3s dest); + CGLM_INLINE vec3s glms_vec3_subadd(vec3s a, vec3s b, vec3s dest); + CGLM_INLINE vec3s glms_vec3_muladd(vec3s a, vec3s b, vec3s dest); + CGLM_INLINE vec3s glms_vec3_muladds(vec3s a, float s, vec3s dest); + CGLM_INLINE vec3s glms_vec3_maxadd(vec3s a, vec3s b, vec3s dest); + CGLM_INLINE vec3s glms_vec3_minadd(vec3s a, vec3s b, vec3s dest); + CGLM_INLINE vec3s glms_vec3_flipsign(vec3s v); + CGLM_INLINE vec3s glms_vec3_negate(vec3s v); + CGLM_INLINE vec3s glms_vec3_inv(vec3s v); + CGLM_INLINE vec3s glms_vec3_normalize(vec3s v); + CGLM_INLINE vec3s glms_vec3_cross(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_crossn(vec3s a, vec3s b); + CGLM_INLINE float glms_vec3_distance(vec3s a, vec3s b); + CGLM_INLINE float glms_vec3_angle(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_rotate(vec3s v, float angle, vec3s axis); + CGLM_INLINE vec3s glms_vec3_rotate_m4(mat4s m, vec3s v); + CGLM_INLINE vec3s glms_vec3_rotate_m3(mat3s m, vec3s v); + CGLM_INLINE vec3s glms_vec3_proj(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_center(vec3s a, vec3s b); + CGLM_INLINE float glms_vec3_distance2(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_maxv(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_minv(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_vec3_ortho(vec3s v); + CGLM_INLINE vec3s glms_vec3_clamp(vec3s v, float minVal, float maxVal); + CGLM_INLINE vec3s glms_vec3_lerp(vec3s from, vec3s to, float t); Convenient: CGLM_INLINE vec3s glms_cross(vec3s a, vec3s b); - CGLM_INLINE float glms_dot(vec3s a, vec3s b); - CGLM_INLINE vec3s glms_normalize(vec3s v); + CGLM_INLINE float glms_dot(vec3s a, vec3s b); + CGLM_INLINE vec3s glms_normalize(vec3s v); */ #ifndef cglm_vec3s_h @@ -89,7 +89,7 @@ * @brief init vec3 using vec4 * * @param[in] v4 vector4 - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -103,7 +103,7 @@ glms_vec3(vec4s v4) { * @brief copy all members of [a] to [dest] * * @param[in] a source - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -123,13 +123,13 @@ glms_vec3_copy(vec3s v) { CGLM_INLINE void glms_vec3_pack(vec3s dst[], vec3 src[], size_t len) { - size_t i; - - for (i = 0; i < len; i++) { - dst[i].x = src[i][0]; - dst[i].y = src[i][1]; - dst[i].z = src[i][2]; - } + size_t i; + + for (i = 0; i < len; i++) { + dst[i].x = src[i][0]; + dst[i].y = src[i][1]; + dst[i].z = src[i][2]; + } } /*! @@ -142,20 +142,20 @@ glms_vec3_pack(vec3s dst[], vec3 src[], size_t len) { CGLM_INLINE void glms_vec3_unpack(vec3 dst[], vec3s src[], size_t len) { - size_t i; + size_t i; - for (i = 0; i < len; i++) { - dst[i][0] = src[i].x; - dst[i][1] = src[i].y; - dst[i][2] = src[i].z; - } + for (i = 0; i < len; i++) { + dst[i][0] = src[i].x; + dst[i][1] = src[i].y; + dst[i][2] = src[i].z; + } } /*! * @brief make vector zero * - * @param[in] v vector - * @returns zero vector + * @param[in] v vector + * @returns zero vector */ CGLM_INLINE vec3s @@ -168,8 +168,8 @@ glms_vec3_zero() { /*! * @brief make vector one * - * @param[in] v vector - * @returns one vector + * @param[in] v vector + * @returns one vector */ CGLM_INLINE vec3s @@ -228,7 +228,7 @@ glms_vec3_norm(vec3s v) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -243,7 +243,7 @@ glms_vec3_add(vec3s a, vec3s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -258,7 +258,7 @@ glms_vec3_adds(vec3s a, float s) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -273,7 +273,7 @@ glms_vec3_sub(vec3s a, vec3s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -286,9 +286,9 @@ glms_vec3_subs(vec3s a, float s) { /*! * @brief multiply two vector (component-wise multiplication) * - * @param a vector1 - * @param b vector2 - * @returns v3 = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) + * @param a vector1 + * @param b vector2 + * @returns v3 = (a[0] * b[0], a[1] * b[1], a[2] * b[2]) */ CGLM_INLINE vec3s @@ -303,7 +303,7 @@ glms_vec3_mul(vec3s a, vec3s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -318,7 +318,7 @@ glms_vec3_scale(vec3s v, float s) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec3s @@ -333,7 +333,7 @@ glms_vec3_scale_as(vec3s v, float s) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) + * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2]) */ CGLM_INLINE vec3s @@ -348,7 +348,7 @@ glms_vec3_div(vec3s a, vec3s b) { * * @param[in] v vector * @param[in] s scalar - * @returns result = (a[0]/s, a[1]/s, a[2]/s) + * @returns result = (a[0]/s, a[1]/s, a[2]/s) */ CGLM_INLINE vec3s @@ -365,7 +365,7 @@ glms_vec3_divs(vec3s a, float s) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a + b) + * @returns dest += (a + b) */ CGLM_INLINE vec3s @@ -381,7 +381,7 @@ glms_vec3_addadd(vec3s a, vec3s b, vec3s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a + b) + * @returns dest += (a + b) */ CGLM_INLINE vec3s @@ -397,7 +397,7 @@ glms_vec3_subadd(vec3s a, vec3s b, vec3s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a * b) + * @returns dest += (a * b) */ CGLM_INLINE vec3s @@ -413,7 +413,7 @@ glms_vec3_muladd(vec3s a, vec3s b, vec3s dest) { * * @param[in] a vector * @param[in] s scalar - * @returns dest += (a * b) + * @returns dest += (a * b) */ CGLM_INLINE vec3s @@ -429,7 +429,7 @@ glms_vec3_muladds(vec3s a, float s, vec3s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += max(a, b) + * @returns dest += max(a, b) */ CGLM_INLINE vec3s @@ -445,7 +445,7 @@ glms_vec3_maxadd(vec3s a, vec3s b, vec3s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += min(a, b) + * @returns dest += min(a, b) */ CGLM_INLINE vec3s @@ -458,7 +458,7 @@ glms_vec3_minadd(vec3s a, vec3s b, vec3s dest) { * @brief negate vector components and store result in dest * * @param[in] v vector - * @returns result vector + * @returns result vector */ CGLM_INLINE vec3s @@ -471,7 +471,7 @@ glms_vec3_flipsign(vec3s v) { * @brief negate vector components * * @param[in] v vector - * @returns negated vector + * @returns negated vector */ CGLM_INLINE vec3s @@ -484,7 +484,7 @@ glms_vec3_negate(vec3s v) { * @brief normalize vec3 and store result in same vec * * @param[in] v vector - * @returns normalized vector + * @returns normalized vector */ CGLM_INLINE vec3s @@ -498,7 +498,7 @@ glms_vec3_normalize(vec3s v) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -513,7 +513,7 @@ glms_vec3_cross(vec3s a, vec3s b) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -540,10 +540,10 @@ glms_vec3_angle(vec3s a, vec3s b) { /*! * @brief rotate vec3 around axis by angle using Rodrigues' rotation formula * - * @param[in] v vector - * @param[in] axis axis vector (must be unit vector) - * @param[in] angle angle by radians - * @returns rotated vector + * @param[in] v vector + * @param[in] axis axis vector (must be unit vector) + * @param[in] angle angle by radians + * @returns rotated vector */ CGLM_INLINE vec3s @@ -563,7 +563,7 @@ glms_vec3_rotate(vec3s v, float angle, vec3s axis) { * * @param[in] m affine matrix or rot matrix * @param[in] v vector - * @returns rotated vector + * @returns rotated vector */ CGLM_INLINE vec3s @@ -578,7 +578,7 @@ glms_vec3_rotate_m4(mat4s m, vec3s v) { * * @param[in] m affine matrix or rot matrix * @param[in] v vector - * @returns rotated vector + * @returns rotated vector */ CGLM_INLINE vec3s @@ -593,7 +593,7 @@ glms_vec3_rotate_m3(mat3s m, vec3s v) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns projected vector + * @returns projected vector */ CGLM_INLINE vec3s @@ -608,7 +608,7 @@ glms_vec3_proj(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns center point + * @returns center point */ CGLM_INLINE vec3s @@ -623,7 +623,7 @@ glms_vec3_center(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @return squared distance (distance * distance) + * @return squared distance (distance * distance) */ CGLM_INLINE float @@ -636,7 +636,7 @@ glms_vec3_distance2(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @return distance + * @return distance */ CGLM_INLINE float @@ -649,7 +649,7 @@ glms_vec3_distance(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -664,7 +664,7 @@ glms_vec3_maxv(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -678,7 +678,7 @@ glms_vec3_minv(vec3s a, vec3s b) { * @brief possible orthogonal/perpendicular vector * * @param[in] v vector - * @returns orthogonal/perpendicular vector + * @returns orthogonal/perpendicular vector */ CGLM_INLINE vec3s @@ -691,10 +691,10 @@ glms_vec3_ortho(vec3s v) { /*! * @brief clamp vector's individual members between min and max values * - * @param[in] v vector - * @param[in] minVal minimum value - * @param[in] maxVal maximum value - * @returns clamped vector + * @param[in] v vector + * @param[in] minVal minimum value + * @param[in] maxVal maximum value + * @returns clamped vector */ CGLM_INLINE vec3s @@ -708,10 +708,10 @@ glms_vec3_clamp(vec3s v, float minVal, float maxVal) { * * formula: from + s * (to - from) * - * @param[in] from from value - * @param[in] to to value - * @param[in] t interpolant (amount) clamped between 0 and 1 - * @returns destination + * @param[in] from from value + * @param[in] to to value + * @param[in] t interpolant (amount) clamped between 0 and 1 + * @returns destination */ CGLM_INLINE vec3s @@ -726,9 +726,9 @@ glms_vec3_lerp(vec3s from, vec3s to, float t) { * * this is just convenient wrapper * - * @param[in] a source 1 - * @param[in] b source 2 - * @returns destination + * @param[in] a source 1 + * @param[in] b source 2 + * @returns destination */ CGLM_INLINE vec3s @@ -745,8 +745,7 @@ glms_cross(vec3s a, vec3s b) { * * @param[in] a vector1 * @param[in] b vector2 - * - * @return dot product + * @return dot product */ CGLM_INLINE float @@ -759,8 +758,8 @@ glms_dot(vec3s a, vec3s b) { * * this is just convenient wrapper * - * @param[in] v vector - * @returns normalized vector + * @param[in] v vector + * @returns normalized vector */ CGLM_INLINE vec3s diff --git a/include/cglm/structs/vec4-ext.h b/include/cglm/struct/vec4-ext.h similarity index 79% rename from include/cglm/structs/vec4-ext.h rename to include/cglm/struct/vec4-ext.h index 0b81b49..fdc5059 100644 --- a/include/cglm/structs/vec4-ext.h +++ b/include/cglm/struct/vec4-ext.h @@ -11,19 +11,19 @@ /* Functions: - CGLM_INLINE vec4s glms_vec4_broadcast(float val); - CGLM_INLINE bool glms_vec4_eq(vec4s v, float val); - CGLM_INLINE bool glms_vec4_eq_eps(vec4s v, float val); - CGLM_INLINE bool glms_vec4_eq_all(vec4s v); - CGLM_INLINE bool glms_vec4_eqv(vec4s a, vec4s b); - CGLM_INLINE bool glms_vec4_eqv_eps(vec4s a, vec4s b); - CGLM_INLINE float glms_vec4_max(vec4s v); - CGLM_INLINE float glms_vec4_min(vec4s v); - CGLM_INLINE bool glms_vec4_isnan(vec4s v); - CGLM_INLINE bool glms_vec4_isinf(vec4s v); - CGLM_INLINE bool glms_vec4_isvalid(vec4s v); - CGLM_INLINE vec4s glms_vec4_sign(vec4s v); - CGLM_INLINE vec4s glms_vec4_sqrt(vec4s v); + CGLM_INLINE vec4s glms_vec4_broadcast(float val); + CGLM_INLINE bool glms_vec4_eq(vec4s v, float val); + CGLM_INLINE bool glms_vec4_eq_eps(vec4s v, float val); + CGLM_INLINE bool glms_vec4_eq_all(vec4s v); + CGLM_INLINE bool glms_vec4_eqv(vec4s a, vec4s b); + CGLM_INLINE bool glms_vec4_eqv_eps(vec4s a, vec4s b); + CGLM_INLINE float glms_vec4_max(vec4s v); + CGLM_INLINE float glms_vec4_min(vec4s v); + CGLM_INLINE bool glms_vec4_isnan(vec4s v); + CGLM_INLINE bool glms_vec4_isinf(vec4s v); + CGLM_INLINE bool glms_vec4_isvalid(vec4s v); + CGLM_INLINE vec4s glms_vec4_sign(vec4s v); + CGLM_INLINE vec4s glms_vec4_sqrt(vec4s v); */ #ifndef cglm_vec4s_ext_h @@ -38,7 +38,7 @@ * @brief fill a vector with specified value * * @param val value - * @returns dest + * @returns dest */ CGLM_INLINE vec4s @@ -170,8 +170,8 @@ glms_vec4_isvalid(vec4s v) { * * Important: It returns 0 for zero/NaN input * - * @param v vector - * @returns sign vector + * @param v vector + * @returns sign vector */ CGLM_INLINE vec4s @@ -185,7 +185,7 @@ glms_vec4_sign(vec4s v) { * @brief square root of each vector item * * @param[in] v vector - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s diff --git a/include/cglm/structs/vec4.h b/include/cglm/struct/vec4.h similarity index 70% rename from include/cglm/structs/vec4.h rename to include/cglm/struct/vec4.h index 2f950a7..8ae7dc9 100644 --- a/include/cglm/structs/vec4.h +++ b/include/cglm/struct/vec4.h @@ -15,39 +15,39 @@ GLM_VEC4_ZERO Functions: - CGLM_INLINE vec4s glms_vec4(vec3s v3, float last); - CGLM_INLINE vec3s glms_vec4_copy3(vec4s v); - CGLM_INLINE vec4s glms_vec4_copy(vec4s v); - CGLM_INLINE vec4s glms_vec4_ucopy(vec4s v); - CGLM_INLINE void glms_vec4_pack(vec4s dst[], vec4 src[], size_t len); - CGLM_INLINE void glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len); - CGLM_INLINE float glms_vec4_dot(vec4s a, vec4s b); - CGLM_INLINE float glms_vec4_norm2(vec4s v); - CGLM_INLINE float glms_vec4_norm(vec4s v); - CGLM_INLINE vec4s glms_vec4_add(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_adds(vec4s v, float s); - CGLM_INLINE vec4s glms_vec4_sub(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_subs(vec4s v, float s); - CGLM_INLINE vec4s glms_vec4_mul(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_scale(vec4s v, float s); - CGLM_INLINE vec4s glms_vec4_scale_as(vec4s v, float s); - CGLM_INLINE vec4s glms_vec4_div(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_divs(vec4s v, float s); - CGLM_INLINE vec4s glms_vec4_addadd(vec4s a, vec4s b, vec4s dest); - CGLM_INLINE vec4s glms_vec4_subadd(vec4s a, vec4s b, vec4s dest); - CGLM_INLINE vec4s glms_vec4_muladd(vec4s a, vec4s b, vec4s dest); - CGLM_INLINE vec4s glms_vec4_muladds(vec4s a, float s, vec4s dest); - CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest); - CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest); - CGLM_INLINE vec4s glms_vec4_negate(vec4s v); - CGLM_INLINE vec4s glms_vec4_inv(vec4s v); - CGLM_INLINE vec4s glms_vec4_normalize(vec4s v); - CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_maxv(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_minv(vec4s a, vec4s b); - CGLM_INLINE vec4s glms_vec4_clamp(vec4s v, float minVal, float maxVal); - CGLM_INLINE vec4s glms_vec4_lerp(vec4s from, vec4s to, float t); - CGLM_INLINE vec4s glms_vec4_cubic(float s); + CGLM_INLINE vec4s glms_vec4(vec3s v3, float last); + CGLM_INLINE vec3s glms_vec4_copy3(vec4s v); + CGLM_INLINE vec4s glms_vec4_copy(vec4s v); + CGLM_INLINE vec4s glms_vec4_ucopy(vec4s v); + CGLM_INLINE void glms_vec4_pack(vec4s dst[], vec4 src[], size_t len); + CGLM_INLINE void glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len); + CGLM_INLINE float glms_vec4_dot(vec4s a, vec4s b); + CGLM_INLINE float glms_vec4_norm2(vec4s v); + CGLM_INLINE float glms_vec4_norm(vec4s v); + CGLM_INLINE vec4s glms_vec4_add(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_adds(vec4s v, float s); + CGLM_INLINE vec4s glms_vec4_sub(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_subs(vec4s v, float s); + CGLM_INLINE vec4s glms_vec4_mul(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_scale(vec4s v, float s); + CGLM_INLINE vec4s glms_vec4_scale_as(vec4s v, float s); + CGLM_INLINE vec4s glms_vec4_div(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_divs(vec4s v, float s); + CGLM_INLINE vec4s glms_vec4_addadd(vec4s a, vec4s b, vec4s dest); + CGLM_INLINE vec4s glms_vec4_subadd(vec4s a, vec4s b, vec4s dest); + CGLM_INLINE vec4s glms_vec4_muladd(vec4s a, vec4s b, vec4s dest); + CGLM_INLINE vec4s glms_vec4_muladds(vec4s a, float s, vec4s dest); + CGLM_INLINE vec4s glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest); + CGLM_INLINE vec4s glms_vec4_minadd(vec4s a, vec4s b, vec4s dest); + CGLM_INLINE vec4s glms_vec4_negate(vec4s v); + CGLM_INLINE vec4s glms_vec4_inv(vec4s v); + CGLM_INLINE vec4s glms_vec4_normalize(vec4s v); + CGLM_INLINE float glms_vec4_distance(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_maxv(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_minv(vec4s a, vec4s b); + CGLM_INLINE vec4s glms_vec4_clamp(vec4s v, float minVal, float maxVal); + CGLM_INLINE vec4s glms_vec4_lerp(vec4s from, vec4s to, float t); + CGLM_INLINE vec4s glms_vec4_cubic(float s); */ #ifndef cglm_vec4s_h @@ -72,7 +72,7 @@ * * @param[in] v3 vector3 * @param[in] last last item - * @returns destination + * @returns destination */ CGLM_INLINE vec4s @@ -86,7 +86,7 @@ glms_vec4(vec3s v3, float last) { * @brief copy first 3 members of [a] to [dest] * * @param[in] a source - * @returns destination + * @returns destination */ CGLM_INLINE vec3s @@ -100,7 +100,7 @@ glms_vec4_copy3(vec4s v) { * @brief copy all members of [a] to [dest] * * @param[in] v source - * @returns destination + * @returns destination */ CGLM_INLINE vec4s @@ -116,7 +116,7 @@ glms_vec4_copy(vec4s v) { * alignment is not required * * @param[in] v source - * @returns destination + * @returns destination */ CGLM_INLINE vec4s @@ -136,13 +136,13 @@ glms_vec4_ucopy(vec4s v) { CGLM_INLINE void glms_vec4_pack(vec4s dst[], vec4 src[], size_t len) { - size_t i; - - for (i = 0; i < len; i++) { - dst[i].x = src[i][0]; - dst[i].y = src[i][1]; - dst[i].z = src[i][2]; - } + size_t i; + + for (i = 0; i < len; i++) { + dst[i].x = src[i][0]; + dst[i].y = src[i][1]; + dst[i].z = src[i][2]; + } } /*! @@ -155,41 +155,41 @@ glms_vec4_pack(vec4s dst[], vec4 src[], size_t len) { CGLM_INLINE void glms_vec4_unpack(vec4 dst[], vec4s src[], size_t len) { - size_t i; + size_t i; - for (i = 0; i < len; i++) { - dst[i][0] = src[i].x; - dst[i][1] = src[i].y; - dst[i][2] = src[i].z; - } + for (i = 0; i < len; i++) { + dst[i][0] = src[i].x; + dst[i][1] = src[i].y; + dst[i][2] = src[i].z; + } } /*! * @brief make vector zero * * @param[in] v vector - * @returns zero vector + * @returns zero vector */ CGLM_INLINE vec4s glms_vec4_zero() { - vec4s r; - glm_vec4_zero(r.raw); - return r; + vec4s r; + glm_vec4_zero(r.raw); + return r; } /*! * @brief make vector one * * @param[in] v vector - * @returns one vector + * @returns one vector */ CGLM_INLINE vec4s glms_vec4_one() { - vec4s r; - glm_vec4_one(r.raw); - return r; + vec4s r; + glm_vec4_one(r.raw); + return r; } /*! @@ -241,7 +241,7 @@ glms_vec4_norm(vec4s v) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -256,7 +256,7 @@ glms_vec4_add(vec4s a, vec4s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -271,7 +271,7 @@ glms_vec4_adds(vec4s v, float s) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -286,7 +286,7 @@ glms_vec4_sub(vec4s a, vec4s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -301,7 +301,7 @@ glms_vec4_subs(vec4s v, float s) { * * @param a vector1 * @param b vector2 - * @returns dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]) + * @returns dest = (a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]) */ CGLM_INLINE vec4s @@ -316,7 +316,7 @@ glms_vec4_mul(vec4s a, vec4s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -331,7 +331,7 @@ glms_vec4_scale(vec4s v, float s) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -346,7 +346,7 @@ glms_vec4_scale_as(vec4s v, float s) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2], a[3]/b[3]) + * @returns result = (a[0]/b[0], a[1]/b[1], a[2]/b[2], a[3]/b[3]) */ CGLM_INLINE vec4s @@ -361,7 +361,7 @@ glms_vec4_div(vec4s a, vec4s b) { * * @param[in] v vector * @param[in] s scalar - * @returns destination vector + * @returns destination vector */ CGLM_INLINE vec4s @@ -378,7 +378,7 @@ glms_vec4_divs(vec4s v, float s) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a + b) + * @returns dest += (a + b) */ CGLM_INLINE vec4s @@ -394,7 +394,7 @@ glms_vec4_addadd(vec4s a, vec4s b, vec4s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a - b) + * @returns dest += (a - b) */ CGLM_INLINE vec4s @@ -410,7 +410,7 @@ glms_vec4_subadd(vec4s a, vec4s b, vec4s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += (a * b) + * @returns dest += (a * b) */ CGLM_INLINE vec4s @@ -426,7 +426,7 @@ glms_vec4_muladd(vec4s a, vec4s b, vec4s dest) { * * @param[in] a vector * @param[in] s scalar - * @returns dest += (a * b) + * @returns dest += (a * b) */ CGLM_INLINE vec4s @@ -442,7 +442,7 @@ glms_vec4_muladds(vec4s a, float s, vec4s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += max(a, b) + * @returns dest += max(a, b) */ CGLM_INLINE vec4s @@ -458,7 +458,7 @@ glms_vec4_maxadd(vec4s a, vec4s b, vec4s dest) { * * @param[in] a vector 1 * @param[in] b vector 2 - * @returns dest += min(a, b) + * @returns dest += min(a, b) */ CGLM_INLINE vec4s @@ -471,7 +471,7 @@ glms_vec4_minadd(vec4s a, vec4s b, vec4s dest) { * @brief negate vector components and store result in dest * * @param[in] v vector - * @returns result vector + * @returns result vector */ CGLM_INLINE vec4s @@ -483,8 +483,8 @@ glms_vec4_negate(vec4s v) { /*! * @brief normalize vec4 and store result in same vec * - * @param[in] v vector - * @returns normalized vector + * @param[in] v vector + * @returns normalized vector */ CGLM_INLINE vec4s @@ -511,7 +511,7 @@ glms_vec4_distance(vec4s a, vec4s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination + * @returns destination */ CGLM_INLINE vec4s @@ -526,7 +526,7 @@ glms_vec4_maxv(vec4s a, vec4s b) { * * @param[in] a vector1 * @param[in] b vector2 - * @returns destination + * @returns destination */ CGLM_INLINE vec4s @@ -539,10 +539,10 @@ glms_vec4_minv(vec4s a, vec4s b) { /*! * @brief clamp vector's individual members between min and max values * - * @param[in] v vector - * @param[in] minVal minimum value - * @param[in] maxVal maximum value - * @returns clamped vector + * @param[in] v vector + * @param[in] minVal minimum value + * @param[in] maxVal maximum value + * @returns clamped vector */ CGLM_INLINE vec4s @@ -556,10 +556,10 @@ glms_vec4_clamp(vec4s v, float minVal, float maxVal) { * * formula: from + s * (to - from) * - * @param[in] from from value - * @param[in] to to value - * @param[in] t interpolant (amount) clamped between 0 and 1 - * @returns destination + * @param[in] from from value + * @param[in] to to value + * @param[in] t interpolant (amount) clamped between 0 and 1 + * @returns destination */ CGLM_INLINE vec4s @@ -572,15 +572,15 @@ glms_vec4_lerp(vec4s from, vec4s to, float t) { /*! * @brief helper to fill vec4 as [S^3, S^2, S, 1] * - * @param[in] s parameter - * @returns destination + * @param[in] s parameter + * @returns destination */ CGLM_INLINE vec4s glms_vec4_cubic(float s) { - vec4s r; - glm_vec4_cubic(s, r.raw); - return r; + vec4s r; + glm_vec4_cubic(s, r.raw); + return r; } #endif /* cglm_vec4s_h */ diff --git a/include/cglm/types-struct.h b/include/cglm/types-struct.h index 2d54aa4..f71c286 100644 --- a/include/cglm/types-struct.h +++ b/include/cglm/types-struct.h @@ -53,13 +53,8 @@ typedef union mat3s { float m10, m11, m12; float m20, m21, m22; }; - struct { - vec3s col0; - vec3s col1; - vec3s col2; - }; #endif - vec3s col[3]; + vec3s col[3]; mat3 raw; } mat3s; @@ -67,18 +62,12 @@ typedef union CGLM_ALIGN_MAT mat4s { #ifndef CGLM_NO_ANONYMOUS_STRUCT struct { float m00, m01, m02, m03; - float m10, m11, m12, m13; - float m20, m21, m22, m23; - float m30, m31, m32, m33; - }; - struct { - vec4s col0; - vec4s col1; - vec4s col2; - vec4s col3; + float m10, m11, m12, m13; + float m20, m21, m22, m23; + float m30, m31, m32, m33; }; #endif - vec4s col[4]; + vec4s col[4]; mat4 raw; } mat4s; diff --git a/test/src/test_common.c b/test/src/test_common.c index 02ccaec..d734e72 100644 --- a/test/src/test_common.c +++ b/test/src/test_common.c @@ -49,8 +49,7 @@ test_rand_vec3(vec3 dest) { } vec3s -test_rand_vec3s() -{ +test_rand_vec3s() { vec3s r; test_rand_vec3(r.raw); return r; @@ -67,8 +66,7 @@ test_rand_vec4(vec4 dest) { } vec4s -test_rand_vec4s() -{ +test_rand_vec4s() { vec4s r; test_rand_vec4(r.raw); return r; @@ -137,8 +135,7 @@ test_assert_vec3_eq(vec3 v1, vec3 v2) { } void -test_assert_vec3s_eq(vec3s v1, vec3s v2) -{ +test_assert_vec3s_eq(vec3s v1, vec3s v2) { test_assert_vec3_eq(v1.raw, v2.raw); } @@ -151,8 +148,7 @@ test_assert_vec4_eq(vec4 v1, vec4 v2) { } void -test_assert_vec4s_eq(vec4s v1, vec4s v2) -{ +test_assert_vec4s_eq(vec4s v1, vec4s v2) { test_assert_vec4_eq(v1.raw, v2.raw); }