From: Mikko Rasa Date: Mon, 7 Dec 2015 07:08:05 +0000 (+0200) Subject: Rearrange things in ZSortedScene a bit X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=041717fbfb7d9a46459f15ecc55a5520f84d006c;p=libs%2Fgl.git Rearrange things in ZSortedScene a bit --- diff --git a/source/simplescene.h b/source/simplescene.h index ae7d169e..fd834111 100644 --- a/source/simplescene.h +++ b/source/simplescene.h @@ -12,7 +12,7 @@ A simple yet efficient scene. Rendering order is unspecified. */ class SimpleScene: public Scene { -protected: +private: typedef std::set RenderableSet; typedef std::vector RenderableArray; diff --git a/source/zsortedscene.cpp b/source/zsortedscene.cpp index 709c5c26..f40903dd 100644 --- a/source/zsortedscene.cpp +++ b/source/zsortedscene.cpp @@ -62,19 +62,19 @@ void ZSortedScene::render(Renderer &renderer, const Tag &tag) const for(SortedArray::iterator i=sorted_cache.begin(); i!=sorted_cache.end(); ++i) { i->in_frustum = (!use_frustum || !frustum_cull(*i->renderable)); - if(i->in_frustum) + if(!i->in_frustum) + continue; + + if(const Matrix *matrix = i->renderable->get_matrix()) { - if(const Matrix *model_matrix = i->renderable->get_matrix()) - { - if(const Geometry::BoundingSphere *bsphere = i->renderable->get_bounding_sphere()) - i->depth = dot(*model_matrix*bsphere->get_center()-camera_pos, look_dir)+bsphere->get_radius()*radius_factor; - else - i->depth = dot(*model_matrix*Vector3()-camera_pos, look_dir); - i->depth *= sign; - } + if(const Geometry::BoundingSphere *bsphere = i->renderable->get_bounding_sphere()) + i->depth = dot(*matrix*bsphere->get_center()-camera_pos, look_dir)+bsphere->get_radius()*radius_factor; else - i->depth = 0; + i->depth = dot(*matrix*Vector3()-camera_pos, look_dir); + i->depth *= sign; } + else + i->depth = 0; } for(SortedArray::iterator i=sorted_cache.begin(), j=i; i!=sorted_cache.end(); ++i) @@ -105,9 +105,9 @@ void ZSortedScene::render(Renderer &renderer, const Tag &tag) const ZSortedScene::SortedRenderable::SortedRenderable(const Renderable *r): + renderable(r), in_frustum(false), - depth(0.0f), - renderable(r) + depth(0.0f) { } } // namespace GL diff --git a/source/zsortedscene.h b/source/zsortedscene.h index 5c876697..b032cbcd 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 { @@ -28,9 +30,9 @@ class ZSortedScene: public Scene private: struct SortedRenderable { + const Renderable *renderable; bool in_frustum; float depth; - const Renderable *renderable; SortedRenderable(const Renderable *);