X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fzsortedscene.h;h=d417777e0a9c8f37c3de1b5c4b778df17a0aa61f;hb=d386eadfd08b556ecb05627a7ceca14652e8b1e5;hp=f9f6f7eed40bd9cfa527540c5417c6fbce3ae75e;hpb=c87860db3b23a98eda1adfe59acddffdb6eb8420;p=libs%2Fgl.git diff --git a/source/zsortedscene.h b/source/zsortedscene.h index f9f6f7ee..d417777e 100644 --- a/source/zsortedscene.h +++ b/source/zsortedscene.h @@ -1,7 +1,9 @@ #ifndef MSP_GL_ZSORTEDSCENE_H_ #define MSP_GL_ZSORTEDSCENE_H_ -#include "simplescene.h" +#include +#include +#include "scene.h" namespace Msp { namespace GL { @@ -23,25 +25,34 @@ enum DepthReference Sorts renderables by their distance from the camera before rendering. Requires renderables to have a matrix. */ -class ZSortedScene: public SimpleScene +class ZSortedScene: public Scene { private: - struct DepthRenderable + struct SortedRenderable { + Renderable *renderable; + bool in_frustum; float depth; - const Renderable *renderable; - DepthRenderable(float, const Renderable *); + SortedRenderable(Renderable *); - bool operator<(const DepthRenderable &o) const { return depth RenderableSet; + typedef std::vector SortedArray; + + RenderableSet renderables; SortOrder order; DepthReference reference; + mutable SortedArray sorted_cache; public: ZSortedScene(); + virtual void add(Renderable &); + virtual void remove(Renderable &); + /// Sets the sort order. Default is back to front. void set_order(SortOrder);