Merge branch 'recp:master' into master

This commit is contained in:
telephone001.mdl
2023-12-08 13:09:24 -06:00
committed by GitHub
22 changed files with 862 additions and 10 deletions

173
docs/source/aabb2d.rst Normal file
View File

@@ -0,0 +1,173 @@
.. default-domain:: C
2d axis aligned bounding box (AABB)
================================================================================
Header: cglm/aabb2d.h
Some convenient functions provided for AABB.
**Definition of aabb:**
cglm defines an aabb as a two dimensional array of vec2's.
The first element is the **min** point and the second one is the **max** point.
If you have another type e.g. struct or even another representation then you must
convert it before and after calling a cglm aabb2d function.
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Functions:
1. :c:func:`glm_aabb2d_copy`
#. :c:func:`glm_aabb2d_transform`
#. :c:func:`glm_aabb2d_merge`
#. :c:func:`glm_aabb2d_crop`
#. :c:func:`glm_aabb2d_crop_until`
#. :c:func:`glm_aabb2d_invalidate`
#. :c:func:`glm_aabb2d_isvalid`
#. :c:func:`glm_aabb2d_size`
#. :c:func:`glm_aabb2d_radius`
#. :c:func:`glm_aabb2d_center`
#. :c:func:`glm_aabb2d_aabb`
#. :c:func:`glm_aabb2d_circle`
#. :c:func:`glm_aabb2d_point`
#. :c:func:`glm_aabb2d_contains`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
.. c:function:: void glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2])
| copy all members of [aabb] to [dest]
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **dest** destination
.. c:function:: void glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2])
| apply transform to Axis-Aligned Bounding Box
Parameters:
| *[in]* **aabb** bounding box
| *[in]* **m** transform matrix
| *[out]* **dest** transformed bounding box
.. c:function:: void glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2])
| merges two AABB bounding box and creates new one
two aabb must be in the same space
Parameters:
| *[in]* **aabb1** bounding box 1
| *[in]* **aabb2** bounding box 2
| *[out]* **dest** merged bounding box
.. c:function:: void glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2])
| crops a bounding box with another one.
this could be useful for gettng a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **aabb** bounding box 1
| *[in]* **cropAabb** crop box
| *[out]* **dest** cropped bounding box
.. c:function:: void glm_aabb2d_crop_until(vec2 aabb[2], vec2 cropAabb[2], vec2 clampAabb[2], vec2 dest[2])
| crops a bounding box with another one.
this could be useful for gettng a bbox which fits with view frustum and
object bounding boxes. In this case you crop view frustum box with objects
box
Parameters:
| *[in]* **aabb** bounding box
| *[in]* **cropAabb** crop box
| *[in]* **clampAabb** miniumum box
| *[out]* **dest** cropped bounding box
.. c:function:: void glm_aabb2d_invalidate(vec2 aabb[2])
| invalidate AABB min and max values
| It fills *max* values with -FLT_MAX and *min* values with +FLT_MAX
Parameters:
| *[in, out]* **aabb** bounding box
.. c:function:: bool glm_aabb2d_isvalid(vec2 aabb[2])
| check if AABB is valid or not
Parameters:
| *[in]* **aabb** bounding box
Returns:
returns true if aabb is valid otherwise false
.. c:function:: float glm_aabb2d_size(vec2 aabb[2])
| distance between of min and max
Parameters:
| *[in]* **aabb** bounding box
Returns:
distance between min - max
.. c:function:: float glm_aabb2d_radius(vec2 aabb[2])
| radius of sphere which surrounds AABB
Parameters:
| *[in]* **aabb** bounding box
.. c:function:: void glm_aabb2d_center(vec2 aabb[2], vec2 dest)
| computes center point of AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **dest** center of bounding box
.. c:function:: bool glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2])
| check if two AABB intersects
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **other** other bounding box
.. c:function:: bool glm_aabb2d_circle(vec2 aabb[2], vec3 c)
| check if AABB intersects with sphere
| https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
| Solid Box - Solid Sphere test.
Parameters:
| *[in]* **aabb** solid bounding box
| *[out]* **c** solid circle
.. c:function:: bool glm_aabb2d_point(vec2 aabb[2], vec2 point)
| check if point is inside of AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **point** point
.. c:function:: bool glm_aabb2d_contains(vec2 aabb[2], vec2 other[2])
| check if AABB contains other AABB
Parameters:
| *[in]* **aabb** bounding box
| *[out]* **other** other bounding box

View File

@@ -18,6 +18,7 @@ Features
* inline or pre-compiled function call
* frustum (extract view frustum planes, corners...)
* bounding box (AABB in Frustum (culling), crop, merge...)
* 2d bounding box (crop, merge...)
* bounding sphere
* project, unproject
* easing functions

245
include/cglm/aabb2d.h Normal file
View File

@@ -0,0 +1,245 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_aabb2d_h
#define cglm_aabb2d_h
#include "common.h"
#include "vec2.h"
#include "vec4.h"
#include "util.h"
/*!
* @brief copy all members of [aabb] to [dest]
*
* @param[in] aabb source
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) {
glm_vec2_copy(aabb[0], dest[0]);
glm_vec2_copy(aabb[1], dest[1]);
}
/*!
* @brief apply transform to Axis-Aligned Bounding aabb
*
* @param[in] aabb bounding aabb
* @param[in] m transform matrix
* @param[out] dest transformed bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) {
vec2 v[2], xa, xb, ya, yb;
glm_vec2_scale(m[0], aabb[0][0], xa);
glm_vec2_scale(m[0], aabb[1][0], xb);
glm_vec2_scale(m[1], aabb[0][1], ya);
glm_vec2_scale(m[1], aabb[1][1], yb);
/* translation + min(xa, xb) + min(ya, yb) */
glm_vec2(m[2], v[0]);
glm_vec2_minadd(xa, xb, v[0]);
glm_vec2_minadd(ya, yb, v[0]);
/* translation + max(xa, xb) + max(ya, yb) */
glm_vec2(m[2], v[1]);
glm_vec2_maxadd(xa, xb, v[1]);
glm_vec2_maxadd(ya, yb, v[1]);
glm_vec2_copy(v[0], dest[0]);
glm_vec2_copy(v[1], dest[1]);
}
/*!
* @brief merges two AABB bounding aabb and creates new one
*
* two aabb must be in same space, if one of aabb is in different space then
* you should consider to convert it's space by glm_aabb_space
*
* @param[in] aabb1 bounding aabb 1
* @param[in] aabb2 bounding aabb 2
* @param[out] dest merged bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) {
dest[0][0] = glm_min(aabb1[0][0], aabb2[0][0]);
dest[0][1] = glm_min(aabb1[0][1], aabb2[0][1]);
dest[1][0] = glm_max(aabb1[1][0], aabb2[1][0]);
dest[1][1] = glm_max(aabb1[1][1], aabb2[1][1]);
}
/*!
* @brief crops a bounding aabb with another one.
*
* this could be useful for gettng a baabb which fits with view frustum and
* object bounding aabbes. In this case you crop view frustum aabb with objects
* aabb
*
* @param[in] aabb bounding aabb 1
* @param[in] cropaabb crop aabb
* @param[out] dest cropped bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) {
dest[0][0] = glm_max(aabb[0][0], cropAabb[0][0]);
dest[0][1] = glm_max(aabb[0][1], cropAabb[0][1]);
dest[1][0] = glm_min(aabb[1][0], cropAabb[1][0]);
dest[1][1] = glm_min(aabb[1][1], cropAabb[1][1]);
}
/*!
* @brief crops a bounding aabb with another one.
*
* this could be useful for gettng a baabb which fits with view frustum and
* object bounding aabbes. In this case you crop view frustum aabb with objects
* aabb
*
* @param[in] aabb bounding aabb
* @param[in] cropaabb crop aabb
* @param[in] clampaabb miniumum aabb
* @param[out] dest cropped bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_crop_until(vec2 aabb[2],
vec2 cropAabb[2],
vec2 clampAabb[2],
vec2 dest[2]) {
glm_aabb2d_crop(aabb, cropAabb, dest);
glm_aabb2d_merge(clampAabb, dest, dest);
}
/*!
* @brief invalidate AABB min and max values
*
* @param[in, out] aabb bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_invalidate(vec2 aabb[2]) {
glm_vec2_fill(aabb[0], FLT_MAX);
glm_vec2_fill(aabb[1], -FLT_MAX);
}
/*!
* @brief check if AABB is valid or not
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_isvalid(vec2 aabb[2]) {
return glm_vec2_max(aabb[0]) != FLT_MAX
&& glm_vec2_min(aabb[1]) != -FLT_MAX;
}
/*!
* @brief distance between of min and max
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
float
glm_aabb2d_size(vec2 aabb[2]) {
return glm_vec2_distance(aabb[0], aabb[1]);
}
/*!
* @brief radius of sphere which surrounds AABB
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
float
glm_aabb2d_radius(vec2 aabb[2]) {
return glm_aabb2d_size(aabb) * 0.5f;
}
/*!
* @brief computes center point of AABB
*
* @param[in] aabb bounding aabb
* @param[out] dest center of bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_center(vec2 aabb[2], vec2 dest) {
glm_vec2_center(aabb[0], aabb[1], dest);
}
/*!
* @brief check if two AABB intersects
*
* @param[in] aabb bounding aabb
* @param[in] other other bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) {
return (aabb[0][0] <= other[1][0] && aabb[1][0] >= other[0][0])
&& (aabb[0][1] <= other[1][1] && aabb[1][1] >= other[0][1]);
}
/*!
* @brief check if AABB intersects with a circle
*
* Circle Representation in cglm: [center.x, center.y, radii]
*
* @param[in] aabb solid bounding aabb
* @param[in] c solid circle
*/
CGLM_INLINE
bool
glm_aabb2d_circle(vec2 aabb[2], vec3 c) {
float dmin;
int a, b;
a = (c[0] < aabb[0][0]) + (c[0] > aabb[1][0]);
b = (c[1] < aabb[0][1]) + (c[1] > aabb[1][1]);
dmin = glm_pow2((c[0] - aabb[!(a - 1)][0]) * (a != 0))
+ glm_pow2((c[1] - aabb[!(b - 1)][1]) * (b != 0));
return dmin <= glm_pow2(c[2]);
}
/*!
* @brief check if point is inside of AABB
*
* @param[in] aabb bounding aabb
* @param[in] point point
*/
CGLM_INLINE
bool
glm_aabb2d_point(vec2 aabb[2], vec2 point) {
return (point[0] >= aabb[0][0] && point[0] <= aabb[1][0])
&& (point[1] >= aabb[0][1] && point[1] <= aabb[1][1]);
}
/*!
* @brief check if AABB contains other AABB
*
* @param[in] aabb bounding aabb
* @param[in] other other bounding aabb
*/
CGLM_INLINE
bool
glm_aabb2d_contains(vec2 aabb[2], vec2 other[2]) {
return (aabb[0][0] <= other[0][0] && aabb[1][0] >= other[1][0])
&& (aabb[0][1] <= other[0][1] && aabb[1][1] >= other[1][1]);
}
#endif /* cglm_aabb2d_h */

View File

@@ -33,6 +33,7 @@ extern "C" {
#include "call/euler.h"
#include "call/plane.h"
#include "call/frustum.h"
#include "call/aabb2d.h"
#include "call/box.h"
#include "call/io.h"
#include "call/project.h"

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglmc_aabb2d_h
#define cglmc_aabb2d_h
#ifdef __cplusplus
extern "C" {
#endif
#include "../cglm.h"
CGLM_EXPORT
void
glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_crop_until(vec2 aabb[2],
vec2 cropAabb[2],
vec2 clampAabb[2],
vec2 dest[2]);
CGLM_EXPORT
void
glmc_aabb2d_invalidate(vec2 aabb[2]);
CGLM_EXPORT
bool
glmc_aabb2d_isvalid(vec2 aabb[2]);
CGLM_EXPORT
float
glmc_aabb2d_size(vec2 aabb[2]);
CGLM_EXPORT
float
glmc_aabb2d_radius(vec2 aabb[2]);
CGLM_EXPORT
void
glmc_aabb2d_center(vec2 aabb[2], vec2 dest);
CGLM_EXPORT
bool
glmc_aabb2d_aabb(vec2 aabb[2], vec2 other[2]);
CGLM_EXPORT
bool
glmc_aabb2d_point(vec2 aabb[2], vec2 point);
CGLM_EXPORT
bool
glmc_aabb2d_contains(vec2 aabb[2], vec2 other[2]);
CGLM_EXPORT
bool
glmc_aabb2d_circle(vec2 aabb[2], vec3 s);
#ifdef __cplusplus
}
#endif
#endif /* cglmc_aabb2d_h */

View File

@@ -30,6 +30,7 @@
#include "quat.h"
#include "euler.h"
#include "plane.h"
#include "aabb2d.h"
#include "box.h"
#include "color.h"
#include "util.h"

View File

@@ -0,0 +1,235 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglms_aabb2ds_h
#define cglms_aabb2ds_h
#include "../common.h"
#include "../types-struct.h"
#include "../aabb2d.h"
#include "vec2.h"
#include "vec4.h"
#include "mat4.h"
/* api definition */
#define glms_aabb2d_(NAME) CGLM_STRUCTAPI(aabb, NAME)
/*!
* @brief apply transform to Axis-Aligned Bounding Box
*
* @param[in] aabb bounding box
* @param[in] m transform matrix
* @param[out] dest transformed bounding box
*/
CGLM_INLINE
void
glms_aabb2d_(transform)(vec2s aabb[2], mat3s m, vec2s dest[2]) {
vec2 rawAabb[2];
vec2 rawDest[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
glm_aabb2d_transform(rawAabb, m.raw, rawDest);
glms_vec2_(pack)(dest, rawDest, 2);
}
/*!
* @brief merges two AABB bounding box and creates new one
*
* two box must be in same space, if one of box is in different space then
* you should consider to convert it's space by glm_box_space
*
* @param[in] aabb1 bounding box 1
* @param[in] aabb2 bounding box 2
* @param[out] dest merged bounding box
*/
CGLM_INLINE
void
glms_aabb2d_(merge)(vec2s aabb1[2], vec2s aabb2[2], vec2s dest[2]) {
vec2 rawAabb1[2];
vec2 rawAabb2[2];
vec2 rawDest[2];
glms_vec2_(unpack)(rawAabb1, aabb1, 2);
glms_vec2_(unpack)(rawAabb2, aabb2, 2);
glm_aabb2d_merge(rawAabb1, rawAabb2, rawDest);
glms_vec2_(pack)(dest, rawDest, 2);
}
/*!
* @brief crops a bounding box with another one.
*
* this could be useful for gettng a bbox which fits with view frustum and
* object bounding boxes. In this case you crop view frustum box with objects
* box
*
* @param[in] aabb bounding box 1
* @param[in] cropAabb crop box
* @param[out] dest cropped bounding box
*/
CGLM_INLINE
void
glms_aabb2d_(crop)(vec2s aabb[2], vec2s cropAabb[2], vec2s dest[2]) {
vec2 rawAabb[2];
vec2 rawCropAabb[2];
vec2 rawDest[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
glms_vec2_(unpack)(rawCropAabb, cropAabb, 2);
glm_aabb2d_crop(rawAabb, rawCropAabb, rawDest);
glms_vec2_(pack)(dest, rawDest, 2);
}
/*!
* @brief crops a bounding box with another one.
*
* this could be useful for gettng a bbox which fits with view frustum and
* object bounding boxes. In this case you crop view frustum box with objects
* box
*
* @param[in] aabb bounding box
* @param[in] cropAabb crop box
* @param[in] clampAabb miniumum box
* @param[out] dest cropped bounding box
*/
CGLM_INLINE
void
glms_aabb2d_(crop_until)(vec2s aabb[2],
vec2s cropAabb[2],
vec2s clampAabb[2],
vec2s dest[2]) {
glms_aabb2d_(crop)(aabb, cropAabb, dest);
glms_aabb2d_(merge)(clampAabb, dest, dest);
}
/*!
* @brief invalidate AABB min and max values
*
* @param[in, out] aabb bounding box
*/
CGLM_INLINE
void
glms_aabb2d_(invalidate)(vec2s box[2]) {
box[0] = glms_vec2_(fill)(FLT_MAX);
box[1] = glms_vec2_(fill)(-FLT_MAX);
}
/*!
* @brief check if AABB is valid or not
*
* @param[in] aabb bounding box
*/
CGLM_INLINE
bool
glms_aabb2d_(isvalid)(vec2s aabb[2]) {
vec2 rawAabb[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
return glm_aabb2d_isvalid(rawAabb);
}
/*!
* @brief distance between of min and max
*
* @param[in] aabb bounding box
*/
CGLM_INLINE
float
glms_aabb2d_(size)(vec2s aabb[2]) {
return glm_vec2_distance(aabb[0].raw, aabb[1].raw);
}
/*!
* @brief radius of sphere which surrounds AABB
*
* @param[in] aabb bounding box
*/
CGLM_INLINE
float
glms_aabb2d_(radius)(vec2s aabb[2]) {
return glms_aabb2d_(size)(aabb) * 0.5f;
}
/*!
* @brief computes center point of AABB
*
* @param[in] aabb bounding box
* @returns center of bounding box
*/
CGLM_INLINE
vec2s
glms_aabb2d_(center)(vec2s aabb[2]) {
return glms_vec2_(center)(aabb[0], aabb[1]);
}
/*!
* @brief check if two AABB intersects
*
* @param[in] aabb bounding box
* @param[in] other other bounding box
*/
CGLM_INLINE
bool
glms_aabb2d_(aabb)(vec2s aabb[2], vec2s other[2]) {
vec2 rawAabb[2];
vec2 rawOther[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
glms_vec2_(unpack)(rawOther, other, 2);
return glm_aabb2d_aabb(rawAabb, rawOther);
}
/*!
* @brief check if AABB intersects with a circle
*
* https://github.com/erich666/GraphicsGems/blob/master/gems/BoxSphere.c
* Solid Box - Solid Sphere test.
*
* @param[in] aabb solid bounding box
* @param[in] s solid sphere
*/
CGLM_INLINE
bool
glms_aabb2d_(circle)(vec2s aabb[2], vec3s c) {
vec2 rawAabb[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
return glm_aabb2d_circle(rawAabb, c.raw);
}
/*!
* @brief check if point is inside of AABB
*
* @param[in] aabb bounding box
* @param[in] point point
*/
CGLM_INLINE
bool
glms_aabb2d_(point)(vec2s aabb[2], vec2s point) {
vec2 rawAabb[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
return glm_aabb2d_point(rawAabb, point.raw);
}
/*!
* @brief check if AABB contains other AABB
*
* @param[in] box bounding box
* @param[in] other other bounding box
*/
CGLM_INLINE
bool
glms_aabb2d_(contains)(vec2s aabb[2], vec2s other[2]) {
vec2 rawAabb[2];
vec2 rawOther[2];
glms_vec2_(unpack)(rawAabb, aabb, 2);
glms_vec2_(unpack)(rawOther, other, 2);
return glm_aabb2d_contains(rawAabb, rawOther);
}
#endif /* cglms_aabb2ds_h */

View File

@@ -24,6 +24,8 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../vec3.h"
#include "../../clipspace/ortho_lh_no.h"
/*!
* @brief set up orthographic projection matrix

View File

@@ -24,6 +24,8 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../vec3.h"
#include "../../clipspace/ortho_lh_zo.h"
/*!
* @brief set up orthographic projection matrix

View File

@@ -24,6 +24,8 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../vec3.h"
#include "../../clipspace/ortho_rh_no.h"
/*!
* @brief set up orthographic projection matrix

View File

@@ -24,6 +24,8 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../vec3.h"
#include "../../clipspace/ortho_rh_zo.h"
/*!
* @brief set up orthographic projection matrix

View File

@@ -39,6 +39,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/persp_lh_no.h"
/*!
* @brief set up perspective peprojection matrix

View File

@@ -39,6 +39,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/persp_lh_zo.h"
/*!
* @brief set up perspective peprojection matrix

View File

@@ -39,6 +39,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/persp_rh_no.h"
/*!
* @brief set up perspective peprojection matrix

View File

@@ -39,6 +39,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/persp_rh_zo.h"
/*!
* @brief set up perspective peprojection matrix

View File

@@ -7,8 +7,9 @@
/*
Functions:
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest)
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest)
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp)
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp)
CGLM_INLINE float glms_project_z_no(vec3s v, mat4s m)
*/
#ifndef cglms_project_no_h
@@ -18,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/project_no.h"
/*!
* @brief maps the specified viewport coordinates into specified space [1]
@@ -48,7 +50,7 @@
*/
CGLM_INLINE
vec3s
glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp) {
vec3s dest;
glm_unprojecti_no(pos.raw, invMat.raw, vp.raw, dest.raw);
return dest;
@@ -69,7 +71,7 @@ glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
*/
CGLM_INLINE
vec3s
glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest) {
glms_project_no(vec3s pos, mat4s m, vec4s vp) {
vec3s dest;
glm_project_no(pos.raw, m.raw, vp.raw, dest.raw);
return dest;
@@ -88,7 +90,7 @@ glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest) {
* @returns projected z coordinate
*/
CGLM_INLINE
vec3s
float
glms_project_z_no(vec3s v, mat4s m) {
return glm_project_z_no(v.raw, m.raw);
}

View File

@@ -7,8 +7,9 @@
/*
Functions:
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp, vec3 dest)
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp, vec3s dest)
CGLM_INLINE vec3s glms_unprojecti_no(vec3s pos, mat4s invMat, vec4s vp)
CGLM_INLINE vec3s glms_project_no(vec3s pos, mat4s m, vec4s vp)
CGLM_INLINE float glms_project_z_zo(vec3s v, mat4s m)
*/
#ifndef cglms_project_zo_h
@@ -18,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/project_zo.h"
/*!
* @brief maps the specified viewport coordinates into specified space [1]
@@ -48,7 +50,7 @@
*/
CGLM_INLINE
vec3s
glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp) {
vec3s dest;
glm_unprojecti_zo(pos.raw, invMat.raw, vp.raw, dest.raw);
return dest;
@@ -69,7 +71,7 @@ glms_unprojecti_zo(vec3s pos, mat4s invMat, vec4s vp, vec3 dest) {
*/
CGLM_INLINE
vec3s
glms_project_zo(vec3s pos, mat4s m, vec4s vp, vec3 dest) {
glms_project_zo(vec3s pos, mat4s m, vec4s vp) {
vec3s dest;
glm_project_zo(pos.raw, m.raw, vp.raw, dest.raw);
return dest;
@@ -88,7 +90,7 @@ glms_project_zo(vec3s pos, mat4s m, vec4s vp, vec3 dest) {
* @returns projected z coordinate
*/
CGLM_INLINE
vec3s
float
glms_project_z_zo(vec3s v, mat4s m) {
return glm_project_z_zo(v.raw, m.raw);
}

View File

@@ -19,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/view_lh_no.h"
/*!
* @brief set up view matrix

View File

@@ -19,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/view_lh_zo.h"
/*!
* @brief set up view matrix

View File

@@ -19,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/view_rh_no.h"
/*!
* @brief set up view matrix

View File

@@ -19,6 +19,7 @@
#include "../../types-struct.h"
#include "../../plane.h"
#include "../../cam.h"
#include "../../clipspace/view_rh_zo.h"
/*!
* @brief set up view matrix

96
src/aabb2d.c Normal file
View File

@@ -0,0 +1,96 @@
/*
* 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
void
glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]) {
glm_aabb2d_copy(aabb, dest);
}
CGLM_EXPORT
void
glmc_aabb2d_transform(vec2 aabb[2], mat3 m, vec2 dest[2]) {
glm_aabb2d_transform(aabb, m, dest);
}
CGLM_EXPORT
void
glmc_aabb2d_merge(vec2 aabb1[2], vec2 aabb2[2], vec2 dest[2]) {
glm_aabb2d_merge(aabb1, aabb2, dest);
}
CGLM_EXPORT
void
glmc_aabb2d_crop(vec2 aabb[2], vec2 cropAabb[2], vec2 dest[2]) {
glm_aabb2d_crop(aabb, cropAabb, dest);
}
CGLM_EXPORT
void
glmc_aabb2d_crop_until(vec2 aabb[2],
vec2 cropAabb[2],
vec2 clampAabb[2],
vec2 dest[2]) {
glm_aabb2d_crop_until(aabb, cropAabb, clampAabb, dest);
}
CGLM_EXPORT
void
glmc_aabb2d_invalidate(vec2 aabb[2]) {
glm_aabb2d_invalidate(aabb);
}
CGLM_EXPORT
bool
glmc_aabb2d_isvalid(vec2 aabb[2]) {
return glm_aabb2d_isvalid(aabb);
}
CGLM_EXPORT
float
glmc_aabb2d_size(vec2 aabb[2]) {
return glm_aabb2d_size(aabb);
}
CGLM_EXPORT
float
glmc_aabb2d_radius(vec2 aabb[2]) {
return glm_aabb2d_radius(aabb);
}
CGLM_EXPORT
void
glmc_aabb2d_center(vec2 aabb[2], vec2 dest) {
glm_aabb2d_center(aabb, dest);
}
CGLM_EXPORT
bool
glmc_aabb2d_aabb(vec2 aabb[2], vec2 other[2]) {
return glm_aabb2d_aabb(aabb, other);
}
CGLM_EXPORT
bool
glmc_aabb2d_point(vec2 aabb[2], vec2 point) {
return glm_aabb2d_point(aabb, point);
}
CGLM_EXPORT
bool
glmc_aabb2d_contains(vec2 aabb[2], vec2 other[2]) {
return glm_aabb2d_contains(aabb, other);
}
CGLM_EXPORT
bool
glmc_aabb2d_circle(vec2 aabb[2], vec3 s) {
return glm_aabb2d_circle(aabb, s);
}