Merge pull request #1204 from cinaera/clean_rendertools

Cleanup MapScreenToGroup
This commit is contained in:
oy 2014-05-11 20:00:29 +02:00
commit bb8a180358
7 changed files with 23 additions and 36 deletions

View file

@ -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();

View file

@ -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();

View file

@ -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++)
{

View file

@ -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

View file

@ -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)

View file

@ -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);
};

View file

@ -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);