Here it's a very special case when the points are really close, but it could just be my math for calculating the points that are stupid, I don't know, though it doesn't show without the outline.
If you move the mouse towards one of the corners of the window it should show when the points become more or less parallel. I guess that's why the outline fuck up?
#include <SFML/Graphics.hpp>
#define SIZE 16.f
#define HALF_SIZE 16.f / 2.f
int main()
{
sf::RenderWindow window( sf::VideoMode( 800, 600 ), "Test" );
sf::Event event;
sf::ConvexShape shape;
shape.SetFillColor( sf::Color::White );
shape.SetOutlineColor( sf::Color::Red );
shape.SetOutlineThickness( 1 );
shape.SetPointsCount( 4 );
shape.SetPosition( 400, 300 );
sf::Vector2f position;
sf::Vector2f camera(0,0);
while( window.IsOpened() == true )
{
camera = static_cast< sf::Vector2f >( sf::Mouse::GetPosition() );
sf::Vector2f movement;
movement.x = ( 34 * SIZE - camera.x ) / SIZE;
movement.y = ( 34 * SIZE - camera.y ) / SIZE;
position = sf::Vector2f( -HALF_SIZE, 0 );
shape.SetPoint( 0, position );
position = sf::Vector2f( HALF_SIZE, 0 );
shape.SetPoint( 1, position );
position = sf::Vector2f( HALF_SIZE, 0 );
position.x += movement.x;
position.y += movement.y;
shape.SetPoint( 2, position );
position = sf::Vector2f( -HALF_SIZE, 0 );
position.x += movement.x;
position.y += movement.y;
shape.SetPoint( 3, position );
window.Clear();
window.Draw( shape );
window.Display();
while( window.PollEvent( event ) == true )
{
if( event.Type == sf::Event::Closed )
{
window.Close();
break;
}
}
}
return 0;
}
This problem was on the previous API as well but I just ignored it and thought that my point calculation fucked up. But seeing how it appears to be when the points are aligned is when it fucks up. I don't even know if it's possible for you to handle that case in your code.
And still, it can be that it's just my point calculations that go haywire?
Update: Checked the exact positions of the points when given to the shape, they are as follow when the camera vector is 872x545
0# -8x0
1# 8x0
2# -12x-0.0625
3# 0x0
So they are ALMOST parallel and no values are "wrong"