]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Octree.cc
improved new vorbisfile compatibility
[chaz/yoink] / src / Moof / Octree.cc
index 300dbcdea7a9f2537d0499667374f22d777c2cb3..062788daa1f0d0378460c09cfd4b99eff4d924ca 100644 (file)
@@ -26,7 +26,7 @@
 
 *******************************************************************************/
 
-#include "Camera.hh"
+#include "Frustum.hh"
 #include "Log.hh"
 #include "Octree.hh"
        
@@ -66,31 +66,34 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                        entity->getAabb().max[2] < node->getAabb().max[2] &&
                        entity->getAabb().min[2] > node->getAabb().min[2]))
        {
+               // TODO this check is only needed for the root node, if we're inside the
+               // volume of the root node, we'll be fully inside the child as
+               // determined by trying to insert the parent node
                goto done;
        }
 
-       halfspace = xy.intersectsSphere(entity->getSphere());
+       halfspace = xy.intersects(entity->getSphere());
        if (halfspace == Plane::INTERSECT)
        {
-               halfspace = xy.intersectsAabb(entity->getAabb());
+               halfspace = xy.intersects(entity->getAabb());
        }
 
        if (halfspace == Plane::POSITIVE)
        {
                Plane xz = node->getAabb().getPlaneXZ();
-               halfspace = xz.intersectsSphere(entity->getSphere());
+               halfspace = xz.intersects(entity->getSphere());
                if (halfspace == Plane::INTERSECT)
                {
-                       halfspace = xz.intersectsAabb(entity->getAabb());
+                       halfspace = xz.intersects(entity->getAabb());
                }
 
                if (halfspace == Plane::POSITIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -105,10 +108,10 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                else if (halfspace == Plane::NEGATIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -124,19 +127,19 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
        else if (halfspace == Plane::NEGATIVE)
        {
                Plane xz = node->getAabb().getPlaneXZ();
-               halfspace = xz.intersectsSphere(entity->getSphere());
+               halfspace = xz.intersects(entity->getSphere());
                if (halfspace == Plane::INTERSECT)
                {
-                       halfspace = xz.intersectsAabb(entity->getAabb());
+                       halfspace = xz.intersects(entity->getAabb());
                }
 
                if (halfspace == Plane::POSITIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -151,10 +154,10 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                else if (halfspace == Plane::NEGATIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -235,17 +238,17 @@ void Octree::draw(Scalar alpha, OctreeNodeP node)
        }
 }
 
-void Octree::drawIfVisible(Scalar alpha, const Camera& cam, OctreeNodeP node)
+void Octree::drawIfVisible(Scalar alpha, const Frustum& frustum, OctreeNodeP node)
 {
        ASSERT(node.valid() && "invalid node passed");
 
        // try to cull by sphere
        Frustum::Collision collision =
-               cam.getFrustum().containsSphere(node->getSphere());
+               frustum.contains(node->getSphere());
        if (collision == Frustum::OUTSIDE) return;
 
        // try to cull by aabb
-       collision = cam.getFrustum().containsAabb(node->getAabb());
+       collision = frustum.contains(node->getAabb());
        if (collision == Frustum::OUTSIDE) return;
 
 
@@ -255,7 +258,7 @@ void Octree::drawIfVisible(Scalar alpha, const Camera& cam, OctreeNodeP node)
        }
        else // collision == Frustum::INTERSECT
        {
-               node->drawIfVisible(alpha, cam);
+               node->drawIfVisible(alpha, frustum);
        }
 
        if (tree_.children(node) > 0)
@@ -277,7 +280,7 @@ void Octree::drawIfVisible(Scalar alpha, const Camera& cam, OctreeNodeP node)
                                OctreeNodeP child = tree_.child(node, i);
                                ASSERT(child.valid() && "expected valid child node");
 
-                               drawIfVisible(alpha, cam, child);
+                               drawIfVisible(alpha, frustum, child);
                        }
                }
        }
This page took 0.022478 seconds and 4 git commands to generate.