Skip to content

Commit

Permalink
Renderer|Shard: Defined SectorCluster/Shard relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 29, 2014
1 parent f1751c6 commit 446f603
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
25 changes: 22 additions & 3 deletions doomsday/client/include/render/shard.h
Expand Up @@ -22,20 +22,39 @@
#include <QList>
#include <de/Matrix>
#include <de/Vector>
#include "MapElement"

class BiasDigest;
class BiasSource;
class SectorCluster;

/**
* 3D map geometry fragment.
*
* Shards are produced and (perhaps owned) by SectorClusters when the map geometry
* is split into drawable geometry fragments. Shard ownership may be transferred
* however a shard should never outlive the MapElement for which it was produced.
*
* @todo Shard should not need to know the MapElement it was produced for.
*/
class Shard
{
public:
/**
* Construct a new Shard of 3D map geometry.
*
* @param mapElement MapElement for which this is geometry fragment.
* @param geomId MapElement-unique geometry id number.
* @param numBiasIllums Number of bias illumination points for the geometry.
* @param owner SectorCluster which owns the shard (if any).
*/
Shard(de::MapElement &mapElement, int geomId, int numBiasIllums,
SectorCluster *owner = 0);

/**
* Change SectorCluster which owns the shard to @a newOwner.
*/
Shard(int numBiasIllums);
void setCluster(SectorCluster *newOwner);

/**
* Perform bias lighting for the supplied vertex geometry.
Expand All @@ -57,14 +76,14 @@ class Shard
de::Matrix3f const &tangentMatrix, uint biasTime);

/**
* Apply bias lighting changes to the Shard.
* Apply bias lighting changes to the shard.
*
* @param changes Digest of lighting changes to be applied.
*/
void applyBiasDigest(BiasDigest &changes);

/**
* Schedule a bias lighting update for the Shard following a move.
* Schedule a bias lighting update for the shard following a move.
*/
void updateBiasAfterMove();

Expand Down
28 changes: 25 additions & 3 deletions doomsday/client/src/render/shard.cpp
Expand Up @@ -21,22 +21,39 @@
#include "BiasDigest"
#include "BiasIllum"
#include "BiasTracker"
#include "SectorCluster"

using namespace de;

DENG2_PIMPL_NOREF(Shard)
{
MapElement &mapElement;
int geomId;

SectorCluster *owner;

BiasTracker biasTracker;
typedef QList<BiasIllum *> BiasIllums;
BiasIllums biasIllums;
uint biasLastUpdateFrame;

Instance() : biasLastUpdateFrame(0) {}
~Instance() { qDeleteAll(biasIllums); }
Instance(MapElement &mapElement, int geomId)
: mapElement (mapElement)
, geomId (geomId)
, owner (0)
, biasLastUpdateFrame(0)
{}

~Instance()
{
qDeleteAll(biasIllums);
}
};

Shard::Shard(int numBiasIllums) : d(new Instance)
Shard::Shard(MapElement &mapElement, int geomId, int numBiasIllums, SectorCluster *owner)
: d(new Instance(mapElement, geomId))
{
setCluster(owner);
if(numBiasIllums)
{
d->biasIllums.reserve(numBiasIllums);
Expand All @@ -47,6 +64,11 @@ Shard::Shard(int numBiasIllums) : d(new Instance)
}
}

void Shard::setCluster(SectorCluster *newOwner)
{
d->owner = newOwner;
}

void Shard::lightWithBiasSources(Vector3f const *posCoords, Vector4f *colorCoords,
Matrix3f const &tangentMatrix, uint biasTime)
{
Expand Down
4 changes: 3 additions & 1 deletion doomsday/client/src/world/sectorcluster.cpp
Expand Up @@ -768,7 +768,9 @@ DENG2_PIMPL(SectorCluster)
foundGroup = geomGroups.insert(&mapElement, Shards());
}

Shard *newShard = new Shard(countIlluminationPoints(mapElement, geomId));
Shard *newShard = new Shard(mapElement, geomId,
countIlluminationPoints(mapElement, geomId),
thisPublic);
foundGroup->insert(geomId, newShard);
return newShard;
}
Expand Down

0 comments on commit 446f603

Please sign in to comment.