diff options
| author | oy <Tom_Adams@web.de> | 2010-08-05 20:55:51 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-08-05 20:55:51 +0200 |
| commit | 05f3757491abbca38dd789574951d46c28ce746c (patch) | |
| tree | 9b392769b6c3c0878749ea488e75160a4a20e176 | |
| parent | 4a365d41b677e495f8658b20bad0a6dff41c747d (diff) | |
| download | zcatch-05f3757491abbca38dd789574951d46c28ce746c.tar.gz zcatch-05f3757491abbca38dd789574951d46c28ce746c.zip | |
added optimisations by sworddragon
| -rw-r--r-- | src/engine/client/graphics.cpp | 22 | ||||
| -rw-r--r-- | src/engine/client/graphics.h | 2 | ||||
| -rw-r--r-- | src/game/client/render.cpp | 4 | ||||
| -rw-r--r-- | src/game/client/render_map.cpp | 4 |
4 files changed, 17 insertions, 15 deletions
diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index bf3f42ea..09ee4784 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -103,7 +103,7 @@ void CGraphics_OpenGL::AddVertices(int Count) Flush(); } -void CGraphics_OpenGL::Rotate4(CPoint *pCenter, CVertex *pPoints) +void CGraphics_OpenGL::Rotate4(const CPoint &rCenter, CVertex *pPoints) { float c = cosf(m_Rotation); float s = sinf(m_Rotation); @@ -112,10 +112,10 @@ void CGraphics_OpenGL::Rotate4(CPoint *pCenter, CVertex *pPoints) for(i = 0; i < 4; i++) { - x = pPoints[i].m_Pos.x - pCenter->x; - y = pPoints[i].m_Pos.y - pCenter->y; - pPoints[i].m_Pos.x = x * c - y * s + pCenter->x; - pPoints[i].m_Pos.y = x * s + y * c + pCenter->y; + x = pPoints[i].m_Pos.x - rCenter.x; + y = pPoints[i].m_Pos.y - rCenter.y; + pPoints[i].m_Pos.x = x * c - y * s + rCenter.x; + pPoints[i].m_Pos.y = x * s + y * c + rCenter.y; } } @@ -558,15 +558,12 @@ void CGraphics_OpenGL::QuadsDraw(CQuadItem *pArray, int Num) void CGraphics_OpenGL::QuadsDrawTL(const CQuadItem *pArray, int Num) { CPoint Center; + Center.z = 0; dbg_assert(m_Drawing == DRAWING_QUADS, "called quads_draw without begin"); for(int i = 0; i < Num; ++i) { - Center.x = pArray[i].m_X + pArray[i].m_Width/2; - Center.y = pArray[i].m_Y + pArray[i].m_Height/2; - Center.z = 0; - m_aVertices[m_NumVertices + 4*i].m_Pos.x = pArray[i].m_X; m_aVertices[m_NumVertices + 4*i].m_Pos.y = pArray[i].m_Y; m_aVertices[m_NumVertices + 4*i].m_Tex = m_aTexture[0]; @@ -588,7 +585,12 @@ void CGraphics_OpenGL::QuadsDrawTL(const CQuadItem *pArray, int Num) m_aVertices[m_NumVertices + 4*i + 3].m_Color = m_aColor[3]; if(m_Rotation != 0) - Rotate4(&Center, &m_aVertices[m_NumVertices + 4*i]); + { + Center.x = pArray[i].m_X + pArray[i].m_Width/2; + Center.y = pArray[i].m_Y + pArray[i].m_Height/2; + + Rotate4(Center, &m_aVertices[m_NumVertices + 4*i]); + } } AddVertices(4*Num); diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index ff4c3562..cb8681f3 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -60,7 +60,7 @@ protected: void Flush(); void AddVertices(int Count); - void Rotate4(CPoint *pCenter, CVertex *pPoints); + void Rotate4(const CPoint &rCenter, CVertex *pPoints); static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset); public: diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index ee4dc9d9..2b773112 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -292,8 +292,8 @@ void CRenderTools::MapscreenToWorld(float CenterX, float CenterY, float Parallax Height *= Zoom; pPoints[0] = OffsetX+CenterX-Width/2; pPoints[1] = OffsetY+CenterY-Height/2; - pPoints[2] = OffsetX+CenterX+Width/2; - pPoints[3] = OffsetY+CenterY+Height/2; + pPoints[2] = pPoints[0]+Width; + pPoints[3] = pPoints[1]+Height; } void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers) diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index 0354b9d5..2d0875ca 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -241,8 +241,8 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4 int ty = Index/16; int Px0 = tx*(1024/16); int Py0 = ty*(1024/16); - int Px1 = (tx+1)*(1024/16)-1; - int Py1 = (ty+1)*(1024/16)-1; + int Px1 = Px0+(1024/16)-1; + int Py1 = Py0+(1024/16)-1; float u0 = Nudge + Px0/TexSize+Frac; float v0 = Nudge + Py0/TexSize+Frac; |