X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fzsortedscene.h;h=a498164cd6bea37806419ed92b59d6aa5cc01ef2;hb=274b6fb1b02692cc422bad9040d1abe5d545505a;hp=f268f5297e3b279e064173c71f938494ade5431a;hpb=54e758597f72544719119e4660af742628645ff6;p=libs%2Fgl.git diff --git a/source/render/zsortedscene.h b/source/render/zsortedscene.h index f268f529..a498164c 100644 --- a/source/render/zsortedscene.h +++ b/source/render/zsortedscene.h @@ -22,8 +22,11 @@ enum DepthReference }; /** -Sorts renderables by their distance from the camera before rendering. Requires -renderables to have a matrix. +A scene which sorts renderables by their distance from the camera before +rendering. + +Renderables must have valid model matrices to be sorted. Those without a +matrix are sorted as closest to the camera. */ class ZSortedScene: public Scene { @@ -34,18 +37,18 @@ private: struct SortedRenderable { Renderable *renderable; - bool in_frustum; - float depth; + bool in_frustum = false; + float depth = 0.0f; - SortedRenderable(Renderable *); + SortedRenderable(Renderable *r): renderable(r) { } bool operator<(const SortedRenderable &o) const { return depth renderables; + std::vector content; SortOrder order = BACK_TO_FRONT; DepthReference reference = FURTHEST; - mutable std::vector sorted_cache; + mutable std::map > sorted_cache; public: virtual void add(Renderable &); @@ -57,10 +60,6 @@ public: /// Sets the reference point for sorting. Default is furthest from camera. void set_reference(DepthReference); -private: - void populate_cache() const; - -public: virtual void setup_frame(Renderer &); virtual void finish_frame();