mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed divide by zero in Shape.cpp (#499)
This commit is contained in:
parent
ef1d29bf73
commit
de3ea71631
@ -240,8 +240,8 @@ void Shape::updateTexCoords()
|
||||
{
|
||||
for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
{
|
||||
float xratio = (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width;
|
||||
float yratio = (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height;
|
||||
float xratio = m_insideBounds.width > 0 ? (m_vertices[i].position.x - m_insideBounds.left) / m_insideBounds.width : 0;
|
||||
float yratio = m_insideBounds.height > 0 ? (m_vertices[i].position.y - m_insideBounds.top) / m_insideBounds.height : 0;
|
||||
m_vertices[i].texCoords.x = m_textureRect.left + m_textureRect.width * xratio;
|
||||
m_vertices[i].texCoords.y = m_textureRect.top + m_textureRect.height * yratio;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user