mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
1cbb800c7f
commit
4efc0e3b82
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue