diff --git a/include/bounce/collision/shapes/aabb3.h b/include/bounce/collision/shapes/aabb3.h index 09ffb2c..51ba36e 100644 --- a/include/bounce/collision/shapes/aabb3.h +++ b/include/bounce/collision/shapes/aabb3.h @@ -37,8 +37,8 @@ struct b3AABB3 return support; } - // Compute this AABB from a list of points. - void Compute(const b3Vec3* points, u32 count) + // Set this AABB from a list of points. + void Set(const b3Vec3* points, u32 count) { m_lower = m_upper = points[0]; for (u32 i = 1; i < count; ++i) @@ -48,8 +48,8 @@ struct b3AABB3 } } - // Compute this AABB from a list of points and a transform. - void Compute(const b3Vec3* points, u32 count, const b3Transform& xf) + // Set this AABB from a list of points and a transform. + void Set(const b3Vec3* points, u32 count, const b3Transform& xf) { m_lower = m_upper = b3Mul(xf, points[0]); for (u32 i = 1; i < count; ++i) @@ -60,6 +60,13 @@ struct b3AABB3 } } + // Set this AABB from a triangle. + void Set(const b3Vec3& v1, const b3Vec3& v2, const b3Vec3& v3) + { + m_lower = b3Min(v1, b3Min(v2, v3)); + m_upper = b3Max(v1, b3Max(v2, v3)); + } + // Set this AABB from a center point and a radius vector. void Set(const b3Vec3& center, const b3Vec3& r) { diff --git a/src/bounce/dynamics/shapes/hull_shape.cpp b/src/bounce/dynamics/shapes/hull_shape.cpp index 78da7bc..81be848 100644 --- a/src/bounce/dynamics/shapes/hull_shape.cpp +++ b/src/bounce/dynamics/shapes/hull_shape.cpp @@ -161,7 +161,7 @@ void b3HullShape::ComputeMass(b3MassData* massData, float32 density) const void b3HullShape::ComputeAABB(b3AABB3* aabb, const b3Transform& xf) const { - aabb->Compute(m_hull->vertices, m_hull->vertexCount, xf); + aabb->Set(m_hull->vertices, m_hull->vertexCount, xf); aabb->Extend(m_radius); } diff --git a/src/bounce/dynamics/shapes/mesh_shape.cpp b/src/bounce/dynamics/shapes/mesh_shape.cpp index 88f3f3d..55724e6 100644 --- a/src/bounce/dynamics/shapes/mesh_shape.cpp +++ b/src/bounce/dynamics/shapes/mesh_shape.cpp @@ -56,7 +56,7 @@ void b3MeshShape::ComputeMass(b3MassData* massData, float32 density) const void b3MeshShape::ComputeAABB(b3AABB3* output, const b3Transform& xf) const { - output->Compute(m_mesh->vertices, m_mesh->vertexCount, xf); + output->Set(m_mesh->vertices, m_mesh->vertexCount, xf); output->Extend(m_radius); }