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
{
+ bool in_frustum;
float depth;
const Renderable *renderable;
- DepthRenderable(float, const Renderable *);
+ SortedRenderable(const Renderable *);
- bool operator<(const DepthRenderable &o) const { return depth<o.depth; }
+ bool operator<(const SortedRenderable &o) const { return depth<o.depth; }
};
+ typedef std::set<const Renderable *> RenderableSet;
+ typedef std::vector<SortedRenderable> SortedArray;
+
+ RenderableSet renderables;
SortOrder order;
DepthReference reference;
+ mutable SortedArray sorted_cache;
public:
ZSortedScene();
+ virtual void add(const Renderable &);
+ virtual void remove(const Renderable &);
+
/// Sets the sort order. Default is back to front.
void set_order(SortOrder);