From 3bf7714d51748038c731b82edf9f222c08a10d52 Mon Sep 17 00:00:00 2001 From: danij Date: Wed, 3 Apr 2013 02:37:02 +0100 Subject: [PATCH] Refactor|GameMap: Removed the now obsolete GameMap_Vertex() --- doomsday/client/include/map/gamemap.h | 9 ----- doomsday/client/src/map/gamemap.cpp | 7 ---- doomsday/client/src/map/p_dmu.cpp | 4 +-- doomsday/client/src/render/r_fakeradio.cpp | 4 +-- doomsday/client/src/render/rend_main.cpp | 42 ++++++++++------------ 5 files changed, 22 insertions(+), 44 deletions(-) diff --git a/doomsday/client/include/map/gamemap.h b/doomsday/client/include/map/gamemap.h index 190dd3ebdc..033cab1ab7 100644 --- a/doomsday/client/include/map/gamemap.h +++ b/doomsday/client/include/map/gamemap.h @@ -443,15 +443,6 @@ void GameMap_InitSkyFix(GameMap *map); void GameMap_UpdateSkyFixForSector(GameMap *map, Sector *sec); -/** - * Lookup a Vertex by its unique index. - * - * @param map GameMap instance. - * @param idx Unique index of the vertex. - * @return Pointer to Vertex with this index else @c NULL if @a idx is not valid. - */ -Vertex *GameMap_Vertex(GameMap *map, uint idx); - /** * Lookup a LineDef by its unique index. * diff --git a/doomsday/client/src/map/gamemap.cpp b/doomsday/client/src/map/gamemap.cpp index 24b7e69cec..94dabe3e4b 100644 --- a/doomsday/client/src/map/gamemap.cpp +++ b/doomsday/client/src/map/gamemap.cpp @@ -206,13 +206,6 @@ GameMap *GameMap_SetSkyFix(GameMap *map, boolean ceiling, coord_t height) return map; } -Vertex *GameMap_Vertex(GameMap *map, uint idx) -{ - DENG2_ASSERT(map); - if(idx >= uint( map->_vertexes.size() )) return 0; - return map->_vertexes[idx]; -} - int GameMap_VertexIndex(GameMap *map, Vertex const *vtx) { DENG2_ASSERT(map); diff --git a/doomsday/client/src/map/p_dmu.cpp b/doomsday/client/src/map/p_dmu.cpp index e0b8d9ed31..cd31b398a2 100644 --- a/doomsday/client/src/map/p_dmu.cpp +++ b/doomsday/client/src/map/p_dmu.cpp @@ -333,7 +333,7 @@ void *P_ToPtr(int type, uint index) switch(type) { case DMU_VERTEX: - return GameMap_Vertex(theMap, index); + return theMap->vertexes().at(index); case DMU_HEDGE: return GameMap_HEdge(theMap, index); @@ -456,7 +456,7 @@ int P_Callback(int type, uint index, void *context, int (*callback)(void *p, voi { case DMU_VERTEX: if(index < GameMap_VertexCount(theMap)) - return callback(GameMap_Vertex(theMap, index), context); + return callback(theMap->vertexes().at(index), context); break; case DMU_HEDGE: diff --git a/doomsday/client/src/render/r_fakeradio.cpp b/doomsday/client/src/render/r_fakeradio.cpp index 1a60302939..3ee0059409 100644 --- a/doomsday/client/src/render/r_fakeradio.cpp +++ b/doomsday/client/src/render/r_fakeradio.cpp @@ -221,9 +221,9 @@ void Rend_RadioInitForMap() Time begunAt; - for(uint i = 0; i < GameMap_VertexCount(theMap); ++i) + foreach(Vertex *vertex, theMap->vertexes()) { - Rend_RadioUpdateVertexShadowOffsets(*GameMap_Vertex(theMap, i)); + Rend_RadioUpdateVertexShadowOffsets(*vertex); } /** diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index 48878a61a7..cd614d144b 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -3351,28 +3351,26 @@ void Rend_Vertexes() oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH); DGL_SetFloat(DGL_LINE_WIDTH, 2); - for(uint i = 0; i < GameMap_VertexCount(theMap); ++i) + foreach(Vertex *vertex, theMap->vertexes()) { - Vertex *vtx = GameMap_Vertex(theMap, i); - // Not a linedef vertex? - LineOwner const *own = vtx->firstLineOwner(); + LineOwner const *own = vertex->firstLineOwner(); if(!own) continue; // Ignore polyobj vertexes. if(own->line().isFromPolyobj()) continue; - float alpha = 1 - M_ApproxDistance(vOrigin[VX] - vtx->origin()[VX], - vOrigin[VZ] - vtx->origin()[VY]) / MAX_VERTEX_POINT_DIST; + float alpha = 1 - M_ApproxDistance(vOrigin[VX] - vertex->origin()[VX], + vOrigin[VZ] - vertex->origin()[VY]) / MAX_VERTEX_POINT_DIST; alpha = de::min(alpha, .15f); if(alpha > 0) { coord_t bottom = DDMAXFLOAT; coord_t top = DDMINFLOAT; - getVertexPlaneMinMax(vtx, &bottom, &top); + getVertexPlaneMinMax(vertex, &bottom, &top); - drawVertexBar(vtx, bottom, top, alpha); + drawVertexBar(vertex, bottom, top, alpha); } } } @@ -3383,27 +3381,24 @@ void Rend_Vertexes() glEnable(GL_POINT_SMOOTH); DGL_SetFloat(DGL_POINT_SIZE, 6); - for(uint i = 0; i < GameMap_VertexCount(theMap); ++i) + foreach(Vertex *vertex, theMap->vertexes()) { - Vertex *vtx = GameMap_Vertex(theMap, i); - coord_t dist; - // Not a linedef vertex? - LineOwner const *own = vtx->firstLineOwner(); + LineOwner const *own = vertex->firstLineOwner(); if(!own) continue; // Ignore polyobj vertexes. if(own->line().isFromPolyobj()) continue; - dist = M_ApproxDistance(vOrigin[VX] - vtx->origin()[VX], - vOrigin[VZ] - vtx->origin()[VY]); + coord_t dist = M_ApproxDistance(vOrigin[VX] - vertex->origin()[VX], + vOrigin[VZ] - vertex->origin()[VY]); if(dist < MAX_VERTEX_POINT_DIST) { coord_t bottom = DDMAXFLOAT; - getVertexPlaneMinMax(vtx, &bottom, NULL); + getVertexPlaneMinMax(vertex, &bottom, NULL); - drawVertexPoint(vtx, bottom, (1 - dist / MAX_VERTEX_POINT_DIST) * 2); + drawVertexPoint(vertex, bottom, (1 - dist / MAX_VERTEX_POINT_DIST) * 2); } } @@ -3416,22 +3411,21 @@ void Rend_Vertexes() eye[VY] = vOrigin[VZ]; eye[VZ] = vOrigin[VY]; - for(uint i = 0; i < GameMap_VertexCount(theMap); ++i) + foreach(Vertex *vertex, theMap->vertexes()) { - Vertex *vtx = GameMap_Vertex(theMap, i); coord_t pos[3], dist; // Not a linedef vertex? - LineOwner const *own = vtx->firstLineOwner(); + LineOwner const *own = vertex->firstLineOwner(); if(!own) continue; // Ignore polyobj vertexes. if(own->line().isFromPolyobj()) continue; - pos[VX] = vtx->origin()[VX]; - pos[VY] = vtx->origin()[VY]; + pos[VX] = vertex->origin()[VX]; + pos[VY] = vertex->origin()[VY]; pos[VZ] = DDMAXFLOAT; - getVertexPlaneMinMax(vtx, &pos[VZ], NULL); + getVertexPlaneMinMax(vertex, &pos[VZ], NULL); dist = V3d_Distance(pos, eye); @@ -3440,7 +3434,7 @@ void Rend_Vertexes() float const alpha = 1 - dist / MAX_VERTEX_POINT_DIST; float const scale = dist / (DENG_WINDOW->width() / 2); - drawVertexIndex(vtx, pos[VZ], scale, alpha); + drawVertexIndex(vertex, pos[VZ], scale, alpha); } } }