RenderTarget::convertCoords now takes a Vector2i argument
This commit is contained in:
parent
74f9388f31
commit
859074b3cc
@ -144,13 +144,12 @@ public :
|
|||||||
/// This version uses the current view of the render target.
|
/// This version uses the current view of the render target.
|
||||||
/// See the other overload to specify a custom view.
|
/// See the other overload to specify a custom view.
|
||||||
///
|
///
|
||||||
/// \param x X coordinate of the point to convert, relative to the render target
|
/// \param point Point to convert, relative to the render target
|
||||||
/// \param y Y coordinate of the point to convert, relative to the render target
|
|
||||||
///
|
///
|
||||||
/// \return The converted point, in "world" units
|
/// \return The converted point, in "world" units
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f convertCoords(unsigned int x, unsigned int y) const;
|
Vector2f convertCoords(const Vector2i& point) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Convert a point from target coordinates to view coordinates
|
/// \brief Convert a point from target coordinates to view coordinates
|
||||||
@ -169,14 +168,13 @@ public :
|
|||||||
/// overload of the function to use the current view of the render
|
/// overload of the function to use the current view of the render
|
||||||
/// target.
|
/// target.
|
||||||
///
|
///
|
||||||
/// \param x X coordinate of the point to convert, relative to the render target
|
/// \param point Point to convert, relative to the render target
|
||||||
/// \param y Y coordinate of the point to convert, relative to the render target
|
|
||||||
/// \param view The view to use for converting the point
|
/// \param view The view to use for converting the point
|
||||||
///
|
///
|
||||||
/// \return The converted point, in "world" units
|
/// \return The converted point, in "world" units
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f convertCoords(unsigned int x, unsigned int y, const View& view) const;
|
Vector2f convertCoords(const Vector2i& point, const View& view) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw a drawable object to the render-target
|
/// \brief Draw a drawable object to the render-target
|
||||||
|
@ -100,20 +100,20 @@ IntRect RenderTarget::getViewport(const View& view) const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f RenderTarget::convertCoords(unsigned int x, unsigned int y) const
|
Vector2f RenderTarget::convertCoords(const Vector2i& point) const
|
||||||
{
|
{
|
||||||
return convertCoords(x, y, getView());
|
return convertCoords(point, getView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2f RenderTarget::convertCoords(unsigned int x, unsigned int y, const View& view) const
|
Vector2f RenderTarget::convertCoords(const Vector2i& point, const View& view) const
|
||||||
{
|
{
|
||||||
// First, convert from viewport coordinates to homogeneous coordinates
|
// First, convert from viewport coordinates to homogeneous coordinates
|
||||||
Vector2f coords;
|
Vector2f coords;
|
||||||
IntRect viewport = getViewport(view);
|
IntRect viewport = getViewport(view);
|
||||||
coords.x = -1.f + 2.f * (static_cast<int>(x) - viewport.left) / viewport.width;
|
coords.x = -1.f + 2.f * (point.x - viewport.left) / viewport.width;
|
||||||
coords.y = 1.f - 2.f * (static_cast<int>(y) - viewport.top) / viewport.height;
|
coords.y = 1.f - 2.f * (point.y - viewport.top) / viewport.height;
|
||||||
|
|
||||||
// Then transform by the inverse of the view matrix
|
// Then transform by the inverse of the view matrix
|
||||||
return view.getInverseTransform().transformPoint(coords);
|
return view.getInverseTransform().transformPoint(coords);
|
||||||
|
Loading…
Reference in New Issue
Block a user