Skip to content

Commit

Permalink
glm_aabb2d_zero, _size -> _diagonal, new _size
Browse files Browse the repository at this point in the history
  • Loading branch information
duarm committed Feb 19, 2024
1 parent 78fb330 commit e312f28
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
29 changes: 26 additions & 3 deletions include/cglm/aabb2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@

#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_zero(vec2 aabb[2]) {
glm_vec2_zero(aabb[0]);
glm_vec2_zero(aabb[1]);
}

/*!
* @brief copy all members of [aabb] to [dest]
*
Expand Down Expand Up @@ -152,10 +164,21 @@ glm_aabb2d_isvalid(vec2 aabb[2]) {
*/
CGLM_INLINE
float
glm_aabb2d_size(vec2 aabb[2]) {
glm_aabb2d_diagonal(vec2 aabb[2]) {
return glm_vec2_distance(aabb[0], aabb[1]);
}

/*!
* @brief distance between of min and max
*
* @param[in] aabb bounding aabb
*/
CGLM_INLINE
void
glm_aabb2d_size(vec2 aabb[2], vec2 dest) {
glm_vec2_sub(aabb[1], aabb[0], dest);
}

/*!
* @brief radius of sphere which surrounds AABB
*
Expand All @@ -164,7 +187,7 @@ glm_aabb2d_size(vec2 aabb[2]) {
CGLM_INLINE
float
glm_aabb2d_radius(vec2 aabb[2]) {
return glm_aabb2d_size(aabb) * 0.5f;
return glm_aabb2d_diagonal(aabb) * 0.5f;
}

/*!
Expand Down
4 changes: 4 additions & 0 deletions include/cglm/call/aabb2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ extern "C" {

#include "../cglm.h"

CGLM_EXPORT
void
glmc_aabb2d_zero(vec2 aabb[2]);

CGLM_EXPORT
void
glmc_aabb2d_copy(vec2 aabb[2], vec2 dest[2]);
Expand Down

0 comments on commit e312f28

Please sign in to comment.