Skip to content

Commit

Permalink
Client|Map Renderer: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 10, 2013
1 parent f82c94f commit a82ba6c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 37 deletions.
1 change: 0 additions & 1 deletion doomsday/client/include/de_play.h
Expand Up @@ -30,7 +30,6 @@
#include "Line"
#include "world/linesighttest.h"
#include "Plane"
#include "Segment"
#include "BspNode"
#include "Sector"
#include "Polyobj"
Expand Down
1 change: 0 additions & 1 deletion doomsday/client/include/render/rend_fakeradio.h
Expand Up @@ -34,7 +34,6 @@
#ifndef DENG_RENDER_FAKERADIO
#define DENG_RENDER_FAKERADIO

#include "Segment"
#include "Line"
#include "Sector"
#include "Vertex"
Expand Down
1 change: 0 additions & 1 deletion doomsday/client/include/world/map.h
Expand Up @@ -41,7 +41,6 @@ class BspNode;
class Line;
class Plane;
class Sector;
class Segment;
class Vertex;

#ifdef __CLIENT__
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/rend_fakeradio.cpp
Expand Up @@ -161,7 +161,7 @@ static inline float calcTexCoordY(float z, float bottom, float top, float texHei
return bottom - z;
}

/// @todo This algorithm should be rewritten to work at Segment level.
/// @todo This algorithm should be rewritten to work at half-edge level.
static void scanNeighbor(bool scanTop, Line::Side const &side, edge_t *edge,
bool toLeft)
{
Expand Down
48 changes: 23 additions & 25 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -52,6 +52,7 @@
#include "world/thinkers.h"
#include "BspLeaf"
#include "BspNode"
#include "Segment"

#include "HueCircleVisual"
#include "SkyFixEdge"
Expand Down Expand Up @@ -1384,8 +1385,10 @@ static void writeWallSection(Segment &segment, int section,
if(retBottomZ) *retBottomZ = 0;
if(retTopZ) *retTopZ = 0;

Line::Side &side = segment.lineSide();
Surface &surface = side.surface(section);
HEdge &hedge = segment.hedge();
Line::Side &side = segment.lineSide();
Surface &surface = side.surface(section);
BiasSurface &bsuf = segment;

// Skip nearly transparent surfaces.
float opacity = surface.opacity();
Expand All @@ -1402,8 +1405,8 @@ static void writeWallSection(Segment &segment, int section,
// Generate edge geometries.
WallSpec const wallSpec = WallSpec::fromMapSide(side, section);

WallEdge leftEdge(wallSpec, segment.hedge(), Line::From);
WallEdge rightEdge(wallSpec, segment.hedge(), Line::To);
WallEdge leftEdge(wallSpec, hedge, Line::From);
WallEdge rightEdge(wallSpec, hedge, Line::To);

// Do the edge geometries describe a valid polygon?
if(!leftEdge.isValid() || !rightEdge.isValid() ||
Expand Down Expand Up @@ -1435,7 +1438,7 @@ static void writeWallSection(Segment &segment, int section,
parm.flags = RPF_DEFAULT | (skyMasked? RPF_SKYMASK : 0);
parm.forceOpaque = wallSpec.flags.testFlag(WallSpec::ForceOpaque);
parm.alpha = parm.forceOpaque? 1 : opacity;
parm.bsuf = &segment;
parm.bsuf = &bsuf;
parm.geomGroup = wallSpec.section;
parm.texTL = &texQuad[0];
parm.texBR = &texQuad[1];
Expand Down Expand Up @@ -1823,8 +1826,6 @@ static void writeLeafSkyMaskStrips(SkyFixEdge::FixType fixType)
HEdge *hedge = base;
forever
{
Segment &seg = *hedge->mapElement()->as<Segment>();

// Are we monitoring material changes?
Material *skyMaterial = 0;
if(splitOnMaterialChange)
Expand All @@ -1835,7 +1836,7 @@ static void writeLeafSkyMaskStrips(SkyFixEdge::FixType fixType)
// Add a first (left) edge to the current strip?
if(startNode == 0)
{
startMaterialOffset = seg.lineSideOffset();
startMaterialOffset = hedge->mapElement()->as<Segment>()->lineSideOffset();

// Prepare the edge geometry
SkyFixEdge skyEdge(*hedge, fixType, (direction == Anticlockwise)? Line::To : Line::From,
Expand All @@ -1860,7 +1861,8 @@ static void writeLeafSkyMaskStrips(SkyFixEdge::FixType fixType)
// Add the i'th (right) edge to the current strip?
if(startNode != 0)
{
startMaterialOffset += seg.length() * (direction == Anticlockwise? -1 : 1);
startMaterialOffset +=
hedge->mapElement()->as<Segment>()->length() * (direction == Anticlockwise? -1 : 1);

// Prepare the edge geometry
SkyFixEdge skyEdge(*hedge, fixType, (direction == Anticlockwise)? Line::From : Line::To,
Expand Down Expand Up @@ -2003,20 +2005,16 @@ static void writeLeafSkyMask(int skyCap = SKYCAP_LOWER|SKYCAP_UPPER)
}
}

static bool coveredOpenRange(Segment &segment, coord_t middleBottomZ, coord_t middleTopZ,
static bool coveredOpenRange(HEdge &hedge, coord_t middleBottomZ, coord_t middleTopZ,
bool wroteOpaqueMiddle)
{
HEdge &hedge = segment.hedge();
Line::Side const &front = segment.lineSide();
Line::Side const &front = hedge.mapElement()->as<Segment>()->lineSide();

if(front.considerOneSided())
{
return wroteOpaqueMiddle;
}

//if(segment.line().isSelfReferencing())
// return false; /// @todo Why? -ds

Sector const &frontSec = hedge.face().mapElement()->as<BspLeaf>()->sector();
Sector const &backSec = hedge.twin().face().mapElement()->as<BspLeaf>()->sector();

Expand Down Expand Up @@ -2113,7 +2111,7 @@ static void writeWallSectionsForFace(Face const &face)
// line segment if the open range has been covered (when the viewer
// is not in the void).
if(!P_IsInVoid(viewPlayer) &&
coveredOpenRange(*seg, middleBottomZ, middleTopZ, wroteOpaqueMiddle))
coveredOpenRange(*hedge, middleBottomZ, middleTopZ, wroteOpaqueMiddle))
{
C_AddRangeFromViewRelPoints(hedge->origin(), hedge->twin().origin());
}
Expand Down Expand Up @@ -3157,12 +3155,13 @@ static void drawTangentSpaceVectorsForSurface(Surface *suf, Vector3d const &orig
glPopMatrix();
}

static void drawTangentSpaceVectorsForSegment(Segment *seg)
static void drawTangentSpaceVectorsForHEdge(HEdge *hedge)
{
if(!seg || !seg->hasLineSide() || seg->line().definesPolyobj())
return;
if(!hedge) return;

HEdge *hedge = &seg->hedge();
Segment *seg = hedge->mapElement()->as<Segment>();
if(!seg->hasLineSide() || seg->line().definesPolyobj())
return;

if(!hedge->twin().hasFace() || !hedge->twin().face().mapElement()->as<BspLeaf>()->hasSector())
{
Expand Down Expand Up @@ -3222,14 +3221,13 @@ static void drawTangentSpaceVectorsForSegment(Segment *seg)
}
}

static void drawTangentSpaceVectorsForFace(Face const &face)
static void drawTangentSpaceVectorsForHEdgesByFace(Face const &face)
{
HEdge *base = face.hedge();
HEdge *hedge = base;
do
{
DENG_ASSERT(hedge->mapElement() != 0);
drawTangentSpaceVectorsForSegment(hedge->mapElement()->as<Segment>());
drawTangentSpaceVectorsForHEdge(hedge);
} while((hedge = &hedge->next()) != base);
}

Expand All @@ -3248,12 +3246,12 @@ static void Rend_DrawSurfaceVectors(Map &map)
if(!bspLeaf->hasSector() || bspLeaf->isDegenerate())
continue;

drawTangentSpaceVectorsForFace(bspLeaf->poly());
drawTangentSpaceVectorsForHEdgesByFace(bspLeaf->poly());

foreach(Mesh *mesh, bspLeaf->extraMeshes())
foreach(Face *face, mesh->faces())
{
drawTangentSpaceVectorsForFace(*face);
drawTangentSpaceVectorsForHEdgesByFace(*face);
}
}

Expand Down
12 changes: 6 additions & 6 deletions doomsday/client/src/render/skyfixedge.cpp
Expand Up @@ -120,13 +120,13 @@ DENG2_PIMPL(SkyFixEdge)

bool const lower = fixType == SkyFixEdge::Lower;

Segment *segment = hedge->mapElement()->as<Segment>();

// Partition line segments have no map line sides.
Segment *segment = hedge->mapElement()->as<Segment>();
if(!segment->hasLineSide()) return false;

Sector const *frontSec = hedge->face().mapElement()->as<BspLeaf>()->sectorPtr();
Sector const *backSec = hedge->twin().hasFace()? hedge->twin().face().mapElement()->as<BspLeaf>()->sectorPtr() : 0;
Line::Side const &lineSide = segment->lineSide();
Sector const *frontSec = hedge->face().mapElement()->as<BspLeaf>()->sectorPtr();
Sector const *backSec = hedge->twin().hasFace()? hedge->twin().face().mapElement()->as<BspLeaf>()->sectorPtr() : 0;

if(!(!backSec || backSec != frontSec)) return false;

Expand All @@ -138,7 +138,7 @@ DENG2_PIMPL(SkyFixEdge)
if(!front->surface().hasSkyMaskedMaterial())
return false;

bool const hasClosedBack = R_SideBackClosed(segment->lineSide());
bool const hasClosedBack = R_SideBackClosed(lineSide);

if(!devRendSkyMode)
{
Expand All @@ -150,7 +150,7 @@ DENG2_PIMPL(SkyFixEdge)
{
int relSection = lower? Line::Side::Bottom : Line::Side::Top;

if(segment->lineSide().surface(relSection).hasMaterial() ||
if(lineSide.surface(relSection).hasMaterial() ||
!(hasClosedBack || (back && back->surface().hasSkyMaskedMaterial())))
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/world/bsp/linesegment.cpp
Expand Up @@ -29,7 +29,7 @@

#include <de/Observers>

#include "Segment"
#include "Segment" /// @todo remove me
#include "world/bsp/convexsubspace.h"
#include "world/bsp/superblockmap.h"

Expand Down
1 change: 0 additions & 1 deletion doomsday/client/src/world/sector.cpp
Expand Up @@ -29,7 +29,6 @@
#include "BspLeaf"
#include "Line"
#include "Plane"
#include "Segment"

#include "world/map.h"
#include "world/p_object.h"
Expand Down

0 comments on commit a82ba6c

Please sign in to comment.