]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Octree.hh
new lua scripting for scene loading
[chaz/yoink] / src / Moof / Octree.hh
index 4dc0c5c7e460e801594585200e47d3a70bc34064..e69e1edf817b67e7b4567ac508e88883ea7de52c 100644 (file)
@@ -39,6 +39,7 @@
 #include <Moof/Aabb.hh>
 #include <Moof/Drawable.hh>
 #include <Moof/Entity.hh>
+#include <Moof/Log.hh>
 #include <Moof/Math.hh>
 #include <Moof/Sphere.hh>
        
@@ -46,7 +47,7 @@
 namespace Mf {
 
 
-class Camera;
+class Frustum;
 
 
 struct OctreeNode;
@@ -87,25 +88,28 @@ struct OctreeNode : public Entity
                        aabb_.draw(); // temporary
        }
 
-       void drawIfVisible(Scalar alpha, const Camera& cam) const
+       void drawIfVisible(Scalar alpha, const Frustum& frustum) const
        {
                std::list<EntityP>::const_iterator it;
 
                for (it = objects.begin(); it != objects.end(); ++it)
                {
-                       (*it)->drawIfVisible(alpha, cam);
+                       (*it)->drawIfVisible(alpha, frustum);
                }
 
                if (!objects.empty())
+               {
                        aabb_.draw();
+                       sphere_.draw();
+               }
        }
 
 
-       bool isVisible(const Camera& cam) const
+       bool isVisible(const Frustum& frustum) const
        {
-               if (sphere_.isVisible(cam))
+               if (sphere_.isVisible(frustum))
                {
-                       return aabb_.isVisible(cam);
+                       return aabb_.isVisible(frustum);
                }
 
                return false;
@@ -132,13 +136,20 @@ class Octree
        void addChild(OctreeNodeP node, int index);
 
        void draw(Scalar alpha, OctreeNodeP node);
-       void drawIfVisible(Scalar alpha, const Camera& cam, OctreeNodeP node);
+       void drawIfVisible(Scalar alpha, const Frustum& frustum, OctreeNodeP node);
 
        stlplus::ntree<OctreeNode> tree_;
 
 public:
 
-       inline static OctreeP alloc(const OctreeNode& rootNode)
+       void print(OctreeNodeP node)
+       {
+               //logDebug("-----");
+               //logDebug("depth to node: %d", tree_.depth(node));
+               //logDebug("size of node: %d", tree_.size(node));
+       }
+
+       static OctreeP alloc(const OctreeNode& rootNode)
        {
                return OctreeP(new Octree(rootNode));
        }
@@ -155,9 +166,9 @@ public:
 
        OctreeNodeP reinsert(EntityP entity, OctreeNodeP node);
 
-       void drawIfVisible(Scalar alpha, const Camera& cam)
+       void drawIfVisible(Scalar alpha, const Frustum& frustum)
        {
-               drawIfVisible(alpha, cam, tree_.root());
+               drawIfVisible(alpha, frustum, tree_.root());
        }
 
        void sort();
This page took 0.021946 seconds and 4 git commands to generate.