Fix bug in occulted centering logic.
This commit is contained in:
parent
0821f1ac11
commit
43be58a1ea
|
@ -633,9 +633,7 @@ void VIEW::SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOX2D occultedRect = screenRect.Intersect( occultingScreenRect );
|
BOX2D occultedRect = screenRect.Intersect( occultingScreenRect );
|
||||||
VECTOR2D offset( occultedRect.GetWidth() / 2, occultedRect.GetHeight() / 2 );
|
|
||||||
|
|
||||||
double topExposed = occultedRect.GetTop() - screenRect.GetTop();
|
double topExposed = occultedRect.GetTop() - screenRect.GetTop();
|
||||||
double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom();
|
double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom();
|
||||||
double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft();
|
double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft();
|
||||||
|
@ -644,16 +642,16 @@ void VIEW::SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect )
|
||||||
if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) )
|
if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) )
|
||||||
{
|
{
|
||||||
if( topExposed > bottomExposed )
|
if( topExposed > bottomExposed )
|
||||||
aCenter.y += ToWorld( occultedRect.GetHeight() / 2 );
|
aCenter.y += ToWorld( screenRect.GetHeight() / 2 - topExposed / 2 );
|
||||||
else
|
else
|
||||||
aCenter.y -= ToWorld( occultedRect.GetHeight() / 2 );
|
aCenter.y -= ToWorld( screenRect.GetHeight() / 2 - bottomExposed / 2 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( leftExposed > rightExposed )
|
if( leftExposed > rightExposed )
|
||||||
aCenter.x += ToWorld( occultedRect.GetWidth() / 2 );
|
aCenter.x += ToWorld( screenRect.GetWidth() / 2 - leftExposed / 2 );
|
||||||
else
|
else
|
||||||
aCenter.x -= ToWorld( occultedRect.GetWidth() / 2 );
|
aCenter.x -= ToWorld( screenRect.GetWidth() / 2 - rightExposed / 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCenter( aCenter );
|
SetCenter( aCenter );
|
||||||
|
|
Loading…
Reference in New Issue