Fix wrong aabb returned from PhysicsComponent2D (#127)
This commit is contained in:
committed by
Jérôme Leclercq
parent
6ff510ad4a
commit
47a22c2785
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user