Skip to content

Commit

Permalink
box: Reimplement get_bounding_sphere()
Browse files Browse the repository at this point in the history
Instead of open-coding it, we should reuse the existing Box API, so we
avoid duplicating bugs.

Fixes: #165
  • Loading branch information
ebassi committed Aug 8, 2019
1 parent dba54ec commit 21603f1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/graphene-box.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,15 @@ void
graphene_box_get_bounding_sphere (const graphene_box_t *box,
graphene_sphere_t *sphere)
{
graphene_point3d_t center;
graphene_vec3_t size;

graphene_vec3_subtract (&box->max, &box->min, &size);
graphene_box_get_center (box, &center);

graphene_vec3_scale (&size, 0.5f, &sphere->center);
sphere->radius = graphene_vec3_length (&size) * 0.5f;
graphene_box_get_size (box, &size);
float radius = graphene_vec3_length (&size) * 0.5f;

graphene_sphere_init (sphere, &center, radius);
}

enum {
Expand Down

0 comments on commit 21603f1

Please sign in to comment.