Move MapScreenToGroup from 3 classes to render.cpp; Rename MapscreenToWorld to MapScreenToWorld

This commit is contained in:
c0d3d3v 2022-05-17 15:00:06 +02:00
parent b751a2e098
commit 87893ceca7
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
9 changed files with 21 additions and 42 deletions

View file

@ -519,14 +519,6 @@ void CHud::RenderWarmupTimer()
} }
} }
void CHud::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
{
float Points[4];
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]);
}
void CHud::RenderTextInfo() void CHud::RenderTextInfo()
{ {
if(g_Config.m_ClShowfps) if(g_Config.m_ClShowfps)
@ -660,7 +652,7 @@ void CHud::RenderCursor()
if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK) if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK)
return; return;
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
// render cursor // render cursor
int CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS; int CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS;

View file

@ -65,10 +65,7 @@ class CHud : public CComponent
void RenderWarmupTimer(); void RenderWarmupTimer();
void RenderLocalTime(float x); void RenderLocalTime(float x);
void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup);
static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f; static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f;
public: public:
CHud(); CHud();
virtual int Sizeof() const override { return sizeof(*this); } virtual int Sizeof() const override { return sizeof(*this); }

View file

@ -55,14 +55,6 @@ void CMapLayers::EnvelopeUpdate()
} }
} }
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
{
float Points[4];
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]);
}
void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, float *pChannels, void *pUser) void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, float *pChannels, void *pUser)
{ {
CMapLayers *pThis = (CMapLayers *)pUser; CMapLayers *pThis = (CMapLayers *)pUser;
@ -1567,7 +1559,7 @@ void CMapLayers::OnRender()
{ {
// set clipping // set clipping
float Points[4]; float Points[4];
MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), GetCurCamera()->m_Zoom); RenderTools()->MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), GetCurCamera()->m_Zoom);
Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]); Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2] - Points[0]); float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2] - Points[0]);
float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3] - Points[1]); float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3] - Points[1]);
@ -1587,10 +1579,10 @@ void CMapLayers::OnRender()
if((!g_Config.m_ClZoomBackgroundLayers || m_Type == TYPE_FULL_DESIGN) && !pGroup->m_ParallaxX && !pGroup->m_ParallaxY) if((!g_Config.m_ClZoomBackgroundLayers || m_Type == TYPE_FULL_DESIGN) && !pGroup->m_ParallaxX && !pGroup->m_ParallaxY)
{ {
MapScreenToGroup(Center.x, Center.y, pGroup, 1.0f); RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, 1.0f);
} }
else else
MapScreenToGroup(Center.x, Center.y, pGroup, GetCurCamera()->m_Zoom); RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, GetCurCamera()->m_Zoom);
for(int l = 0; l < pGroup->m_NumLayers; l++) for(int l = 0; l < pGroup->m_NumLayers; l++)
{ {

View file

@ -35,8 +35,6 @@ class CMapLayers : public CComponent
bool m_OnlineOnly; bool m_OnlineOnly;
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom = 1.0f);
struct STileLayerVisuals struct STileLayerVisuals
{ {
STileLayerVisuals() : STileLayerVisuals() :

View file

@ -14,13 +14,6 @@
#include "players.h" #include "players.h"
void CNamePlates::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
{
float Points[4];
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]);
}
void CNamePlates::RenderNameplate( void CNamePlates::RenderNameplate(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
@ -109,7 +102,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
// create nameplates at standard zoom // create nameplates at standard zoom
float ScreenX0, ScreenY0, ScreenX1, ScreenY1; float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1, -1.0f); m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1, -1.0f);
@ -135,7 +128,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
// create nameplates at standard zoom // create nameplates at standard zoom
float ScreenX0, ScreenY0, ScreenX1, ScreenY1; float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); RenderTools()->MapScreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup());
m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1, -1.0f); m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1, -1.0f);

View file

@ -37,8 +37,6 @@ struct SPlayerNamePlate
class CNamePlates : public CComponent class CNamePlates : public CComponent
{ {
void MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup);
void RenderNameplate( void RenderNameplate(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,

View file

@ -752,7 +752,7 @@ void CRenderTools::CalcScreenParams(float Aspect, float Zoom, float *w, float *h
*h *= Zoom; *h *= Zoom;
} }
void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, void CRenderTools::MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints) float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints)
{ {
float Width, Height; float Width, Height;
@ -764,3 +764,11 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax
pPoints[2] = pPoints[0] + Width; pPoints[2] = pPoints[0] + Width;
pPoints[3] = pPoints[1] + Height; pPoints[3] = pPoints[1] + Height;
} }
void CRenderTools::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
{
float Points[4];
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

@ -119,8 +119,9 @@ public:
// helpers // helpers
void CalcScreenParams(float Aspect, float Zoom, float *w, float *h); void CalcScreenParams(float Aspect, float Zoom, float *w, float *h);
void MapscreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, void MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints); float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints);
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom = 1.0f);
// DDRace // DDRace

View file

@ -128,7 +128,7 @@ void CLayerGroup::Convert(CUIRect *pRect)
void CLayerGroup::Mapping(float *pPoints) 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_pMap->m_pEditor->m_WorldOffsetX, m_pMap->m_pEditor->m_WorldOffsetY,
m_ParallaxX, m_ParallaxY, 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); m_pMap->m_pEditor->Graphics()->ScreenAspect(), m_pMap->m_pEditor->m_WorldZoom, pPoints);
@ -2864,7 +2864,7 @@ void CEditor::DoMapEditor(CUIRect View)
float aPoints[4]; float aPoints[4];
float Aspect = Start + (End - Start) * (i / (float)NumSteps); float Aspect = Start + (End - Start) * (i / (float)NumSteps);
RenderTools()->MapscreenToWorld( RenderTools()->MapScreenToWorld(
m_WorldOffsetX, m_WorldOffsetY, m_WorldOffsetX, m_WorldOffsetY,
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints); 100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
@ -2906,7 +2906,7 @@ void CEditor::DoMapEditor(CUIRect View)
float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f}; float aAspects[] = {4.0f / 3.0f, 16.0f / 10.0f, 5.0f / 4.0f, 16.0f / 9.0f};
float Aspect = aAspects[i]; float Aspect = aAspects[i];
RenderTools()->MapscreenToWorld( RenderTools()->MapScreenToWorld(
m_WorldOffsetX, m_WorldOffsetY, m_WorldOffsetX, m_WorldOffsetY,
100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints); 100.0f, 100.0f, 0.0f, 0.0f, Aspect, 1.0f, aPoints);
@ -6156,7 +6156,7 @@ void CEditor::ZoomMouseTarget(float ZoomFactor)
// zoom to the current mouse position // zoom to the current mouse position
// get absolute mouse position // get absolute mouse position
float aPoints[4]; float aPoints[4];
RenderTools()->MapscreenToWorld( RenderTools()->MapScreenToWorld(
m_WorldOffsetX, m_WorldOffsetY, m_WorldOffsetX, m_WorldOffsetY,
100.0f, 100.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints); 100.0f, 100.0f, 0.0f, 0.0f, Graphics()->ScreenAspect(), m_WorldZoom, aPoints);