Make world offset calculation more accurate

Noticed that after some time groups with a parallax different than 100 were incorrectly rendered in the editor
This commit is contained in:
12pm 2019-04-03 01:05:38 +02:00
parent 1cbb800c7f
commit 4efc0e3b82
5 changed files with 22 additions and 23 deletions

View file

@ -521,7 +521,7 @@ void CHud::RenderWarmupTimer()
void CHud::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
{
float Points[4];
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX/100.0f, pGroup->m_ParallaxY/100.0f,
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY,
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
}

View file

@ -49,7 +49,7 @@ void CMapLayers::EnvelopeUpdate()
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
{
float Points[4];
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX/100.0f, pGroup->m_ParallaxY/100.0f,
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY,
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, Points);
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
}

View file

@ -17,7 +17,7 @@
void CNamePlates::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
{
float Points[4];
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX / 100.0f, pGroup->m_ParallaxY / 100.0f, pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX, pGroup->m_ParallaxY, pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), 1.0f, Points);
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
}

View file

@ -453,8 +453,8 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax
{
float Width, Height;
CalcScreenParams(1150*1000, 1500, 1050, Aspect, &Width, &Height);
CenterX *= ParallaxX;
CenterY *= ParallaxY;
CenterX *= ParallaxX/100.0f;
CenterY *= ParallaxY/100.0f;
Width *= Zoom;
Height *= Zoom;
pPoints[0] = OffsetX+CenterX-Width/2;

View file

@ -170,8 +170,7 @@ void CLayerGroup::Mapping(float *pPoints)
{
m_pMap->m_pEditor->RenderTools()->MapscreenToWorld(
m_pMap->m_pEditor->m_WorldOffsetX, m_pMap->m_pEditor->m_WorldOffsetY,
m_ParallaxX/100.0f, m_ParallaxY/100.0f,
m_OffsetX, m_OffsetY,
m_ParallaxX, m_ParallaxY, m_OffsetX, m_OffsetY,
m_pMap->m_pEditor->Graphics()->ScreenAspect(), m_pMap->m_pEditor->m_WorldZoom, pPoints);
pPoints[0] += m_pMap->m_pEditor->m_EditorOffsetX;
@ -2874,7 +2873,7 @@ void CEditor::DoMapEditor(CUIRect View)
RenderTools()->MapscreenToWorld(
m_WorldOffsetX, m_WorldOffsetY,
1.0f, 1.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
if(i == 0)
{
@ -2916,7 +2915,7 @@ void CEditor::DoMapEditor(CUIRect View)
RenderTools()->MapscreenToWorld(
m_WorldOffsetX, m_WorldOffsetY,
1.0f, 1.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
CUIRect r;
r.x = aPoints[0];
@ -5870,7 +5869,7 @@ void CEditor::ZoomMouseTarget(float ZoomFactor)
float aPoints[4];
RenderTools()->MapscreenToWorld(
m_WorldOffsetX, m_WorldOffsetY,
1.0f, 1.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);
100.0f, 100.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);
float WorldWidth = aPoints[2]-aPoints[0];
float WorldHeight = aPoints[3]-aPoints[1];