From 2fcb898f5f754179cf95dfc5f9dfeaefcbb95712 Mon Sep 17 00:00:00 2001 From: BeaR Date: Tue, 11 Mar 2014 10:24:37 +0100 Subject: [PATCH] Remove redundant MapScreenToGroup() and declarate it in RenderTools --- src/game/client/components/hud.cpp | 10 +--------- src/game/client/components/hud.h | 2 -- src/game/client/components/maplayers.cpp | 15 ++------------- src/game/client/components/maplayers.h | 1 - src/game/client/render.cpp | 20 ++++++++++++++------ src/game/client/render.h | 5 +++-- src/game/editor/editor.cpp | 6 +++--- 7 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 9772abb83..21adf24a4 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -374,14 +374,6 @@ void CHud::RenderWarmupTimer() m_WarmupHideTick = 0; } -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, - pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), m_pClient->m_pCamera->m_Zoom, Points); - Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]); -} - void CHud::RenderFps() { if(g_Config.m_ClShowfps) @@ -472,7 +464,7 @@ void CHud::RenderCursor() if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; - MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); + RenderTools()->MapScreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup(), m_pClient->m_pCamera->m_Zoom); Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); diff --git a/src/game/client/components/hud.h b/src/game/client/components/hud.h index 7fc3df598..e069758ba 100644 --- a/src/game/client/components/hud.h +++ b/src/game/client/components/hud.h @@ -25,8 +25,6 @@ class CHud : public CComponent void RenderScoreHud(); void RenderSpectatorHud(); void RenderWarmupTimer(); - - void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup); public: CHud(); diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index f7b56035d..f5dd0fa75 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -64,15 +64,6 @@ void CMapLayers::EnvelopeUpdate() } } - -void CMapLayers::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(), m_pClient->m_pCamera->m_Zoom, Points); - Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]); -} - void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser) { CMapLayers *pThis = (CMapLayers *)pUser; @@ -165,8 +156,6 @@ void CMapLayers::OnRender() Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h); vec2 Center = m_pClient->m_pCamera->m_Center; - //float center_x = gameclient.camera->center.x; - //float center_y = gameclient.camera->center.y; bool PassedGameLayer = false; @@ -178,7 +167,7 @@ void CMapLayers::OnRender() { // set clipping float Points[4]; - MapScreenToGroup(Center.x, Center.y, pLayers->GameGroup()); + RenderTools()->MapScreenToGroup(Center.x, Center.y, pLayers->GameGroup(), m_pClient->m_pCamera->m_Zoom); Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]); float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]); float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]); @@ -189,7 +178,7 @@ void CMapLayers::OnRender() (int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight())); } - MapScreenToGroup(Center.x, Center.y, pGroup); + RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, m_pClient->m_pCamera->m_Zoom); for(int l = 0; l < pGroup->m_NumLayers; l++) { diff --git a/src/game/client/components/maplayers.h b/src/game/client/components/maplayers.h index a026b0cb7..f9be38595 100644 --- a/src/game/client/components/maplayers.h +++ b/src/game/client/components/maplayers.h @@ -14,7 +14,6 @@ class CMapLayers : public CComponent int m_LastLocalTick; bool m_EnvelopeUpdate; - void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup); static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser); public: enum diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 29b1e37c7..04f18dc24 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -521,8 +521,8 @@ static void CalcScreenParams(float Amount, float WMax, float HMax, float Aspect, } } -void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, - float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints) +void CRenderTools::MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, + float OffsetX, float OffsetY, float Aspect, float Zoom, float aPoints[4]) { float Width, Height; CalcScreenParams(1150*1000, 1500, 1050, Aspect, &Width, &Height); @@ -530,10 +530,18 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax CenterY *= ParallaxY; Width *= Zoom; Height *= Zoom; - pPoints[0] = OffsetX+CenterX-Width/2; - pPoints[1] = OffsetY+CenterY-Height/2; - pPoints[2] = pPoints[0]+Width; - pPoints[3] = pPoints[1]+Height; + aPoints[0] = OffsetX+CenterX-Width/2; + aPoints[1] = OffsetY+CenterY-Height/2; + aPoints[2] = aPoints[0]+Width; + aPoints[3] = aPoints[1]+Height; +} + +void CRenderTools::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom) +{ + float aPoints[4]; + MapScreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX/100.0f, pGroup->m_ParallaxY/100.0f, + pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, aPoints); + Graphics()->MapScreen(aPoints[0], aPoints[1], aPoints[2], aPoints[3]); } void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers) diff --git a/src/game/client/render.h b/src/game/client/render.h index 9c46c4ccd..2aef65df1 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -75,8 +75,9 @@ public: void RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 Color, int RenderFlags, ENVELOPE_EVAL pfnEval, void *pUser, int ColorEnv, int ColorEnvOffset); // helpers - void MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, - float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints); + void MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, + float OffsetX, float OffsetY, float Aspect, float Zoom, float aPoints[4]); + void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom); }; diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 0bbcdaf7c..25bbc298f 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -77,7 +77,7 @@ void CLayerGroup::Convert(CUIRect *pRect) void CLayerGroup::Mapping(float *pPoints) { - m_pMap->m_pEditor->RenderTools()->MapscreenToWorld( + 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, @@ -2115,7 +2115,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) float aPoints[4]; float Aspect = Start + (End-Start)*(i/(float)NumSteps); - RenderTools()->MapscreenToWorld( + RenderTools()->MapScreenToWorld( m_WorldOffsetX, m_WorldOffsetY, 1.0f, 1.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints); @@ -2157,7 +2157,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) float aAspects[] = {4.0f/3.0f, 16.0f/10.0f, 5.0f/4.0f, 16.0f/9.0f}; float Aspect = aAspects[i]; - RenderTools()->MapscreenToWorld( + RenderTools()->MapScreenToWorld( m_WorldOffsetX, m_WorldOffsetY, 1.0f, 1.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);