Heeello,
I'm using a sf::view as a camera that follows the player. The update on the different components are done in the following order:
1) The player's position might be updated in a game cicle.
2) Set the view's center to the player's position
3) Set the window's view to the updated view
4) Calculate the line of sight of the player, calculate shadows (do_FOV)
5) Draw everything
The shadows casted from the player's field of view are not draw globally. With this I mean that the shadow's RenderTexture is not as big as my map, but as my window, so the texture for the shadows has the same side of the window.
This means that in order to draw the shadows on my shadowTexture, I must also set the RenderTexture's view the same as my window:
shadowRepresentationRender.setView( engine->view );
shadowRepresentationSprite.setPosition( engine->view.getCenter().x , engine->view.getCenter().y );
//shadowRepresentationSprite's origin is set to it's center
This is done in the do_FOV function (which is executed after the view and the player's position has been updated).
The problem comes when I draw the shadows on my screen. While standing still, everything is working fine. The problem comes when the players moves. In the following screenshot I'm walking to the left:
As you can see inside the red area, it looks like the shadow's sprite is falling behind the actual movement of the player. If I walk to the right, that gap appears at the right. Same applies when moving up and down.
I have tried setting the sprite's position (and the sprite's origin) to 0,0 and then change the window's view to the defaut view, so it's back in the origin. The exact same error happens.
I think this problems comes from setting the view for the shadow's RenderTexture the same as the window view.
Anyone has any idea of what could be wrong here?