What is the global bounding rectangle? The local geometry of the entity, to which we apply the same transformations as the entity, so that it is defined in the final coordinates system.
So you need these two things:
- the local geometry of the entity is the sprite, since it's what internally composes your car entity; so the car's local bounding rect is just sprite.getLocalBounds()
- the transformations of your car entity are car.getTransform(), so the global bounds of the car can finally be computed with getTransform().transformRect(sprite.getLocalBounds()) (as already mentioned
)
If you want to mimic SFML classes, you can define these functions in your Car class:
class Car
{
public:
sf::FloatRect getLocalBounds() const {return sprite.getLocalBounds();}
sf::FloatRect getGlobalBounds() const {return getTransform().transformRect(getLocalBounds());}
};