Fix wrong aabb returned from PhysicsComponent2D (#127)

This commit is contained in:
Gawaboumga
2017-06-20 06:53:39 +02:00
committed by Jérôme Leclercq
parent 6ff510ad4a
commit 47a22c2785
3 changed files with 42 additions and 5 deletions

View File

@@ -121,11 +121,14 @@ namespace Nz
Rectf RigidBody2D::GetAABB() const
{
cpBB bb = cpBBNew(0.f, 0.f, 0.f, 0.f);
for (cpShape* shape : m_shapes)
bb = cpBBMerge(bb, cpShapeGetBB(shape));
if (m_shapes.empty())
return Rectf::Zero();
return Rectf(Rect<cpFloat>(bb.l, bb.t, bb.r - bb.l, bb.b - bb.t));
cpBB bb = cpShapeGetBB(*m_shapes.begin());
for (auto it = ++m_shapes.begin(); it != m_shapes.end(); ++it)
bb = cpBBMerge(bb, cpShapeGetBB(*it));
return Rectf(Rect<cpFloat>(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b));
}
float RigidBody2D::GetAngularVelocity() const