Skip to content

Commit

Permalink
World|BspLeaf: Simplified BspLeaf (no need for pimpl here)
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Oct 22, 2014
1 parent 9c14991 commit 3951887
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/world/bspleaf.h
Expand Up @@ -99,7 +99,7 @@ class BspLeaf : public de::MapElement
Sector const *sectorPtr() const;

private:
DENG2_PRIVATE(d)
ConvexSubspace *_subspace;
};

#endif // DENG_WORLD_BSPLEAF_H
24 changes: 9 additions & 15 deletions doomsday/client/src/world/bspleaf.cpp
Expand Up @@ -27,46 +27,40 @@

using namespace de;

DENG2_PIMPL_NOREF(BspLeaf)
{
ConvexSubspace *subspace;
};

BspLeaf::BspLeaf(Sector *sector)
: MapElement(DMU_BSPLEAF, sector), d(new Instance)
{
d->subspace = 0;
}
: MapElement(DMU_BSPLEAF, sector)
, _subspace(0)
{}

bool BspLeaf::hasSubspace() const
{
return d->subspace != 0;
return _subspace != 0;
}

ConvexSubspace &BspLeaf::subspace() const
{
if(hasSubspace())
{
return *d->subspace;
return *_subspace;
}
/// @throw MissingSubspaceError Attempted with no subspace attributed.
throw MissingSubspaceError("BspLeaf::subspace", "No subspace is attributed");
}

void BspLeaf::setSubspace(ConvexSubspace *newSubspace)
{
if(d->subspace == newSubspace) return;
if(_subspace == newSubspace) return;

if(hasSubspace())
{
d->subspace->setBspLeaf(0);
_subspace->setBspLeaf(0);
}

d->subspace = newSubspace;
_subspace = newSubspace;

if(hasSubspace())
{
d->subspace->setBspLeaf(this);
_subspace->setBspLeaf(this);
}
}

Expand Down

0 comments on commit 3951887

Please sign in to comment.