Skip to content

Commit

Permalink
Fixed|BSP Builder|ConvexSubspace: Failed to partition a map with over…
Browse files Browse the repository at this point in the history
…lapped single sided lines

When two or more single sided lines are overlapping and reference the
same sector, depending on how the map is partitioned it may result in
a degenerate set of line segments. In this situation, separating the
discordant segs into an "extra" mesh geometry may mean we are left
with fewer than three to produce the primary convex polygon geometry
for a BSP leaf. In which case, we shouldn't attempt to assign a non-
convex polygon.

BLUDWRKS.wad once again loads (and very nearly rendered correctly).
  • Loading branch information
danij-deng committed Sep 27, 2013
1 parent 07e5666 commit 6b42cf4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 0 additions & 6 deletions doomsday/client/include/world/sector.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,6 @@ class Sector : public de::MapElement
*/
inline int clusterCount() const { return clusters().count(); }

/**
* Convenient method of determning whether the sector is a parent of one or
* BSP leaf (i.e., at least one cluster is defined).
*/
inline bool hasBspLeafs() const { return clusterCount() != 0; }

/**
* (Re)Build BSP leaf clusters for the sector.
*/
Expand Down
4 changes: 3 additions & 1 deletion doomsday/client/src/render/walledge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ DENG2_PIMPL(WallEdge), public IHPlane
(line.definesPolyobj()? &line.polyobj().bspLeaf()
: &hedge->face().mapElement()->as<BspLeaf>())->clusterPtr();

if(seg.lineSide().considerOneSided())
if(seg.lineSide().considerOneSided() ||
// Mapping errors may result in a line segment missing a back face.
(!line.definesPolyobj() && !hedge->twin().hasFace()))
{
if(spec.section == LineSide::Middle)
{
Expand Down
10 changes: 7 additions & 3 deletions doomsday/client/src/world/bsp/convexsubspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,9 @@ void ConvexSubspace::addOneSegment(LineSegment::Side const &newSegment)
void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
{
LOG_AS("ConvexSubspace::buildGeometry");
bool const isDegenerate = segmentCount() < 3;

// Sanity check.
if(!isDegenerate && !d->haveMapLineSegment())
if(segmentCount() >= 3 && !d->haveMapLineSegment())
throw Error("ConvexSubspace::buildGeometry", "No map line segment");

if(d->needRebuildOrderedSegments)
Expand Down Expand Up @@ -415,6 +414,7 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
conty->addOneSegment(oseg);
}

int extraMeshSegments = 0;
for(int i = 0; i < continuities.count(); ++i)
{
Continuity &conty = continuities[i];
Expand All @@ -441,6 +441,9 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const

HEdge *hedge = extraMesh->newHEdge(lineSeg->from());
LineSideSegment *seg = mapSide->addSegment(*hedge);

extraMeshSegments += 1;

#ifdef __CLIENT__
/// @todo LineSide::newSegment() should encapsulate:
seg->setLineSideOffset(Vector2d(mapSide->from().origin() - lineSeg->from().origin()).length());
Expand Down Expand Up @@ -519,7 +522,7 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
}
#endif*/

if(!isDegenerate)
if(segmentCount() - extraMeshSegments >= 3)
{
// Construct a new face and a ring of half-edges.
Face *face = mesh.newFace();
Expand All @@ -529,6 +532,7 @@ void ConvexSubspace::buildGeometry(BspLeaf &leaf, Mesh &mesh) const
{
LineSegment::Side *lineSeg = d->orderedSegments[i].segment;

// Already added this to an extra mesh?
if(lineSeg->hasHEdge())
continue;

Expand Down

0 comments on commit 6b42cf4

Please sign in to comment.