Skip to content

Commit

Permalink
Cleanup: Do not use fvertex_t for Vertex's coordinates
Browse files Browse the repository at this point in the history
This additional level of abstraction achieves nothing now.
  • Loading branch information
danij-deng committed Apr 15, 2012
1 parent 427164f commit 1a2f65d
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 112 deletions.
16 changes: 7 additions & 9 deletions doomsday/engine/portable/include/mapdata.hs
Expand Up @@ -26,8 +26,6 @@ typedef struct lineowner_s {
shadowvert_t shadowOffsets;
} lineowner_t;

#define V_pos v.pos

typedef struct mvertex_s {
// Vertex index. Always valid after loading and pruning of unused
// vertices has occurred.
Expand All @@ -47,9 +45,9 @@ typedef struct mvertex_s {
end

struct Vertex
- float[2] pos
- uint numLineOwners // Number of line owners.
- lineowner_t* lineOwners // Lineowner base ptr [numlineowners] size. A doubly, circularly linked list. The base is the line with the lowest angle and the next-most with the largest angle.
- fvertex_t v
- mvertex_t buildData
end

Expand All @@ -59,13 +57,13 @@ internal
#define BACK 1

#define HE_v(n) v[(n)? 1:0]
#define HE_vpos(n) HE_v(n)->V_pos
#define HE_vpos(n) HE_v(n)->pos

#define HE_v1 HE_v(0)
#define HE_v1pos HE_v(0)->V_pos
#define HE_v1pos HE_v(0)->pos

#define HE_v2 HE_v(1)
#define HE_v2pos HE_v(1)->V_pos
#define HE_v2pos HE_v(1)->pos

#define HEDGE_BACK_SECTOR(h) ((h)->twin ? (h)->twin->sector : NULL)
#define HEDGE_SIDEDEF(h) ((h)->lineDef->sideDefs[(h)->side])
Expand Down Expand Up @@ -419,13 +417,13 @@ end
internal
// Helper macros for accessing linedef data elements.
#define L_v(n) v[(n)? 1:0]
#define L_vpos(n) v[(n)]->V_pos
#define L_vpos(n) v[(n)]->pos

#define L_v1 L_v(0)
#define L_v1pos L_v(0)->V_pos
#define L_v1pos L_v(0)->pos

#define L_v2 L_v(1)
#define L_v2pos L_v(1)->V_pos
#define L_v2pos L_v(1)->pos

#define L_vo(n) vo[(n)? 1:0]
#define L_vo1 L_vo(0)
Expand Down
16 changes: 7 additions & 9 deletions doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -25,8 +25,6 @@ typedef struct lineowner_s {
shadowvert_t shadowOffsets;
} lineowner_t;

#define V_pos v.pos

typedef struct mvertex_s {
// Vertex index. Always valid after loading and pruning of unused
// vertices has occurred.
Expand All @@ -46,9 +44,9 @@ typedef struct mvertex_s {

typedef struct vertex_s {
runtime_mapdata_header_t header;
float pos[2];
unsigned int numLineOwners; // Number of line owners.
lineowner_t* lineOwners; // Lineowner base ptr [numlineowners] size. A doubly, circularly linked list. The base is the line with the lowest angle and the next-most with the largest angle.
fvertex_t v;
mvertex_t buildData;
} Vertex;

Expand All @@ -57,13 +55,13 @@ typedef struct vertex_s {
#define BACK 1

#define HE_v(n) v[(n)? 1:0]
#define HE_vpos(n) HE_v(n)->V_pos
#define HE_vpos(n) HE_v(n)->pos

#define HE_v1 HE_v(0)
#define HE_v1pos HE_v(0)->V_pos
#define HE_v1pos HE_v(0)->pos

#define HE_v2 HE_v(1)
#define HE_v2pos HE_v(1)->V_pos
#define HE_v2pos HE_v(1)->pos

#define HEDGE_BACK_SECTOR(h) ((h)->twin ? (h)->twin->sector : NULL)
#define HEDGE_SIDEDEF(h) ((h)->lineDef->sideDefs[(h)->side])
Expand Down Expand Up @@ -394,13 +392,13 @@ typedef struct sidedef_s {

// Helper macros for accessing linedef data elements.
#define L_v(n) v[(n)? 1:0]
#define L_vpos(n) v[(n)? 1:0]->V_pos
#define L_vpos(n) v[(n)? 1:0]->pos

#define L_v1 L_v(0)
#define L_v1pos L_v(0)->V_pos
#define L_v1pos L_v(0)->pos

#define L_v2 L_v(1)
#define L_v2pos L_v(1)->V_pos
#define L_v2pos L_v(1)->pos

#define L_vo(n) vo[(n)? 1:0]
#define L_vo1 L_vo(0)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/sv_pool.h
Expand Up @@ -293,7 +293,7 @@ typedef struct {
} sidedelta_t;

typedef struct {
fvertex_t dest;
float dest[2];
float speed;
angle_t destAngle;
angle_t angleSpeed;
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/bspleaf.cpp
Expand Up @@ -46,22 +46,22 @@ void BspLeaf_ChooseFanBase(BspLeaf* leaf)
if(leaf->hedgeCount > 3)
{
// Leafs with higher vertex counts demand checking.
fvertex_t* baseVtx, *a, *b;
Vertex* baseVtx, *a, *b;

// Search for a good base.
do
{
HEdge* other = leaf->hedge;

baseVtx = &leaf->fanBase->HE_v1->v;
baseVtx = leaf->fanBase->HE_v1;
do
{
// Test this triangle?
if(!(leaf->fanBase != leaf->hedge &&
(other == leaf->fanBase || other == leaf->fanBase->prev)))
{
a = &other->HE_v1->v;
b = &other->HE_v2->v;
a = other->HE_v1;
b = other->HE_v2;

if(M_TriangleArea(baseVtx->pos, a->pos, b->pos) <= MIN_TRIANGLE_EPSILON)
{
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/dam_file.c
Expand Up @@ -164,8 +164,8 @@ static void writeVertex(const GameMap *map, uint idx)
{
Vertex *v = &map->vertexes[idx];

writeFloat(v->V_pos[VX]);
writeFloat(v->V_pos[VY]);
writeFloat(v->pos[VX]);
writeFloat(v->pos[VY]);
writeLong((long) v->numLineOwners);

if(v->numLineOwners > 0)
Expand All @@ -187,8 +187,8 @@ static void readVertex(const GameMap *map, uint idx)
uint i;
Vertex *v = &map->vertexes[idx];

v->V_pos[VX] = readFloat();
v->V_pos[VY] = readFloat();
v->pos[VX] = readFloat();
v->pos[VY] = readFloat();
v->numLineOwners = (uint) readLong();

if(v->numLineOwners > 0)
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/edit_bsp.cpp
Expand Up @@ -139,8 +139,8 @@ static void finishHEdges(GameMap* map)
if(ldef->L_side(hedge->side))
hedge->sector = ldef->L_side(hedge->side)->sector;

hedge->offset = P_AccurateDistance(hedge->HE_v1pos[VX] - vtx->V_pos[VX],
hedge->HE_v1pos[VY] - vtx->V_pos[VY]);
hedge->offset = P_AccurateDistance(hedge->HE_v1pos[VX] - vtx->pos[VX],
hedge->HE_v1pos[VY] - vtx->pos[VY]);
}

hedge->angle = bamsAtan2((int) (hedge->HE_v2pos[VY] - hedge->HE_v1pos[VY]),
Expand Down Expand Up @@ -258,8 +258,8 @@ static void copyVertex(Vertex& vtx, Vertex const& other)
V2d_Copy(vtx.buildData.pos, other.buildData.pos);

// Apply the final coordinates.
vtx.V_pos[VX] = float(vtx.buildData.pos[VX]);
vtx.V_pos[VY] = float(vtx.buildData.pos[VY]);
vtx.pos[VX] = float(vtx.buildData.pos[VX]);
vtx.pos[VY] = float(vtx.buildData.pos[VY]);
}

static void hardenVertexes(BspBuilder& builder, GameMap* map,
Expand Down
18 changes: 9 additions & 9 deletions doomsday/engine/portable/src/edit_map.c
Expand Up @@ -788,8 +788,8 @@ static int C_DECL lineAngleSorter(const void* a, const void* b)
line = own[i]->lineDef;
otherVtx = line->L_v(line->L_v1 == rootVtx? 1:0);

dx = otherVtx->V_pos[VX] - rootVtx->V_pos[VX];
dy = otherVtx->V_pos[VY] - rootVtx->V_pos[VY];
dx = otherVtx->pos[VX] - rootVtx->pos[VX];
dy = otherVtx->pos[VY] - rootVtx->pos[VY];

own[i]->angle = angles[i] = bamsAtan2(-100 *dx, 100 * dy);

Expand Down Expand Up @@ -1531,7 +1531,7 @@ static void findBounds(Vertex const** vertexes, uint numVertexes, vec2f_t min, v
for(i = 0; i < numVertexes; ++i)
{
vtx = vertexes[i];
V2f_Set(point, vtx->V_pos[VX], vtx->V_pos[VY]);
V2f_Set(point, vtx->pos[VX], vtx->pos[VY]);
if(!i)
V2f_InitBox(bounds, point);
else
Expand Down Expand Up @@ -1763,8 +1763,8 @@ uint MPE_VertexCreate(coord_t x, coord_t y)
v = createVertex();
v->buildData.pos[VX] = x;
v->buildData.pos[VY] = y;
v->V_pos[VX] = (float)v->buildData.pos[VX];
v->V_pos[VY] = (float)v->buildData.pos[VY];
v->pos[VX] = (float)v->buildData.pos[VX];
v->pos[VY] = (float)v->buildData.pos[VY];

return v->buildData.index;
}
Expand All @@ -1784,8 +1784,8 @@ boolean MPE_VertexCreatev(size_t num, coord_t* values, uint* indices)
v = createVertex();
v->buildData.pos[VX] = values[n * 2];
v->buildData.pos[VY] = values[n * 2 + 1];
v->V_pos[VX] = (float)v->buildData.pos[VX];
v->V_pos[VY] = (float)v->buildData.pos[VY];
v->pos[VX] = (float)v->buildData.pos[VX];
v->pos[VY] = (float)v->buildData.pos[VY];

if(indices)
indices[n] = v->buildData.index;
Expand Down Expand Up @@ -1860,8 +1860,8 @@ uint MPE_LinedefCreate(uint v1, uint v2, uint frontSide, uint backSide, int flag
// Next, check the length is not zero.
vtx1 = map->vertexes[v1 - 1];
vtx2 = map->vertexes[v2 - 1];
length = P_AccurateDistance(vtx2->V_pos[VX] - vtx1->V_pos[VX],
vtx2->V_pos[VY] - vtx1->V_pos[VY]);
length = P_AccurateDistance(vtx2->pos[VX] - vtx1->pos[VX],
vtx2->pos[VY] - vtx1->pos[VY]);
if(!(length > 0)) return 0;

if(frontSide > 0)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/portable/src/p_maputil.c
Expand Up @@ -472,7 +472,7 @@ BspLeaf* P_BspLeafAtPointXY(float x, float y)

boolean P_IsPointXYInBspLeaf(float x, float y, const BspLeaf* bspLeaf)
{
fvertex_t* vi, *vj;
Vertex* vi, *vj;
HEdge* hedge;

if(!bspLeaf || !bspLeaf->hedge) return false; // I guess?
Expand All @@ -482,8 +482,8 @@ boolean P_IsPointXYInBspLeaf(float x, float y, const BspLeaf* bspLeaf)
{
HEdge* next = hedge->next;

vi = &hedge->HE_v1->v;
vj = &next->HE_v1->v;
vi = hedge->HE_v1;
vj = next->HE_v1;

if(((vi->pos[VY] - y) * (vj->pos[VX] - vi->pos[VX]) -
(vi->pos[VX] - x) * (vj->pos[VY] - vi->pos[VY])) < 0)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/p_objlink.c
Expand Up @@ -403,8 +403,8 @@ static void processSeg(HEdge* hedge, void* paramaters)
const float dx = hedge->HE_v2pos[VX] - hedge->HE_v1pos[VX];
const float dy = hedge->HE_v2pos[VY] - hedge->HE_v1pos[VY];
vtx = hedge->HE_v1;
distance = ((vtx->V_pos[VY] - p->objPos[VY]) * dx -
(vtx->V_pos[VX] - p->objPos[VX]) * dy) / hedge->length;
distance = ((vtx->pos[VY] - p->objPos[VY]) * dx -
(vtx->pos[VX] - p->objPos[VX]) * dy) / hedge->length;
}

if(hedge->lineDef)
Expand Down
14 changes: 7 additions & 7 deletions doomsday/engine/portable/src/polyobj.c
Expand Up @@ -243,12 +243,12 @@ boolean Polyobj_Rotate(Polyobj* po, angle_t angle)
LineDef* line = *lineIter;
Vertex* vtx = line->L_v1;

prevPts->pos[VX] = vtx->V_pos[VX];
prevPts->pos[VY] = vtx->V_pos[VY];
vtx->V_pos[VX] = originalPts->pos[VX];
vtx->V_pos[VY] = originalPts->pos[VY];
prevPts->pos[VX] = vtx->pos[VX];
prevPts->pos[VY] = vtx->pos[VY];
vtx->pos[VX] = originalPts->pos[VX];
vtx->pos[VY] = originalPts->pos[VY];

rotatePoint2d(vtx->V_pos, po->pos, fineAngle);
rotatePoint2d(vtx->pos, po->pos, fineAngle);
}

lineIter = po->lines;
Expand Down Expand Up @@ -279,8 +279,8 @@ boolean Polyobj_Rotate(Polyobj* po, angle_t angle)
{
LineDef* line = *lineIter;
Vertex* vtx = line->L_v1;
vtx->V_pos[VX] = prevPts->pos[VX];
vtx->V_pos[VY] = prevPts->pos[VY];
vtx->pos[VX] = prevPts->pos[VX];
vtx->pos[VY] = prevPts->pos[VY];
}

lineIter = po->lines;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/r_fakeradio.c
Expand Up @@ -282,13 +282,13 @@ void R_InitFakeRadioForMap(void)
vo1 = line->L_vo(j^1)->LO_prev;

// Use the extended points, they are wider than inoffsets.
V2f_Set(point, vtx0->V_pos[VX], vtx0->V_pos[VY]);
V2f_Set(point, vtx0->pos[VX], vtx0->pos[VY]);
V2f_InitBox(bounds.arvec2, point);

V2f_Sum(point, point, vo0->shadowOffsets.extended);
V2f_AddToBox(bounds.arvec2, point);

V2f_Set(point, vtx1->V_pos[VX], vtx1->V_pos[VY]);
V2f_Set(point, vtx1->pos[VX], vtx1->pos[VY]);
V2f_AddToBox(bounds.arvec2, point);

V2f_Sum(point, point, vo1->shadowOffsets.extended);
Expand Down
14 changes: 7 additions & 7 deletions doomsday/engine/portable/src/rend_bias.c
Expand Up @@ -564,8 +564,8 @@ static float SB_Dot(source_t* src, const vectorcompf_t* point,
return V3f_DotProduct(delta, normal);
}

static void updateAffected(biassurface_t* bsuf, const fvertex_t* from,
const fvertex_t* to, const vectorcompf_t* normal)
static void updateAffected(biassurface_t* bsuf, float const from[2],
float const to[2], const vectorcompf_t* normal)
{
int i, k;
vec2f_t delta;
Expand All @@ -592,11 +592,11 @@ static void updateAffected(biassurface_t* bsuf, const fvertex_t* from,
for(i = 0; i < 2; ++i)
{
if(!i)
V2f_Set(delta, from->pos[VX] - src->pos[VX],
from->pos[VY] - src->pos[VY]);
V2f_Set(delta, from[VX] - src->pos[VX],
from[VY] - src->pos[VY]);
else
V2f_Set(delta, to->pos[VX] - src->pos[VX],
to->pos[VY] - src->pos[VY]);
V2f_Set(delta, to[VX] - src->pos[VX],
to[VY] - src->pos[VY]);
len = V2f_Normalize(delta);

if(i == 0 || len < distance)
Expand Down Expand Up @@ -969,7 +969,7 @@ void SB_RendPoly(struct ColorRawf_s* rcolors, biassurface_t* bsuf,
{
HEdge* hedge = (HEdge*) mapObject;

updateAffected(bsuf, &hedge->HE_v1->v, &hedge->HE_v2->v, normal);
updateAffected(bsuf, hedge->HE_v1pos, hedge->HE_v2pos, normal);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/rend_clip.c
Expand Up @@ -1296,8 +1296,8 @@ int C_CheckBspLeaf(BspLeaf* bspLeaf)
{
Vertex* vtx = hedge->HE_v1;
// Shift for more accuracy.
anglist[i++] = bamsAtan2((int) ((vtx->V_pos[VY] - vz) * 100),
(int) ((vtx->V_pos[VX] - vx) * 100));
anglist[i++] = bamsAtan2((int) ((vtx->pos[VY] - vz) * 100),
(int) ((vtx->pos[VX] - vx) * 100));

} while((hedge = hedge->next) != bspLeaf->hedge);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/rend_fakeradio.c
Expand Up @@ -1625,10 +1625,10 @@ void Rend_DrawShadowOffsetVerts(void)
{
pos[VZ] = vo->lineDef->L_frontsector->SP_floorvisheight;

V2f_Sum(pos, vtx->V_pos, vo->shadowOffsets.extended);
V2f_Sum(pos, vtx->pos, vo->shadowOffsets.extended);
drawPoint(pos, 1.f, yellow);

V2f_Sum(pos, vtx->V_pos, vo->shadowOffsets.inner);
V2f_Sum(pos, vtx->pos, vo->shadowOffsets.inner);
drawPoint(pos, 1.f, red);

vo = vo->LO_next;
Expand Down

0 comments on commit 1a2f65d

Please sign in to comment.