X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FOctree.hh;h=e3e2225f03299636137b21aa3a54aeb38fd25b38;hp=ade0a026fdddc13e4507c88a9605e7f28bfd959f;hb=660e768e64c2c30928c7f157d5ff34195a4347fa;hpb=57b78ebe21b1b48acd337daa5a1cb8c383959cfa diff --git a/src/Moof/Octree.hh b/src/Moof/Octree.hh index ade0a02..e3e2225 100644 --- a/src/Moof/Octree.hh +++ b/src/Moof/Octree.hh @@ -47,7 +47,7 @@ namespace Mf { -class Camera; +class Frustum; struct OctreeNode; @@ -88,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::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; @@ -133,20 +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 tree_; public: - inline void print(OctreeNodeP node) + void print(OctreeNodeP node) { //logDebug("-----"); //logDebug("depth to node: %d", tree_.depth(node)); //logDebug("size of node: %d", tree_.size(node)); } - inline static OctreeP alloc(const OctreeNode& rootNode) + static OctreeP alloc(const OctreeNode& rootNode) { return OctreeP(new Octree(rootNode)); } @@ -163,9 +166,14 @@ public: OctreeNodeP reinsert(EntityP entity, OctreeNodeP node); - void drawIfVisible(Scalar alpha, const Camera& cam) + void draw(Scalar alpha) + { + draw(alpha, tree_.root()); + } + + void drawIfVisible(Scalar alpha, const Frustum& frustum) { - drawIfVisible(alpha, cam, tree_.root()); + drawIfVisible(alpha, frustum, tree_.root()); } void sort();