Renamed GetOutlinePoint/GetOutlinePointsCount to GetPoint/GetPointsCount in sf::Shape, and made them public

This commit is contained in:
Laurent Gomila 2011-12-10 14:51:40 +01:00
parent e6956d8e4d
commit 048abbf46f
8 changed files with 35 additions and 80 deletions

View file

@ -54,16 +54,16 @@ float CircleShape::GetRadius() const
////////////////////////////////////////////////////////////
unsigned int CircleShape::GetOutlinePointsCount() const
unsigned int CircleShape::GetPointsCount() const
{
return 30;
}
////////////////////////////////////////////////////////////
Vector2f CircleShape::GetOutlinePoint(unsigned int index) const
Vector2f CircleShape::GetPoint(unsigned int index) const
{
float angle = index * 2 * 3.141592654f / GetOutlinePointsCount();
float angle = index * 2 * 3.141592654f / GetPointsCount();
float x = std::cos(angle) * myRadius;
float y = std::sin(angle) * myRadius;

View file

@ -66,18 +66,4 @@ Vector2f ConvexShape::GetPoint(unsigned int index) const
return myPoints[index];
}
////////////////////////////////////////////////////////////
unsigned int ConvexShape::GetOutlinePointsCount() const
{
return GetPointsCount();
}
////////////////////////////////////////////////////////////
Vector2f ConvexShape::GetOutlinePoint(unsigned int index) const
{
return GetPoint(index);
}
} // namespace sf

View file

@ -54,14 +54,14 @@ const Vector2f& RectangleShape::GetSize() const
////////////////////////////////////////////////////////////
unsigned int RectangleShape::GetOutlinePointsCount() const
unsigned int RectangleShape::GetPointsCount() const
{
return 4;
}
////////////////////////////////////////////////////////////
Vector2f RectangleShape::GetOutlinePoint(unsigned int index) const
Vector2f RectangleShape::GetPoint(unsigned int index) const
{
switch (index)
{

View file

@ -169,7 +169,7 @@ myBounds ()
void Shape::Update()
{
// Get the total number of points of the shape
unsigned int count = GetOutlinePointsCount();
unsigned int count = GetPointsCount();
if (count < 3)
{
myVertices.Resize(0);
@ -180,9 +180,8 @@ void Shape::Update()
myVertices.Resize(count + 2); // + 2 for center and repeated first point
// Position
Vector2f offset(myOutlineThickness, myOutlineThickness);
for (unsigned int i = 0; i < count; ++i)
myVertices[i + 1].Position = GetOutlinePoint(i) + offset;
myVertices[i + 1].Position = GetPoint(i);
myVertices[count + 1].Position = myVertices[1].Position;
// Update the bounding rectangle