Physics2D/Collider2D: Allow to prevent individual colliders properties override
This commit is contained in:
@@ -13,11 +13,10 @@ namespace Nz
|
||||
|
||||
std::vector<cpShape*> Collider2D::GenerateShapes(RigidBody2D* body) const
|
||||
{
|
||||
cpShapeFilter filter = cpShapeFilterNew(m_collisionGroup, m_categoryMask, m_collisionMask);
|
||||
|
||||
std::vector<cpShape*> shapes;
|
||||
CreateShapes(body, shapes);
|
||||
|
||||
cpShapeFilter filter = cpShapeFilterNew(m_collisionGroup, m_categoryMask, m_collisionMask);
|
||||
for (cpShape* shape : shapes)
|
||||
{
|
||||
cpShapeSetFilter(shape, filter);
|
||||
@@ -82,7 +81,8 @@ namespace Nz
|
||||
/******************************** CompoundCollider2D *********************************/
|
||||
|
||||
CompoundCollider2D::CompoundCollider2D(std::vector<Collider2DRef> geoms) :
|
||||
m_geoms(std::move(geoms))
|
||||
m_geoms(std::move(geoms)),
|
||||
m_doesOverrideCollisionProperties(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -109,6 +109,20 @@ namespace Nz
|
||||
geom->CreateShapes(body, shapes);
|
||||
}
|
||||
|
||||
std::vector<cpShape*> CompoundCollider2D::GenerateShapes(RigidBody2D* body) const
|
||||
{
|
||||
// This is our parent's default behavior
|
||||
if (m_doesOverrideCollisionProperties)
|
||||
return Collider2D::GenerateShapes(body);
|
||||
else
|
||||
{
|
||||
std::vector<cpShape*> shapes;
|
||||
CreateShapes(body, shapes);
|
||||
|
||||
return shapes;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** ConvexCollider2D *********************************/
|
||||
|
||||
ConvexCollider2D::ConvexCollider2D(SparsePtr<const Vector2f> vertices, std::size_t vertexCount, float radius) :
|
||||
|
||||
Reference in New Issue
Block a user