Replaced unsigned int with std::size_t for array indices/sizes
This commit is contained in:
parent
b0d6c2bea9
commit
1cfa5c6f1d
13 changed files with 51 additions and 51 deletions
|
@ -32,7 +32,7 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
CircleShape::CircleShape(float radius, unsigned int pointCount) :
|
||||
CircleShape::CircleShape(float radius, std::size_t pointCount) :
|
||||
m_radius (radius),
|
||||
m_pointCount(pointCount)
|
||||
{
|
||||
|
@ -56,21 +56,21 @@ float CircleShape::getRadius() const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void CircleShape::setPointCount(unsigned int count)
|
||||
void CircleShape::setPointCount(std::size_t count)
|
||||
{
|
||||
m_pointCount = count;
|
||||
update();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int CircleShape::getPointCount() const
|
||||
std::size_t CircleShape::getPointCount() const
|
||||
{
|
||||
return m_pointCount;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f CircleShape::getPoint(unsigned int index) const
|
||||
Vector2f CircleShape::getPoint(std::size_t index) const
|
||||
{
|
||||
static const float pi = 3.141592654f;
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
ConvexShape::ConvexShape(unsigned int pointCount)
|
||||
ConvexShape::ConvexShape(std::size_t pointCount)
|
||||
{
|
||||
setPointCount(pointCount);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void ConvexShape::setPointCount(unsigned int count)
|
||||
void ConvexShape::setPointCount(std::size_t count)
|
||||
{
|
||||
m_points.resize(count);
|
||||
update();
|
||||
|
@ -46,14 +46,14 @@ void ConvexShape::setPointCount(unsigned int count)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int ConvexShape::getPointCount() const
|
||||
std::size_t ConvexShape::getPointCount() const
|
||||
{
|
||||
return static_cast<unsigned int>(m_points.size());
|
||||
return m_points.size();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void ConvexShape::setPoint(unsigned int index, const Vector2f& point)
|
||||
void ConvexShape::setPoint(std::size_t index, const Vector2f& point)
|
||||
{
|
||||
m_points[index] = point;
|
||||
update();
|
||||
|
@ -61,7 +61,7 @@ void ConvexShape::setPoint(unsigned int index, const Vector2f& point)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvexShape::getPoint(unsigned int index) const
|
||||
Vector2f ConvexShape::getPoint(std::size_t index) const
|
||||
{
|
||||
return m_points[index];
|
||||
}
|
||||
|
|
|
@ -54,14 +54,14 @@ const Vector2f& RectangleShape::getSize() const
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int RectangleShape::getPointCount() const
|
||||
std::size_t RectangleShape::getPointCount() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f RectangleShape::getPoint(unsigned int index) const
|
||||
Vector2f RectangleShape::getPoint(std::size_t index) const
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
|
|
@ -190,7 +190,7 @@ void RenderTarget::draw(const Drawable& drawable, const RenderStates& states)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::draw(const Vertex* vertices, unsigned int vertexCount,
|
||||
void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
||||
PrimitiveType type, const RenderStates& states)
|
||||
{
|
||||
// Nothing to draw?
|
||||
|
@ -218,7 +218,7 @@ void RenderTarget::draw(const Vertex* vertices, unsigned int vertexCount,
|
|||
if (useVertexCache)
|
||||
{
|
||||
// Pre-transform the vertices and store them into the vertex cache
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
for (std::size_t i = 0; i < vertexCount; ++i)
|
||||
{
|
||||
Vertex& vertex = m_cache.vertexCache[i];
|
||||
vertex.position = states.transform * vertices[i].position;
|
||||
|
|
|
@ -175,7 +175,7 @@ m_bounds ()
|
|||
void Shape::update()
|
||||
{
|
||||
// Get the total number of points of the shape
|
||||
unsigned int count = getPointCount();
|
||||
std::size_t count = getPointCount();
|
||||
if (count < 3)
|
||||
{
|
||||
m_vertices.resize(0);
|
||||
|
@ -186,7 +186,7 @@ void Shape::update()
|
|||
m_vertices.resize(count + 2); // + 2 for center and repeated first point
|
||||
|
||||
// Position
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
m_vertices[i + 1].position = getPoint(i);
|
||||
m_vertices[count + 1].position = m_vertices[1].position;
|
||||
|
||||
|
@ -230,7 +230,7 @@ void Shape::draw(RenderTarget& target, RenderStates states) const
|
|||
////////////////////////////////////////////////////////////
|
||||
void Shape::updateFillColors()
|
||||
{
|
||||
for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
m_vertices[i].color = m_fillColor;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ void Shape::updateFillColors()
|
|||
////////////////////////////////////////////////////////////
|
||||
void Shape::updateTexCoords()
|
||||
{
|
||||
for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
{
|
||||
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;
|
||||
|
@ -251,12 +251,12 @@ void Shape::updateTexCoords()
|
|||
////////////////////////////////////////////////////////////
|
||||
void Shape::updateOutline()
|
||||
{
|
||||
unsigned int count = m_vertices.getVertexCount() - 2;
|
||||
std::size_t count = m_vertices.getVertexCount() - 2;
|
||||
m_outlineVertices.resize((count + 1) * 2);
|
||||
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
{
|
||||
unsigned int index = i + 1;
|
||||
std::size_t index = i + 1;
|
||||
|
||||
// Get the two segments shared by the current point
|
||||
Vector2f p0 = (i == 0) ? m_vertices[count].position : m_vertices[index - 1].position;
|
||||
|
@ -298,7 +298,7 @@ void Shape::updateOutline()
|
|||
////////////////////////////////////////////////////////////
|
||||
void Shape::updateOutlineColors()
|
||||
{
|
||||
for (unsigned int i = 0; i < m_outlineVertices.getVertexCount(); ++i)
|
||||
for (std::size_t i = 0; i < m_outlineVertices.getVertexCount(); ++i)
|
||||
m_outlineVertices[i].color = m_outlineColor;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ void Text::setColor(const Color& color)
|
|||
// (if geometry is updated anyway, we can skip this step)
|
||||
if (!m_geometryNeedUpdate)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
|
||||
m_vertices[i].color = m_color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ m_primitiveType(Points)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
VertexArray::VertexArray(PrimitiveType type, unsigned int vertexCount) :
|
||||
VertexArray::VertexArray(PrimitiveType type, std::size_t vertexCount) :
|
||||
m_vertices (vertexCount),
|
||||
m_primitiveType(type)
|
||||
{
|
||||
|
@ -48,21 +48,21 @@ m_primitiveType(type)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int VertexArray::getVertexCount() const
|
||||
std::size_t VertexArray::getVertexCount() const
|
||||
{
|
||||
return static_cast<unsigned int>(m_vertices.size());
|
||||
return m_vertices.size();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex& VertexArray::operator [](unsigned int index)
|
||||
Vertex& VertexArray::operator [](std::size_t index)
|
||||
{
|
||||
return m_vertices[index];
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vertex& VertexArray::operator [](unsigned int index) const
|
||||
const Vertex& VertexArray::operator [](std::size_t index) const
|
||||
{
|
||||
return m_vertices[index];
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void VertexArray::clear()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void VertexArray::resize(unsigned int vertexCount)
|
||||
void VertexArray::resize(std::size_t vertexCount)
|
||||
{
|
||||
m_vertices.resize(vertexCount);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ FloatRect VertexArray::getBounds() const
|
|||
void VertexArray::draw(RenderTarget& target, RenderStates states) const
|
||||
{
|
||||
if (!m_vertices.empty())
|
||||
target.draw(&m_vertices[0], static_cast<unsigned int>(m_vertices.size()), m_primitiveType, states);
|
||||
target.draw(&m_vertices[0], m_vertices.size(), m_primitiveType, states);
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue