mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Renamed GetOutlinePoint/GetOutlinePointsCount to GetPoint/GetPointsCount in sf::Shape, and made them public
This commit is contained in:
parent
e6956d8e4d
commit
048abbf46f
@ -69,15 +69,13 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetRadius() const;
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points defining the shape
|
||||
/// \brief Get the number of points of the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetOutlinePointsCount() const;
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
@ -87,7 +85,7 @@ private :
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetOutlinePoint(unsigned int index) const;
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
@ -122,6 +120,6 @@ private :
|
||||
/// window.Draw(circle);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Shape, sf::StarShape, sf::RectangleShape, sf::ConvexShape
|
||||
/// \see sf::Shape, sf::RectangleShape, sf::ConvexShape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -68,7 +68,7 @@ public :
|
||||
/// \see SetPointsCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetPointsCount() const;
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of a point
|
||||
@ -94,27 +94,7 @@ public :
|
||||
/// \see SetPoint
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f GetPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points defining the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetOutlinePointsCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
///
|
||||
/// \param index Index of the point to get
|
||||
///
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetOutlinePoint(unsigned int index) const;
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
@ -157,6 +137,6 @@ private :
|
||||
/// window.Draw(polygon);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Shape, sf::StarShape, sf::RectangleShape, sf::CircleShape
|
||||
/// \see sf::Shape, sf::RectangleShape, sf::CircleShape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -69,15 +69,13 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& GetSize() const;
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points defining the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetOutlinePointsCount() const;
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
@ -87,7 +85,7 @@ private :
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetOutlinePoint(unsigned int index) const;
|
||||
virtual Vector2f GetPoint(unsigned int index) const;
|
||||
|
||||
private :
|
||||
|
||||
@ -122,6 +120,6 @@ private :
|
||||
/// window.Draw(rectangle);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Shape, sf::StarShape, sf::CircleShape, sf::ConvexShape
|
||||
/// \see sf::Shape, sf::CircleShape, sf::ConvexShape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -184,6 +184,24 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetOutlineThickness() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total number of points of the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointsCount() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
///
|
||||
/// \param index Index of the point to get, in range [0 .. GetPointsCount() - 1]
|
||||
///
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetPoint(unsigned int index) const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the local bounding rectangle of the entity
|
||||
///
|
||||
@ -230,30 +248,6 @@ protected :
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update();
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points defining the shape
|
||||
///
|
||||
/// This function must be implemented in derived classes.
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetOutlinePointsCount() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
///
|
||||
/// This function must be implemented in derived classes.
|
||||
///
|
||||
/// \param index Index of the point to get
|
||||
///
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual Vector2f GetOutlinePoint(unsigned int index) const = 0;
|
||||
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user