From 3837717a5d8afdd3dbca8c939e4b7dbbb343532a Mon Sep 17 00:00:00 2001 From: danij Date: Wed, 10 Apr 2013 02:00:47 +0100 Subject: [PATCH] Refactor|LineDef: Made private mode LineDef instance data Vertexes/direction vector/accurate length --- doomsday/client/include/map/linedef.h | 36 ++++---- doomsday/client/src/edit_map.cpp | 68 +++++++--------- doomsday/client/src/map/bsp/partitioner.cpp | 18 ++-- doomsday/client/src/map/linedef.cpp | 86 ++++++++++++-------- doomsday/client/src/map/linesighttest.cpp | 2 +- doomsday/client/src/map/p_dmu.cpp | 11 ++- doomsday/client/src/map/p_maputil.cpp | 2 +- doomsday/client/src/map/p_particle.cpp | 4 +- doomsday/client/src/render/r_fakeradio.cpp | 16 ++-- doomsday/client/src/render/rend_main.cpp | 4 +- doomsday/client/src/render/rend_particle.cpp | 11 +-- doomsday/server/src/server/sv_pool.cpp | 4 +- 12 files changed, 136 insertions(+), 126 deletions(-) diff --git a/doomsday/client/include/map/linedef.h b/doomsday/client/include/map/linedef.h index f7382f0245..7f8301504b 100644 --- a/doomsday/client/include/map/linedef.h +++ b/doomsday/client/include/map/linedef.h @@ -22,13 +22,17 @@ #define LIBDENG_MAP_LINEDEF #include -#include // Divline + +#include #include -#include "resource/r_data.h" + +//#include "resource/r_data.h" + +#include "MapElement" #include "map/r_world.h" -#include "p_mapdata.h" +//#include "p_mapdata.h" + #include "p_dmu.h" -#include "MapElement" class Vertex; class Sector; @@ -125,7 +129,7 @@ class LineDef : public de::MapElement int _shadowVisCount; public: - Side(); + Side(Sector *sector = 0); /** * Returns @c true iff a Sector is attributed to the side. @@ -196,10 +200,6 @@ class LineDef : public de::MapElement }; public: /// @todo make private: - /// Vertexes: - Vertex *_v1; - Vertex *_v2; - /// Links to vertex line owner nodes: LineOwner *_vo1; LineOwner *_vo2; @@ -213,16 +213,12 @@ class LineDef : public de::MapElement /// Calculated from the direction vector. binangle_t _angle; - /// Direction vector from Start to End vertex. - vec2d_t _direction; - - /// Accurate length. - coord_t _length; - int _validCount; public: - LineDef(); + LineDef(Vertex &v1, Vertex &v2, + Sector *frontSector = 0, + Sector *backSector = 0); /** * Returns @c true iff the line is part of some Polyobj. @@ -573,7 +569,7 @@ class LineDef : public de::MapElement /** * Returns a direction vector for the line from Start to End vertex. */ - const_pvec2d_t &direction() const; + de::Vector2d const &direction() const; /** * Returns the logical @em slopetype for the line (which, is determined @@ -640,7 +636,8 @@ class LineDef : public de::MapElement */ inline coord_t pointDistance(const_pvec2d_t point, coord_t *offset) const { - return V2d_PointLineDistance(point, v1().origin(), direction(), offset); + coord_t v1Direction[2] = { direction().x, direction().y }; + return V2d_PointLineDistance(point, v1().origin(), v1Direction, offset); } /// @copydoc pointDistance() @@ -662,7 +659,8 @@ class LineDef : public de::MapElement */ inline coord_t pointOnSide(const_pvec2d_t point) const { - return V2d_PointOnLineSide(point, v1().origin(), direction()); + coord_t v1Direction[2] = { direction().x, direction().y }; + return V2d_PointOnLineSide(point, v1().origin(), v1Direction); } /// @copydoc pointOnSide() diff --git a/doomsday/client/src/edit_map.cpp b/doomsday/client/src/edit_map.cpp index 3a468d66ec..cee805452b 100644 --- a/doomsday/client/src/edit_map.cpp +++ b/doomsday/client/src/edit_map.cpp @@ -99,9 +99,10 @@ class EditableMap return vtx; } - LineDef *createLine() + LineDef *createLine(Vertex &v1, Vertex &v2, Sector *frontSector = 0, + Sector *backSector = 0) { - LineDef *line = new LineDef; + LineDef *line = new LineDef(v1, v2, frontSector, backSector); lines.append(line); line->setOrigIndex(lines.count()); // 1-based index, 0 = NIL. @@ -1002,15 +1003,7 @@ boolean MPE_End() while(!editMap.lines.isEmpty()) { map->_lines.append(editMap.lines.takeFirst()); - LineDef *line = map->_lines.back(); - - /// @todo This init should already have been done elsewhere. -ds - line->updateSlopeType(); - line->updateAABox(); - - line->_length = V2d_Length(line->_direction); - line->_angle = bamsAtan2(int( line->_direction[VY] ), - int( line->_direction[VX] )); + map->_lines.back(); } // Collate polyobjs: @@ -1171,13 +1164,13 @@ uint MPE_SidedefCreate(short flags, ddstring_t const *topMaterialUri, } #undef MPE_LinedefCreate -uint MPE_LinedefCreate(uint v1, uint v2, uint frontSector, uint backSector, +uint MPE_LinedefCreate(uint v1, uint v2, uint frontSectorIdx, uint backSectorIdx, uint frontSide, uint backSide, int flags) { if(!editMapInited) return 0; - if(frontSector > (uint)editMap.sectors.count()) return 0; - if(backSector > (uint)editMap.sectors.count()) return 0; + if(frontSectorIdx > (uint)editMap.sectors.count()) return 0; + if(backSectorIdx > (uint)editMap.sectors.count()) return 0; if(frontSide > (uint)editMap.sideDefs.count()) return 0; if(backSide > (uint)editMap.sideDefs.count()) return 0; if(v1 == 0 || v1 > (uint)editMap.vertexes.count()) return 0; @@ -1191,55 +1184,50 @@ uint MPE_LinedefCreate(uint v1, uint v2, uint frontSector, uint backSector, return 0; // Next, check the length is not zero. + /// @todo fixme: We need to allow these... -ds Vertex *vtx1 = editMap.vertexes[v1 - 1]; Vertex *vtx2 = editMap.vertexes[v2 - 1]; - coord_t length = V2d_Distance(vtx2->origin(), vtx1->origin()); - if(!(length > 0)) return 0; + if(!(V2d_Distance(vtx2->origin(), vtx1->origin()) > 0)) return 0; SideDef *front = frontSide? editMap.sideDefs[frontSide - 1] : 0; SideDef *back = backSide? editMap.sideDefs[backSide - 1] : 0; - LineDef *l = editMap.createLine(); - l->_v1 = vtx1; - l->_v2 = vtx2; + Sector *frontSector = (frontSectorIdx == 0? NULL: editMap.sectors[frontSectorIdx-1]); + Sector *backSector = (backSectorIdx == 0? NULL: editMap.sectors[backSectorIdx-1]); - l->_v1->_buildData.refCount++; - l->_v2->_buildData.refCount++; - - l->front()._sector = (frontSector == 0? NULL: editMap.sectors[frontSector-1]); - l->back()._sector = (backSector == 0? NULL: editMap.sectors[backSector-1]); + LineDef *l = editMap.createLine(*vtx1, *vtx2, frontSector, backSector); l->front()._sideDef = front; - l->back()._sideDef = back; - - l->_length = length; - - l->updateSlopeType(); - l->updateAABox(); - - l->_angle = bamsAtan2(int( l->_direction[VY] ), - int( l->_direction[VX] )); - - // Remember the number of unique references. if(l->hasFrontSideDef()) { l->frontSideDef()._line = l; - l->frontSideDef()._buildData.refCount++; } + l->back()._sideDef = back; if(l->hasBackSideDef()) { l->backSideDef()._line = l; - l->backSideDef()._buildData.refCount++; } - l->_inFlags = 0; - - // Determine the default linedef flags. + // Determine the default line flags. l->_flags = flags; if(!front || !back) l->_flags |= DDLF_BLOCKING; + // Remember the number of unique references. + l->v1()._buildData.refCount++; + l->v2()._buildData.refCount++; + + if(l->hasFrontSideDef()) + { + l->frontSideDef()._buildData.refCount++; + } + + if(l->hasBackSideDef()) + { + l->backSideDef()._buildData.refCount++; + } + return l->origIndex(); } diff --git a/doomsday/client/src/map/bsp/partitioner.cpp b/doomsday/client/src/map/bsp/partitioner.cpp index 9946ee33f2..7dbfdda4cd 100644 --- a/doomsday/client/src/map/bsp/partitioner.cpp +++ b/doomsday/client/src/map/bsp/partitioner.cpp @@ -228,39 +228,39 @@ DENG2_PIMPL(Partitioner) bool isFront = false; if(p.castHoriz) { - if(de::abs(line.direction()[VY]) < DIST_EPSILON) + if(de::abs(line.direction().y) < DIST_EPSILON) return; if((de::max(line.v1Origin()[VY], line.v2Origin()[VY]) < p.mY - DIST_EPSILON) || (de::min(line.v1Origin()[VY], line.v2Origin()[VY]) > p.mY + DIST_EPSILON)) return; - dist = (line.v1Origin()[VX] + (p.mY - line.v1Origin()[VY]) * line.direction()[VX] / line.direction()[VY]) - p.mX; + dist = (line.v1Origin()[VX] + (p.mY - line.v1Origin()[VY]) * line.direction().x / line.direction().y) - p.mX; - isFront = ((p.testLine->direction()[VY] > 0) != (dist > 0)); + isFront = ((p.testLine->direction().y > 0) != (dist > 0)); dist = de::abs(dist); // Too close? (overlapping lines?) if(dist < DIST_EPSILON) return; - hitSector = line.sectorPtr((p.testLine->direction()[VY] > 0) ^ (line.direction()[VY] > 0) ^ !isFront); + hitSector = line.sectorPtr((p.testLine->direction().y > 0) ^ (line.direction().y > 0) ^ !isFront); } else // Cast vertically. { - if(de::abs(line.direction()[VX]) < DIST_EPSILON) + if(de::abs(line.direction().x) < DIST_EPSILON) return; if((de::max(line.v1Origin()[VX], line.v2Origin()[VX]) < p.mX - DIST_EPSILON) || (de::min(line.v1Origin()[VX], line.v2Origin()[VX]) > p.mX + DIST_EPSILON)) return; - dist = (line.v1Origin()[VY] + (p.mX - line.v1Origin()[VX]) * line.direction()[VY] / line.direction()[VX]) - p.mY; + dist = (line.v1Origin()[VY] + (p.mX - line.v1Origin()[VX]) * line.direction().y / line.direction().x) - p.mY; - isFront = ((p.testLine->direction()[VX] > 0) == (dist > 0)); + isFront = ((p.testLine->direction().x > 0) == (dist > 0)); dist = de::abs(dist); - hitSector = line.sectorPtr((p.testLine->direction()[VX] > 0) ^ (line.direction()[VX] > 0) ^ !isFront); + hitSector = line.sectorPtr((p.testLine->direction().x > 0) ^ (line.direction().x > 0) ^ !isFront); } // Too close? (overlapping lines?) @@ -326,7 +326,7 @@ DENG2_PIMPL(Partitioner) p.testLine = line; p.mX = (line->v1Origin()[VX] + line->v2Origin()[VX]) / 2.0; p.mY = (line->v1Origin()[VY] + line->v2Origin()[VY]) / 2.0; - p.castHoriz = (de::abs(line->direction()[VX]) < de::abs(line->direction()[VY])? true : false); + p.castHoriz = (de::abs(line->direction().x) < de::abs(line->direction().y)? true : false); AABoxd scanRegion = map->bounds(); if(p.castHoriz) diff --git a/doomsday/client/src/map/linedef.cpp b/doomsday/client/src/map/linedef.cpp index e6cfe92b60..e9ed75fb06 100644 --- a/doomsday/client/src/map/linedef.cpp +++ b/doomsday/client/src/map/linedef.cpp @@ -35,8 +35,8 @@ using namespace de; -LineDef::Side::Side() - : _sector(0), +LineDef::Side::Side(Sector *sector) + : _sector(sector), _sideDef(0), _leftHEdge(0), _rightHEdge(0), @@ -122,9 +122,19 @@ void LineDef::Side::updateSurfaceNormals() DENG2_PIMPL(LineDef) { + /// Vertexes: + Vertex *v1; + Vertex *v2; + + /// Direction vector from vertex v1 to v2. + Vector2d direction; + /// Logical line slope (i.e., world angle) classification. slopetype_t slopeType; + /// Accurate length. + coord_t length; + /// Bounding box encompassing the map space coordinates of both vertexes. AABoxd aaBox; @@ -138,29 +148,34 @@ DENG2_PIMPL(LineDef) /// Whether the line has been mapped by each player yet. bool mapped[DDMAXPLAYERS]; - Instance(Public *i) + Instance(Public *i, Vertex &v1, Vertex &v2, + Sector *frontSector, Sector *backSector) : Base(i), - slopeType(ST_HORIZONTAL), + v1(&v1), + v2(&v2), + direction(Vector2d(v2.origin()) - Vector2d(v1.origin())), + slopeType(M_SlopeTypeXY(direction.x, direction.y)), + length(direction.length()), + front(frontSector), + back(backSector), origIndex(0) { std::memset(mapped, 0, sizeof(mapped)); } }; -LineDef::LineDef() +LineDef::LineDef(Vertex &v1, Vertex &v2, Sector *frontSector, Sector *backSector) : MapElement(DMU_LINEDEF), - _v1(0), - _v2(0), _vo1(0), _vo2(0), _flags(0), _inFlags(0), _angle(0), - _length(0), _validCount(0), - d(new Instance(this)) + d(new Instance(this, v1, v2, frontSector, backSector)) { - V2d_Set(_direction, 0, 0); + _angle = bamsAtan2(int( d->direction.y ), int( d->direction.x )); + updateAABox(); } int LineDef::flags() const @@ -200,14 +215,14 @@ LineDef::Side const &LineDef::side(int back) const Vertex &LineDef::vertex(int to) { - DENG_ASSERT((to? _v2 : _v1) != 0); - return to? *_v2 : *_v1; + DENG_ASSERT((to? d->v2 : d->v1) != 0); + return to? *d->v2 : *d->v1; } Vertex const &LineDef::vertex(int to) const { - DENG_ASSERT((to? _v2 : _v1) != 0); - return to? *_v2 : *_v1; + DENG_ASSERT((to? d->v2 : d->v1) != 0); + return to? *d->v2 : *d->v1; } LineOwner *LineDef::vertexOwner(int to) const @@ -223,18 +238,18 @@ AABoxd const &LineDef::aaBox() const void LineDef::updateAABox() { - V2d_InitBox(d->aaBox.arvec2, _v1->origin()); - V2d_AddToBox(d->aaBox.arvec2, _v2->origin()); + V2d_InitBox(d->aaBox.arvec2, d->v1->origin()); + V2d_AddToBox(d->aaBox.arvec2, d->v2->origin()); } coord_t LineDef::length() const { - return _length; + return d->length; } -const_pvec2d_t &LineDef::direction() const +Vector2d const &LineDef::direction() const { - return _direction; + return d->direction; } slopetype_t LineDef::slopeType() const @@ -244,8 +259,8 @@ slopetype_t LineDef::slopeType() const void LineDef::updateSlopeType() { - V2d_Subtract(_direction, _v2->origin(), _v1->origin()); - d->slopeType = M_SlopeType(_direction); + d->direction = d->v2->origin() - d->v1->origin(); + d->slopeType = M_SlopeTypeXY(d->direction.x, d->direction.y); } binangle_t LineDef::angle() const @@ -255,7 +270,8 @@ binangle_t LineDef::angle() const int LineDef::boxOnSide(AABoxd const &box) const { - return M_BoxOnLineSide(&box, _v1->origin(), _direction); + coord_t v1Direction[2] = { direction().x, direction().y }; + return M_BoxOnLineSide(&box, d->v1->origin(), v1Direction); } int LineDef::boxOnSide_FixedPrecision(AABoxd const &box) const @@ -268,8 +284,8 @@ int LineDef::boxOnSide_FixedPrecision(AABoxd const &box) const * so we won't change the discretization of the fractional part into 16-bit * precision. */ - coord_t offset[2] = { de::floor(_v1->origin()[VX] + _direction[VX]/2), - de::floor(_v1->origin()[VY] + _direction[VY]/2) }; + coord_t offset[2] = { de::floor(d->v1->origin()[VX] + d->direction.x/2), + de::floor(d->v1->origin()[VY] + d->direction.y/2) }; fixed_t boxx[4]; boxx[BOXLEFT] = FLT2FIX(box.minX - offset[VX]); @@ -277,11 +293,11 @@ int LineDef::boxOnSide_FixedPrecision(AABoxd const &box) const boxx[BOXBOTTOM] = FLT2FIX(box.minY - offset[VY]); boxx[BOXTOP] = FLT2FIX(box.maxY - offset[VY]); - fixed_t pos[2] = { FLT2FIX(_v1->origin()[VX] - offset[VX]), - FLT2FIX(_v1->origin()[VY] - offset[VY]) }; + fixed_t pos[2] = { FLT2FIX(d->v1->origin()[VX] - offset[VX]), + FLT2FIX(d->v1->origin()[VY] - offset[VY]) }; - fixed_t delta[2] = { FLT2FIX(_direction[VX]), - FLT2FIX(_direction[VY]) }; + fixed_t delta[2] = { FLT2FIX(d->direction.x), + FLT2FIX(d->direction.y) }; return M_BoxOnLineSide_FixedPrecision(boxx, pos, delta); } @@ -308,23 +324,23 @@ int LineDef::property(setargs_t &args) const switch(args.prop) { case DMU_VERTEX0: - DMU_GetValue(DMT_LINEDEF_V, &_v1, &args, 0); + DMU_GetValue(DMT_LINEDEF_V, &d->v1, &args, 0); break; case DMU_VERTEX1: - DMU_GetValue(DMT_LINEDEF_V, &_v2, &args, 0); + DMU_GetValue(DMT_LINEDEF_V, &d->v2, &args, 0); break; case DMU_DX: - DMU_GetValue(DMT_LINEDEF_DX, &_direction[VX], &args, 0); + DMU_GetValue(DMT_LINEDEF_DX, &d->direction.x, &args, 0); break; case DMU_DY: - DMU_GetValue(DMT_LINEDEF_DY, &_direction[VY], &args, 0); + DMU_GetValue(DMT_LINEDEF_DY, &d->direction.y, &args, 0); break; case DMU_DXY: - DMU_GetValue(DMT_LINEDEF_DX, &_direction[VX], &args, 0); - DMU_GetValue(DMT_LINEDEF_DY, &_direction[VY], &args, 1); + DMU_GetValue(DMT_LINEDEF_DX, &d->direction.x, &args, 0); + DMU_GetValue(DMT_LINEDEF_DY, &d->direction.y, &args, 1); break; case DMU_LENGTH: - DMU_GetValue(DMT_LINEDEF_LENGTH, &_length, &args, 0); + DMU_GetValue(DMT_LINEDEF_LENGTH, &d->length, &args, 0); break; case DMU_ANGLE: { angle_t lineAngle = BANG_TO_ANGLE(_angle); diff --git a/doomsday/client/src/map/linesighttest.cpp b/doomsday/client/src/map/linesighttest.cpp index bf5765a418..24df6848fa 100644 --- a/doomsday/client/src/map/linesighttest.cpp +++ b/doomsday/client/src/map/linesighttest.cpp @@ -111,7 +111,7 @@ DENG2_PIMPL(LineSightTest) V2x_PointOnLineSide(lineV2OriginX, ray.origin, ray.direction)) return true; - fixed_t lineDirectionX[2] = { DBL2FIX(line.direction()[VX]), DBL2FIX(line.direction()[VY]) }; + fixed_t lineDirectionX[2] = { DBL2FIX(line.direction().x), DBL2FIX(line.direction().y) }; fixed_t fromPointX[2] = { DBL2FIX(from.x), DBL2FIX(from.y) }; fixed_t toPointX[2] = { DBL2FIX(to.x), DBL2FIX(to.y) }; diff --git a/doomsday/client/src/map/p_dmu.cpp b/doomsday/client/src/map/p_dmu.cpp index 085a1f40dd..dbd3538443 100644 --- a/doomsday/client/src/map/p_dmu.cpp +++ b/doomsday/client/src/map/p_dmu.cpp @@ -52,12 +52,19 @@ struct DummyData virtual ~DummyData() {} // polymorphic }; +class DummyVertex : public Vertex, public DummyData {}; class DummySideDef : public SideDef, public DummyData {}; -class DummyLineDef : public LineDef, public DummyData {}; class DummySector : public Sector, public DummyData {}; +class DummyLineDef : public LineDef, public DummyData +{ +public: + DummyLineDef(DummyVertex &v1, DummyVertex &v2) : LineDef(v1, v2) {} +}; + typedef QSet Dummies; static Dummies dummies; +static DummyVertex dummyVertex; // The one dummy vertex. char const *DMU_Str(uint prop) { @@ -209,7 +216,7 @@ void *P_AllocDummy(int type, void *extraData) return ds; } case DMU_LINEDEF: { - DummyLineDef *dl = new DummyLineDef; + DummyLineDef *dl = new DummyLineDef(dummyVertex, dummyVertex); dummies.insert(dl); dl->extraData = extraData; return dl; } diff --git a/doomsday/client/src/map/p_maputil.cpp b/doomsday/client/src/map/p_maputil.cpp index 27d6145bdd..25fd7fed58 100644 --- a/doomsday/client/src/map/p_maputil.cpp +++ b/doomsday/client/src/map/p_maputil.cpp @@ -547,7 +547,7 @@ int PIT_AddLineDefIntercepts(LineDef *line, void * /*parameters*/) // On the correct side of the trace origin? fixed_t linePointX[2] = { DBL2FIX(line->v1Origin()[VX]), DBL2FIX(line->v1Origin()[VY]) }; - fixed_t lineDirectionX[2] = { DBL2FIX(line->direction()[VX]), DBL2FIX(line->direction()[VY]) }; + fixed_t lineDirectionX[2] = { DBL2FIX(line->direction().x), DBL2FIX(line->direction().y) }; float distance = FIX2FLT(V2x_Intersection(linePointX, lineDirectionX, traceLos.origin, traceLos.direction)); diff --git a/doomsday/client/src/map/p_particle.cpp b/doomsday/client/src/map/p_particle.cpp index add11c919f..683e88da3c 100644 --- a/doomsday/client/src/map/p_particle.cpp +++ b/doomsday/client/src/map/p_particle.cpp @@ -1135,8 +1135,8 @@ static void P_MoveParticle(ptcgen_t *gen, particle_t *pt) // - Multiply with bounce. // Calculate the normal. - normal[VX] = -FLT2FIX(ptcHitLine->direction()[VX]); - normal[VY] = -FLT2FIX(ptcHitLine->direction()[VY]); + normal[VX] = -FLT2FIX(ptcHitLine->direction().x); + normal[VY] = -FLT2FIX(ptcHitLine->direction().y); if(!normal[VX] && !normal[VY]) goto quit_iteration; diff --git a/doomsday/client/src/render/r_fakeradio.cpp b/doomsday/client/src/render/r_fakeradio.cpp index fb3c1e6a10..fd39c3f448 100644 --- a/doomsday/client/src/render/r_fakeradio.cpp +++ b/doomsday/client/src/render/r_fakeradio.cpp @@ -144,24 +144,24 @@ void Rend_RadioUpdateVertexShadowOffsets(Vertex &vtx) if(&lineB.v1() == &vtx) { - rightDir[VX] = lineB.direction()[VX]; - rightDir[VY] = lineB.direction()[VY]; + rightDir[VX] = lineB.direction().x; + rightDir[VY] = lineB.direction().y; } else { - rightDir[VX] = -lineB.direction()[VX]; - rightDir[VY] = -lineB.direction()[VY]; + rightDir[VX] = -lineB.direction().x; + rightDir[VY] = -lineB.direction().y; } if(&lineA.v1() == &vtx) { - leftDir[VX] = -lineA.direction()[VX]; - leftDir[VY] = -lineA.direction()[VY]; + leftDir[VX] = -lineA.direction().x; + leftDir[VY] = -lineA.direction().y; } else { - leftDir[VX] = lineA.direction()[VX]; - leftDir[VY] = lineA.direction()[VY]; + leftDir[VX] = lineA.direction().x; + leftDir[VY] = lineA.direction().y; } // The left side is always flipped. diff --git a/doomsday/client/src/render/rend_main.cpp b/doomsday/client/src/render/rend_main.cpp index d5c51f402c..36518559b6 100644 --- a/doomsday/client/src/render/rend_main.cpp +++ b/doomsday/client/src/render/rend_main.cpp @@ -1701,9 +1701,9 @@ static boolean rendHEdgeSection(HEdge *hedge, SideDefSection section, viewData->current.origin[VZ] < WallDivNode_Height(WallDivs_Last(rightWallDivs))) { LineDef const &line = hedge->line(); + coord_t lineDirection[2] = { line.direction().x, line.direction().y }; vec2d_t result; - double pos = V2d_ProjectOnLine(result, mo->origin, line.v1Origin(), - line.direction()); + double pos = V2d_ProjectOnLine(result, mo->origin, line.v1Origin(), lineDirection); if(pos > 0 && pos < 1) { diff --git a/doomsday/client/src/render/rend_particle.cpp b/doomsday/client/src/render/rend_particle.cpp index f3375c2c35..a0aa6ad5fe 100644 --- a/doomsday/client/src/render/rend_particle.cpp +++ b/doomsday/client/src/render/rend_particle.cpp @@ -505,11 +505,11 @@ static void setupModelParamsForParticle(rendmodelparams_t* params, */ static void lineUnitVector(LineDef const &line, pvec2f_t unitVec) { - coord_t len = M_ApproxDistance(line.direction()[VX], line.direction()[VY]); + coord_t len = M_ApproxDistance(line.direction().x, line.direction().y); if(len) { - unitVec[VX] = line.direction()[VX] / len; - unitVec[VY] = line.direction()[VY] / len; + unitVec[VX] = line.direction().x / len; + unitVec[VY] = line.direction().y / len; } else { @@ -751,8 +751,9 @@ static void renderParticles(int rtype, boolean withBlend) // Calculate a new center point (project onto the wall). V2d_Set(origin, FIX2FLT(pt->origin[VX]), FIX2FLT(pt->origin[VY])); - V2d_ProjectOnLine(projected, origin, pt->contact->v1Origin(), - pt->contact->direction()); + + coord_t lineDirection[2] = { pt->contact->direction().x, pt->contact->direction().y }; + V2d_ProjectOnLine(projected, origin, pt->contact->v1Origin(), lineDirection); // Move away from the wall to avoid the worst Z-fighting. double const gap = -1; // 1 map unit. diff --git a/doomsday/server/src/server/sv_pool.cpp b/doomsday/server/src/server/sv_pool.cpp index 2e73254b90..201a4185cc 100644 --- a/doomsday/server/src/server/sv_pool.cpp +++ b/doomsday/server/src/server/sv_pool.cpp @@ -1583,8 +1583,8 @@ coord_t Sv_DeltaDistance(void const *deltaPtr, ownerinfo_t const *info) { SideDef *sideDef = theMap->sideDefs().at(delta->id); LineDef &line = sideDef->line(); - vec2d_t origin; V2d_Set(origin, line.v1Origin()[VX] + line.direction()[VX] / 2, - line.v1Origin()[VY] + line.direction()[VY] / 2); + vec2d_t origin; V2d_Set(origin, line.v1Origin()[VX] + line.direction().x / 2, + line.v1Origin()[VY] + line.direction().y / 2); return M_ApproxDistance(info->origin[VX] - origin[VX], info->origin[VY] - origin[VY]); }