Skip to content

Commit

Permalink
Refactor|GameMap: Removed the now obsolete GameMap_Vertex()
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 3, 2013
1 parent 540f9a3 commit 3bf7714
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 44 deletions.
9 changes: 0 additions & 9 deletions doomsday/client/include/map/gamemap.h
Expand Up @@ -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.
*
Expand Down
7 changes: 0 additions & 7 deletions doomsday/client/src/map/gamemap.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/map/p_dmu.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/r_fakeradio.cpp
Expand Up @@ -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);
}

/**
Expand Down
42 changes: 18 additions & 24 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}

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

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

0 comments on commit 3bf7714

Please sign in to comment.