mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Add EdgeShape:set/getNext/PreviousVertex. ChainShape:setNext/PreviousVertex can now take no arguments to disable ghost vertices.
Resolves issue #1191.
This commit is contained in:
@@ -55,6 +55,12 @@ void ChainShape::setNextVertex(float x, float y)
|
||||
c->SetNextVertex(Physics::scaleDown(v));
|
||||
}
|
||||
|
||||
void ChainShape::setNextVertex()
|
||||
{
|
||||
b2ChainShape *c = (b2ChainShape *)shape;
|
||||
c->m_hasNextVertex = false;
|
||||
}
|
||||
|
||||
void ChainShape::setPreviousVertex(float x, float y)
|
||||
{
|
||||
if (loop)
|
||||
@@ -67,30 +73,40 @@ void ChainShape::setPreviousVertex(float x, float y)
|
||||
c->SetPrevVertex(Physics::scaleDown(v));
|
||||
}
|
||||
|
||||
bool ChainShape::hasNextVertex() const
|
||||
void ChainShape::setPreviousVertex()
|
||||
{
|
||||
b2ChainShape *c = (b2ChainShape *)shape;
|
||||
return c->m_hasNextVertex;
|
||||
c->m_hasPrevVertex = false;
|
||||
}
|
||||
|
||||
bool ChainShape::hasPreviousVertex() const
|
||||
bool ChainShape::getNextVertex(float &x, float &y) const
|
||||
{
|
||||
b2ChainShape *c = (b2ChainShape *)shape;
|
||||
return c->m_hasPrevVertex;
|
||||
|
||||
if (c->m_hasNextVertex)
|
||||
{
|
||||
b2Vec2 v = Physics::scaleUp(c->m_nextVertex);
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
b2Vec2 ChainShape::getNextVertex() const
|
||||
bool ChainShape::getPreviousVertex(float &x, float &y) const
|
||||
{
|
||||
b2ChainShape *c = (b2ChainShape *)shape;
|
||||
const b2Vec2 &v = c->m_nextVertex;
|
||||
return Physics::scaleUp(v);
|
||||
}
|
||||
|
||||
b2Vec2 ChainShape::getPreviousVertex() const
|
||||
{
|
||||
b2ChainShape *c = (b2ChainShape *)shape;
|
||||
const b2Vec2 &v = c->m_prevVertex;
|
||||
return Physics::scaleUp(v);
|
||||
if (c->m_hasPrevVertex)
|
||||
{
|
||||
b2Vec2 v = Physics::scaleUp(c->m_prevVertex);
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EdgeShape *ChainShape::getChildEdge(int index) const
|
||||
|
||||
Reference in New Issue
Block a user