]> git.tdb.fi Git - libs/gl.git/commitdiff
Rearrange things in ZSortedScene a bit
authorMikko Rasa <tdb@tdb.fi>
Mon, 7 Dec 2015 07:08:05 +0000 (09:08 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 7 Dec 2015 07:11:03 +0000 (09:11 +0200)
source/simplescene.h
source/zsortedscene.cpp
source/zsortedscene.h

index ae7d169e408df3f790cd93f7daa3955b17f033cf..fd834111354635a3c34d29d9158a3faf45042b1a 100644 (file)
@@ -12,7 +12,7 @@ A simple yet efficient scene.  Rendering order is unspecified.
 */
 class SimpleScene: public Scene
 {
-protected:
+private:
        typedef std::set<const Renderable *> RenderableSet;
        typedef std::vector<const Renderable *> RenderableArray;
 
index 709c5c26787478cf260d3257d069550aa38e59e6..f40903dd63375878e4466405dc3a154733ce621a 100644 (file)
@@ -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<float, 3> *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<float, 3> *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
index 5c876697cae9ee3a878c42be2fc48156471ee9ce..b032cbcdf01f08e228846aebb32b3c5b96c60d37 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef MSP_GL_ZSORTEDSCENE_H_
 #define MSP_GL_ZSORTEDSCENE_H_
 
-#include "simplescene.h"
+#include <set>
+#include <vector>
+#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 *);