From 72b4b78f3267d74ff89c6df164ec24c53af06d59 Mon Sep 17 00:00:00 2001 From: danij Date: Thu, 5 Sep 2013 22:34:44 +0100 Subject: [PATCH] World|BspLeaf|Client: Added mechanism for linking Lumobjs to BspLeafs Will replace the old mechanism for which in lumobj.cpp --- doomsday/client/include/world/bspleaf.h | 35 ++++++++++++++++ doomsday/client/src/world/bspleaf.cpp | 56 ++++++++++++++----------- 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/doomsday/client/include/world/bspleaf.h b/doomsday/client/include/world/bspleaf.h index 56c8658543..4f4a820f9f 100644 --- a/doomsday/client/include/world/bspleaf.h +++ b/doomsday/client/include/world/bspleaf.h @@ -39,6 +39,7 @@ struct polyobj_s; #ifdef __CLIENT__ class BiasDigest; +class Lumobj; #endif /** @@ -79,7 +80,9 @@ class BspLeaf : public de::MapElement */ typedef QSet Meshes; typedef QSet Polyobjs; + #ifdef __CLIENT__ + typedef QSet Lumobjs; typedef QSet ShadowLines; #endif @@ -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. */ diff --git a/doomsday/client/src/world/bspleaf.cpp b/doomsday/client/src/world/bspleaf.cpp index c3a6bdaffb..31167085c9 100644 --- a/doomsday/client/src/world/bspleaf.cpp +++ b/doomsday/client/src/world/bspleaf.cpp @@ -62,41 +62,26 @@ typedef QMap 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__ @@ -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;