Skip to content

Commit

Permalink
World|BspLeaf|Client: Added mechanism for linking Lumobjs to BspLeafs
Browse files Browse the repository at this point in the history
Will replace the old mechanism for which in lumobj.cpp
  • Loading branch information
danij-deng committed Sep 5, 2013
1 parent 968134b commit 72b4b78
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 25 deletions.
35 changes: 35 additions & 0 deletions doomsday/client/include/world/bspleaf.h
Expand Up @@ -39,6 +39,7 @@
struct polyobj_s;
#ifdef __CLIENT__
class BiasDigest;
class Lumobj;
#endif

/**
Expand Down Expand Up @@ -79,7 +80,9 @@ class BspLeaf : public de::MapElement
*/
typedef QSet<de::Mesh *> Meshes;
typedef QSet<polyobj_s *> Polyobjs;

#ifdef __CLIENT__
typedef QSet<Lumobj *> Lumobjs;
typedef QSet<LineSide *> ShadowLines;
#endif

Expand Down Expand Up @@ -419,6 +422,38 @@ class BspLeaf : public de::MapElement
*/
AudioEnvironmentFactors const &reverb() const;

/**
* Clear all lumobj links for the BSP leaf.
*/
void clearLumobjs();

/**
* Unlink the specified @a lumobj in the BSP leaf. If the lumobj is not
* linked then nothing will happen.
*
* @param lumobj Lumobj to unlink.
*
* @see linkLumobj()
*/
void unlinkLumobj(Lumobj &lumobj);

/**
* Link the specified @a lumobj in the BSP leaf. If the lumobj is already
* linked then nothing will happen.
*
* @param lumobj Lumobj to link.
*
* @see lumobjs(), unlinkLumobj()
*/
void linkLumobj(Lumobj &lumobj);

/**
* Provides access to the set of lumobjs linked to the BSP leaf.
*
* @see linkLumobj(), clearLumobjs()
*/
Lumobjs const &lumobjs() const;

/**
* Clear the list of fake radio shadow line sides for the BSP leaf.
*/
Expand Down
56 changes: 31 additions & 25 deletions doomsday/client/src/world/bspleaf.cpp
Expand Up @@ -62,41 +62,26 @@ typedef QMap<int, GeometryGroup> GeometryGroups;

DENG2_PIMPL(BspLeaf)
{
/// Attributed sector cluster if any (not owned).
SectorCluster *cluster;
SectorCluster *cluster; ///< Attributed cluster (if any, not owned).

/// Convex polygon geometry attributed to the BSP leaf if any (not owned).
Face *poly;

/// Additional meshes assigned to the BSP leaf (owned).
Meshes extraMeshes;
Face *poly; ///< Convex polygon geometry (if any, not owned).
Meshes extraMeshes; ///< Additional meshes (owned).
Polyobjs polyobjs; ///< Linked polyobjs (if any, not owned).

/// Offset to align the top left of materials in the built geometry to the
/// map coordinate space grid.
Vector2d worldGridOffset;

/// Set of polyobjs linked to the leaf (not owned).
Polyobjs polyobjs;

#ifdef __CLIENT__
HEdge *fanBase; ///< Trifan base Half-edge (otherwise the center point is used).

/// Half-edge whose vertex to use as the base for a trifan.
/// If @c 0 the center point will be used instead.
HEdge *fanBase;

bool needUpdateFanBase; ///< @c true= need to rechoose a fan base half-edge.
bool needUpdateFanBase; ///< @c true= need to rechoose a fan base half-edge.
int addSpriteCount; ///< Frame number of last R_AddSprites.

/// Frame number of last R_AddSprites.
int addSpriteCount;

/// Bias lighting data for each geometry group (i.e., each plane).
GeometryGroups geomGroups;

/// Set of fake radio shadow lines.
ShadowLines shadowLines;

/// Final audio environment characteristics.
AudioEnvironmentFactors reverb;
Lumobjs lumobjs; ///< Linked lumobjs (not owned).
ShadowLines shadowLines; ///< Linked map lines for fake radio shadowing.
AudioEnvironmentFactors reverb; ///< Cached characteristics.

#endif // __CLIENT__

Expand Down Expand Up @@ -669,6 +654,27 @@ BspLeaf::ShadowLines const &BspLeaf::shadowLines() const
return d->shadowLines;
}

void BspLeaf::clearLumobjs()
{
d->lumobjs.clear();
}

void BspLeaf::unlinkLumobj(Lumobj &lumobj)
{
d->lumobjs.remove(&lumobj);
}

void BspLeaf::linkLumobj(Lumobj &lumobj)
{
if(isDegenerate()) return;
d->lumobjs.insert(&lumobj);
}

BspLeaf::Lumobjs const &BspLeaf::lumobjs() const
{
return d->lumobjs;
}

int BspLeaf::lastSpriteProjectFrame() const
{
return d->addSpriteCount;
Expand Down

0 comments on commit 72b4b78

Please sign in to comment.