Physics2D/Collider2D: Add support for neighbors vertices
This commit is contained in:
parent
f371cbb386
commit
df2a029f30
|
|
@ -213,6 +213,7 @@ Nazara Engine:
|
|||
- Added ENetPeer::GetTotalPacketSent
|
||||
- ⚠ ENetHost::GetTotalReceivedPackets now returns the number of commands received (instead of the number of UDP packets received)
|
||||
- Added EmptyStream class, useful to measure how many bytes some writing operations will take
|
||||
- SegmentCollider2D: Add support for neighbors (aka "ghost vertices"), allowing to prevent seams collisions
|
||||
|
||||
Nazara Development Kit:
|
||||
- Added ImageWidget (#139)
|
||||
|
|
|
|||
|
|
@ -230,13 +230,16 @@ namespace Nz
|
|||
{
|
||||
public:
|
||||
inline SegmentCollider2D(const Vector2f& first, const Vector2f& second, float thickness = 1.f);
|
||||
inline SegmentCollider2D(const Vector2f& first, const Vector2f& firstNeighbor, const Vector2f& second, const Vector2f& secondNeighbor, float thickness = 1.f);
|
||||
|
||||
Nz::Vector2f ComputeCenterOfMass() const override;
|
||||
float ComputeMomentOfInertia(float mass) const override;
|
||||
|
||||
inline const Vector2f& GetFirstPoint() const;
|
||||
inline const Vector2f& GetFirstPointNeighbor() const;
|
||||
inline float GetLength() const;
|
||||
inline const Vector2f& GetSecondPoint() const;
|
||||
inline const Vector2f& GetSecondPointNeighbor() const;
|
||||
inline float GetThickness() const;
|
||||
ColliderType2D GetType() const override;
|
||||
|
||||
|
|
@ -246,7 +249,9 @@ namespace Nz
|
|||
std::size_t CreateShapes(RigidBody2D* body, std::vector<cpShape*>* shapes) const override;
|
||||
|
||||
Vector2f m_first;
|
||||
Vector2f m_firstNeighbor;
|
||||
Vector2f m_second;
|
||||
Vector2f m_secondNeighbor;
|
||||
float m_thickness;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,8 +191,15 @@ namespace Nz
|
|||
}
|
||||
|
||||
SegmentCollider2D::SegmentCollider2D(const Vector2f& first, const Vector2f& second, float thickness) :
|
||||
SegmentCollider2D(first, first, second, second, thickness)
|
||||
{
|
||||
}
|
||||
|
||||
inline SegmentCollider2D::SegmentCollider2D(const Vector2f& first, const Vector2f& firstNeighbor, const Vector2f& second, const Vector2f& secondNeighbor, float thickness) :
|
||||
m_first(first),
|
||||
m_firstNeighbor(firstNeighbor),
|
||||
m_second(second),
|
||||
m_secondNeighbor(secondNeighbor),
|
||||
m_thickness(thickness)
|
||||
{
|
||||
}
|
||||
|
|
@ -202,6 +209,11 @@ namespace Nz
|
|||
return m_first;
|
||||
}
|
||||
|
||||
inline const Vector2f& SegmentCollider2D::GetFirstPointNeighbor() const
|
||||
{
|
||||
return m_firstNeighbor;
|
||||
}
|
||||
|
||||
inline float SegmentCollider2D::GetLength() const
|
||||
{
|
||||
return m_first.Distance(m_second);
|
||||
|
|
@ -212,6 +224,11 @@ namespace Nz
|
|||
return m_second;
|
||||
}
|
||||
|
||||
inline const Vector2f& SegmentCollider2D::GetSecondPointNeighbor() const
|
||||
{
|
||||
return m_secondNeighbor;
|
||||
}
|
||||
|
||||
inline float SegmentCollider2D::GetThickness() const
|
||||
{
|
||||
return m_thickness;
|
||||
|
|
|
|||
|
|
@ -298,7 +298,10 @@ namespace Nz
|
|||
|
||||
std::size_t SegmentCollider2D::CreateShapes(RigidBody2D* body, std::vector<cpShape*>* shapes) const
|
||||
{
|
||||
shapes->push_back(cpSegmentShapeNew(body->GetHandle(), cpv(m_first.x, m_first.y), cpv(m_second.x, m_second.y), m_thickness));
|
||||
cpShape* segment = cpSegmentShapeNew(body->GetHandle(), cpv(m_first.x, m_first.y), cpv(m_second.x, m_second.y), m_thickness);
|
||||
cpSegmentShapeSetNeighbors(segment, cpv(m_firstNeighbor.x, m_firstNeighbor.y), cpv(m_secondNeighbor.x, m_secondNeighbor.y));
|
||||
|
||||
shapes->push_back(segment);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue