- aabb_.min = Vector3(-1.0, -1.0, -1.0);
- aabb_.max = Vector3(1.0, 1.0, 1.0);
- sphere_.init(Vector3(0.0, 0.0, 0.0), 1.41421);
- }
+ std::list<InsertableP> objects;
+
+ Aabb aabb;
+ Sphere sphere;
+
+ Node(const Aabb& box) :
+ aabb(box)
+ {
+ sphere.point = aabb.getCenter();
+ sphere.radius = (aabb.min - sphere.point).length();
+ }
+
+ void draw(Scalar alpha) const
+ {
+ aabb.draw(alpha);
+ }
+
+ void drawIfVisible(Scalar alpha, const Frustum& frustum) const
+ {
+ if (isVisible(frustum))
+ {
+ aabb.draw(alpha);
+ }
+ }
+
+ void printSize()
+ {
+ logDebug("size of node %d", objects.size());
+ }
+
+ void getAll(std::list<InsertableP>& insertables) const
+ {
+ insertables.insert(insertables.end(), objects.begin(),
+ objects.end());
+ }
+
+ void getIfVisible(std::list<InsertableP>& insertables,
+ const Frustum& frustum) const
+ {
+ typename std::list<InsertableP>::const_iterator it;
+
+ for (it = objects.begin(); it != objects.end(); ++it)
+ {
+ if ((*it)->isVisible(frustum)) insertables.push_back(*it);
+ }
+ }
+
+
+ bool isVisible(const Frustum& frustum) const
+ {
+ if (sphere.isVisible(frustum))
+ {
+ return aabb.isVisible(frustum);
+ }
+
+ return false;
+ }
+ };