In the current implementation of mapPixelToCoords it requires a RenderTarget to call.
I have a function handleEvent(sf::event e) which will have information about the relevant view for the object that calls it but not the RenderTarget so I can't call mapPixelToCoords even though I'd like to check for a specific position within a vertex array.
Based on the current implementation it doesn't appear that any member of RenderTarget is needed to perform the calculation:
FloatRect viewport --> Defined from view parameter
normalized --> Defined from parameter point & parameter view
Calculation calls member functions of the view.
Based on this would it make sense to allow for views to directly call this helper function without a RenderTarget object either as a member of view or static call to RenderTarget? If not the context would probably benefit my personal thought process
.
Vector2f RenderTarget::mapPixelToCoords(const Vector2i& point, const View& view) const
{
// First, convert from viewport coordinates to homogeneous coordinates
Vector2f normalized;
FloatRect viewport = FloatRect(getViewport(view));
normalized.x = -1.f + 2.f * (static_cast<float>(point.x) - viewport.left) / viewport.width;
normalized.y = 1.f - 2.f * (static_cast<float>(point.y) - viewport.top) / viewport.height;
// Then transform by the inverse of the view matrix
return view.getInverseTransform().transformPoint(normalized);
}