Skip to content

Commit

Permalink
World|WorldSystem|Client: WorldSystem owns the SkyDrawable::Animator
Browse files Browse the repository at this point in the history
Pass the Sky being drawn to SkyDrawable (once the animation state of
the drawable is fully encapsulated by the animator we'll pass that).
  • Loading branch information
danij-deng committed Sep 1, 2014
1 parent f017064 commit 5ba0abc
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 125 deletions.
23 changes: 6 additions & 17 deletions doomsday/client/include/render/skydrawable.h
Expand Up @@ -43,13 +43,10 @@ class Sky;
class SkyDrawable
{
public:
/// No animator is presently configured. @ingroup errors
DENG2_ERROR(MissingAnimatorError);

/// Required model is missing. @ingroup errors
DENG2_ERROR(MissingModelError);

struct ModelInfo
struct ModelData
{
de::Record const *def; // Sky model def
ModelDef *model;
Expand Down Expand Up @@ -88,10 +85,6 @@ class SkyDrawable
public:
SkyDrawable();

bool hasAnimator() const;
void setAnimator(Animator *newAnimator);
Animator &animator();

/**
* Models are set up according to the given @a skyDef.
*/
Expand All @@ -100,12 +93,12 @@ class SkyDrawable
/**
* Cache all assets needed for visualizing the sky.
*/
void cacheDrawableAssets();
void cacheDrawableAssets(Sky const *sky = 0);

/**
* Render the sky.
*/
void draw();
void draw(Sky const *sky = 0) const;

/**
* Determines whether the specified sky model @a index is valid.
Expand All @@ -119,21 +112,17 @@ class SkyDrawable
*
* @see hasModel()
*/
ModelInfo &model(int index);
ModelData &model(int index);

/// @copydoc model()
ModelInfo const &model(int index) const;
ModelData const &model(int index) const;

/**
* Returns a pointer to the referenced sky model; otherwise @c 0.
*
* @see hasModel(), model()
*/
inline ModelInfo *modelPtr(int index) { return hasModel(index)? &model(index) : 0; }

/// @todo RenderSystem should own a sky-masked-material => SkyDrawable map.
void setSky(Sky *sky);
Sky &sky();
inline ModelData *modelPtr(int index) { return hasModel(index)? &model(index) : 0; }

public:
static de::MaterialVariantSpec const &layerMaterialSpec(bool masked);
Expand Down
4 changes: 4 additions & 0 deletions doomsday/client/include/world/p_ticker.h
Expand Up @@ -20,6 +20,10 @@
#ifndef DENG_WORLD_P_TICKER_H
#define DENG_WORLD_P_TICKER_H

#include "world/thinkers.h"

int P_MobjTicker(thinker_t *th, void *context);

/**
* Doomsday's own play-ticker.
*/
Expand Down
12 changes: 8 additions & 4 deletions doomsday/client/include/world/worldsystem.h
Expand Up @@ -74,10 +74,6 @@ class WorldSystem : public de::System
// System.
void timeChanged(de::Clock const &);

/**
* To be called to register the commands and variables of this module.
*/
static void consoleRegister();

/**
* To be called to reset the world back to the initial state. Any currently
Expand Down Expand Up @@ -131,6 +127,8 @@ class WorldSystem : public de::System
*/
timespan_t time() const;

void tick(timespan_t elapsed);

#ifdef __CLIENT__
/**
* To be called at the beginning of a render frame, so that we can prepare for
Expand Down Expand Up @@ -164,6 +162,12 @@ class WorldSystem : public de::System

#endif // __CLIENT__

public:
/**
* To be called to register the commands and variables of this module.
*/
static void consoleRegister();

private:
DENG2_PRIVATE(d)
};
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -3465,7 +3465,7 @@ static void drawLists(DrawLists::FoundLists const &lists, DrawMode mode)
popGLStateForPass(mode);
}

static void drawSky()
static void drawSky(Sky const &sky)
{
DrawLists::FoundLists lists;
ClientApp::renderSystem().drawLists().findAll(SkyMaskGeom, lists);
Expand Down Expand Up @@ -3503,7 +3503,7 @@ static void drawSky()
glStencilFunc(GL_EQUAL, 1, 0xffffffff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

ClientApp::renderSystem().sky().draw();
ClientApp::renderSystem().sky().draw(&sky);

if(!devRendSkyAlways)
{
Expand Down Expand Up @@ -3634,7 +3634,7 @@ static void drawAllLists(Map &map)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

drawSky();
drawSky(map.sky());

// Render the real surfaces of the visible world.

Expand Down
6 changes: 0 additions & 6 deletions doomsday/client/src/render/rendersystem.cpp
Expand Up @@ -90,10 +90,7 @@ uint Store::allocateVertices(uint count)
DENG2_PIMPL(RenderSystem)
{
ModelRenderer models;

SkyDrawable sky;
SkyDrawable::Animator skyAnimator;

SettingsRegister settings;
SettingsRegister appearanceSettings;
ImageBank images;
Expand Down Expand Up @@ -222,9 +219,6 @@ DENG2_PIMPL(RenderSystem)
.define(SReg::IntCVar, "rend-particle-visible-near", 0)

.define(SReg::FloatCVar, "rend-sky-distance", 1600);

skyAnimator.setSky(&sky);
sky.setAnimator(&skyAnimator);
}

/**
Expand Down

0 comments on commit 5ba0abc

Please sign in to comment.