diff --git a/doc/graphene-sections.txt b/doc/graphene-sections.txt index bb85ba6..253f6c0 100644 --- a/doc/graphene-sections.txt +++ b/doc/graphene-sections.txt @@ -14,6 +14,7 @@ graphene_box_expand_scalar graphene_box_expand_vec3 graphene_box_get_min graphene_box_get_max +graphene_box_get_minmax graphene_box_get_center graphene_box_get_depth graphene_box_get_height diff --git a/include/graphene-box.h b/include/graphene-box.h index d8605bd..eebee06 100644 --- a/include/graphene-box.h +++ b/include/graphene-box.h @@ -113,6 +113,10 @@ void graphene_box_get_min (const graphene_ GRAPHENE_AVAILABLE_IN_1_2 void graphene_box_get_max (const graphene_box_t *box, graphene_point3d_t *max); +GRAPHENE_AVAILABLE_IN_1_12 +void graphene_box_get_minmax (const graphene_box_t *box, + graphene_point3d_t *min, + graphene_point3d_t *max); GRAPHENE_AVAILABLE_IN_1_2 void graphene_box_get_vertices (const graphene_box_t *box, graphene_vec3_t vertices[]); diff --git a/src/graphene-box.c b/src/graphene-box.c index 4fd4f12..d9c6a98 100644 --- a/src/graphene-box.c +++ b/src/graphene-box.c @@ -528,6 +528,28 @@ graphene_box_get_center (const graphene_box_t *box, graphene_point3d_init_from_vec3 (center, &res); } +/** + * graphene_box_get_minmax: + * @box: a #graphene_box_t + * @min: (out caller-allocates) (optional): return location for the minimum point + * @max: (out caller-allocates) (optional): return location for the maximum point + * + * Retrieves the coordinates of the minimum and maximum points of the + * given #graphene_box_t + * + * Since: 1.12 + */ +void +graphene_box_get_minmax (const graphene_box_t *box, + graphene_point3d_t *min, + graphene_point3d_t *max) +{ + if (min != NULL) + graphene_point3d_init_from_vec3 (min, &box->min); + if (max != NULL) + graphene_point3d_init_from_vec3 (max, &box->max); +} + /** * graphene_box_get_min: * @box: a #graphene_box_t @@ -542,7 +564,7 @@ void graphene_box_get_min (const graphene_box_t *box, graphene_point3d_t *min) { - graphene_point3d_init_from_vec3 (min, &box->min); + graphene_box_get_minmax (box, min, NULL); } /** @@ -559,7 +581,7 @@ void graphene_box_get_max (const graphene_box_t *box, graphene_point3d_t *max) { - graphene_point3d_init_from_vec3 (max, &box->max); + graphene_box_get_minmax (box, NULL, max); } /** diff --git a/tests/box.c b/tests/box.c index c104baf..3ebf9d5 100644 --- a/tests/box.c +++ b/tests/box.c @@ -42,8 +42,7 @@ box_init_min_max (mutest_spec_t *spec) NULL); graphene_box_init_from_vec3 (b, graphene_vec3_zero (), graphene_vec3_one ()); - graphene_box_get_min (b, &min); - graphene_box_get_max (b, &max); + graphene_box_get_minmax (b, &min, &max); mutest_expect ("init_from_vec3(zero, one).min() maps to point3d(zero)", mutest_bool_value (graphene_point3d_equal (&min, &zero)), mutest_to_be_true,