From fb2cac981657910cd564c914228acfb2158365fc Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Tue, 22 May 2018 17:45:37 +0300 Subject: [PATCH] aabb: center of AABB helper * it is just wrapper of vec_center but it saves to access min and max values of AABB --- include/cglm/box.h | 12 ++++++++++++ include/cglm/call/box.h | 5 +++++ src/box.c | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/include/cglm/box.h b/include/cglm/box.h index 31b0ec2..5ed135e 100644 --- a/include/cglm/box.h +++ b/include/cglm/box.h @@ -200,4 +200,16 @@ glm_aabb_radius(vec3 box[2]) { return glm_aabb_size(box) * 0.5f; } +/*! + * @brief computes center point of AABB + * + * @param[in] box bounding box + * @param[out] dest center of bounding box + */ +CGLM_INLINE +void +glm_aabb_center(vec3 box[2], vec3 dest) { + glm_vec_center(box[0], box[1], dest); +} + #endif /* cglm_box_h */ diff --git a/include/cglm/call/box.h b/include/cglm/call/box.h index 3b532b5..bf25508 100644 --- a/include/cglm/call/box.h +++ b/include/cglm/call/box.h @@ -51,6 +51,11 @@ glmc_aabb_size(vec3 box[2]); CGLM_EXPORT float glmc_aabb_radius(vec3 box[2]); + +CGLM_EXPORT +void +glmc_aabb_center(vec3 box[2], vec3 dest); + #ifdef __cplusplus } #endif diff --git a/src/box.c b/src/box.c index 6cc51b5..0274390 100644 --- a/src/box.c +++ b/src/box.c @@ -64,3 +64,9 @@ float glmc_aabb_radius(vec3 box[2]) { return glm_aabb_radius(box); } + +CGLM_EXPORT +void +glmc_aabb_center(vec3 box[2], vec3 dest) { + glm_aabb_center(box, dest); +}