Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r544 - branches/itanium2/Model/Groups


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r544 - branches/itanium2/Model/Groups
  • Date: Tue, 13 Sep 2005 11:34:12 -0600 (MDT)

Author: bigler
Date: Tue Sep 13 11:34:12 2005
New Revision: 544

Modified:
   branches/itanium2/Model/Groups/FrustumKDTree.cc
   branches/itanium2/Model/Groups/FrustumKDTree.h
Log:

Format text to *Standard* (i.e. my standard ;)


Modified: branches/itanium2/Model/Groups/FrustumKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.cc     (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.cc     Tue Sep 13 11:34:12 
2005
@@ -1,30 +1,30 @@
 /*
- For more information, please see: http://software.sci.utah.edu
+  For more information, please see: http://software.sci.utah.edu
  
- The MIT License
+  The MIT License
  
- Copyright (c) 2005
- Scientific Computing and Imaging Institue, University of Utah
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institue, University of Utah
  
- License for the specific language governing rights and limitations under
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
  
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
  
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
- */
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
 
 #include <Model/Groups/FrustumKDTree.h>
 
@@ -45,72 +45,78 @@
 // have common origin and all rays have a common direction.
 PacketFrustum::PacketFrustum( const RayPacket &rays ) {
 
-       // Assume that all rays have a common origin.
-       frustum_origin = rays.get(0).ray.origin();
+  // Assume that all rays have a common origin.
+  frustum_origin = rays.get(0).ray.origin();
 
-       
/////////////////////////////////////////////////////////////////////////////
-       // Choose a plane to intersect all of the rays with based on the 
direction
-       // of the rays.
-       Point  plane_point;
-       Vector plane_normal;
-       
-       for (int i=0;i<3;++i) {
-               int signMask = rays.get(0).signMask[i];
-       
-               // Compute the plane point and normal.
-               plane_point [i] = (2.0 * signMask) - 1.0;    // signMask[i] 
now in {-1,1}
-               plane_normal[i] = plane_point[i] * 0.577350;
-       }
-       
-       
/////////////////////////////////////////////////////////////////////////////
-       // Compute the axes of a coordinate system on the plane.
-       Vector plane_u, plane_v;
-       
-       // Project x and y axis to the plane (plane normal is never either x 
or y).
-       plane_u = (Vector(1,0,0) - (plane_normal * Dot( Vector(1,0,0), 
plane_normal ) ) );
-       plane_u.normalize();
-       
-       plane_v = (Vector(0,1,0) - (plane_normal * Dot( Vector(0,1,0), 
plane_normal ) ) );
-       plane_v.normalize();
-
-       
/////////////////////////////////////////////////////////////////////////////
-       // Find min and max corners of bounding frustum intersected with all 
rays in
-       // packet.
-       typedef VectorT<Real, 2> Vector2;
-       typedef PointT <Real, 2> Point2;
-       
-       Vector2 min(  FLT_MAX,  FLT_MAX );
-       Vector2 max( -FLT_MAX, -FLT_MAX );
-       
-       for (int i=0;i<rays.getSize();++i) {
-               const RayPacket::Element &e = rays.get(i);
-               
-               // Intersect the ray with the plane.
-               Real t;
-               Intersection::intersectPlane( plane_point, plane_normal, t, 
e.ray );
-               
-               // Compute intersection point in world coords.
-               Vector  i_vec( e.ray.origin() + (e.ray.direction() * t) );
-               i_vec = i_vec - (Vector)plane_point;
-               
-               // Determine the intersection point in plane coordinates.
-               Point2 p;
-               p[0] = Dot( i_vec, plane_u );
-               p[1] = Dot( i_vec, plane_v );
-               
-               // Check p against the bounds.
-               for (int j=0;j<2;++j) {
-                       if (p[j] < min[j])      min[j] = p[j];
-                       else if (p[j] > max[j]) max[j] = p[j];
-               }
-       }
-       
-       
/////////////////////////////////////////////////////////////////////////////
-       // Transform bounding corners into world vectors.
-       frustum_bound[0] = (plane_point + (plane_u * min[0]) + (plane_v * 
min[1])) - frustum_origin;
-       frustum_bound[1] = (plane_point + (plane_u * max[0]) + (plane_v * 
min[1])) - frustum_origin;
-       frustum_bound[2] = (plane_point + (plane_u * max[0]) + (plane_v * 
max[1])) - frustum_origin;
-       frustum_bound[3] = (plane_point + (plane_u * min[0]) + (plane_v * 
max[1])) - frustum_origin;
+  
/////////////////////////////////////////////////////////////////////////////
+  // Choose a plane to intersect all of the rays with based on the direction
+  // of the rays.
+  Point  plane_point;
+  Vector plane_normal;
+
+  for (int i=0;i<3;++i) {
+    int signMask = rays.get(0).signMask[i];
+
+    // Compute the plane point and normal.
+    plane_point [i] = (2.0 * signMask) - 1.0;    // signMask[i] now in {-1,1}
+    plane_normal[i] = plane_point[i] * 0.577350;
+  }
+
+  
/////////////////////////////////////////////////////////////////////////////
+  // Compute the axes of a coordinate system on the plane.
+  Vector plane_u, plane_v;
+
+  // Project x and y axis to the plane (plane normal is never either x or y).
+  plane_u = (Vector(1,0,0) -
+             (plane_normal * Dot( Vector(1,0,0), plane_normal ) ) );
+  plane_u.normalize();
+
+  plane_v = (Vector(0,1,0) -
+             (plane_normal * Dot( Vector(0,1,0), plane_normal ) ) );
+  plane_v.normalize();
+
+  
/////////////////////////////////////////////////////////////////////////////
+  // Find min and max corners of bounding frustum intersected with all rays 
in
+  // packet.
+  typedef VectorT<Real, 2> Vector2;
+  typedef PointT <Real, 2> Point2;
+
+  Vector2 min(  FLT_MAX,  FLT_MAX );
+  Vector2 max( -FLT_MAX, -FLT_MAX );
+
+  for (int i=0;i<rays.getSize();++i) {
+    const RayPacket::Element &e = rays.get(i);
+
+    // Intersect the ray with the plane.
+    Real t;
+    Intersection::intersectPlane( plane_point, plane_normal, t, e.ray );
+
+    // Compute intersection point in world coords.
+    Vector  i_vec( e.ray.origin() + (e.ray.direction() * t) );
+    i_vec = i_vec - (Vector)plane_point;
+
+    // Determine the intersection point in plane coordinates.
+    Point2 p;
+    p[0] = Dot( i_vec, plane_u );
+    p[1] = Dot( i_vec, plane_v );
+
+    // Check p against the bounds.
+    for (int j=0;j<2;++j) {
+      if (p[j] < min[j])      min[j] = p[j];
+      else if (p[j] > max[j]) max[j] = p[j];
+    }
+  }
+        
+  
/////////////////////////////////////////////////////////////////////////////
+  // Transform bounding corners into world vectors.
+  frustum_bound[0] = ((plane_point + (plane_u * min[0]) + (plane_v * 
min[1])) -
+                      frustum_origin);
+  frustum_bound[1] = ((plane_point + (plane_u * max[0]) + (plane_v * 
min[1])) -
+                      frustum_origin);
+  frustum_bound[2] = ((plane_point + (plane_u * max[0]) + (plane_v * 
max[1])) -
+                      frustum_origin);
+  frustum_bound[3] = ((plane_point + (plane_u * min[0]) + (plane_v * 
max[1])) -
+                      frustum_origin);
 }
 
 
@@ -122,20 +128,22 @@
 
 /////////////////////////////////////////////////////////////////////////
 // Create a frustum from a ray packet, and intersect with the kdtree.
-void FrustumKDTree::packet_intersect(const RenderContext& context, RayPacket 
&rays ) {
+void FrustumKDTree::packet_intersect(const RenderContext& context,
+                                     RayPacket &rays ) {
 
   ///////////////////////////////////////////////////////////////////////
-       // Check to make sure the ray packet is big enough and has the 
correct flags set.
-       if ((rays.getSize() == 1) || 
+  // Check to make sure the ray packet is big enough and has the
+  // correct flags set.
+  if ((rays.getSize() == 1) || 
       (!rays.getFlags( RayPacket::ConstantOrigin )) || 
       (!rays.getFlags( RayPacket::ConstantDirections ))) {
-       
-               // If not call normal kdtree ray intersect.
-               KDTree::intersect( context, rays );
-               return;
-       }
-       
-       // Create a packet bounding frustum and intersect it with the tree.
+        
+    // If not call normal kdtree ray intersect.
+    KDTree::intersect( context, rays );
+    return;
+  }
+        
+  // Create a packet bounding frustum and intersect it with the tree.
   PacketFrustum frustum( rays );
   
   ///////////////////////////////////////////////////////////////////////
@@ -268,6 +276,6 @@
 // Intersect the specified frustum with a leaf.
 FrustumKDTree::IntersectCase FrustumKDTree::frustum_leaf_intersect(const 
RenderContext& context, KDTreeLeafNode *node, PacketFrustum &frustum ) {
 
-       return INTERSECT_BOTH;
+  return INTERSECT_BOTH;
 }
 

Modified: branches/itanium2/Model/Groups/FrustumKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.h      (original)
+++ branches/itanium2/Model/Groups/FrustumKDTree.h      Tue Sep 13 11:34:12 
2005
@@ -1,30 +1,30 @@
 /*
- For more information, please see: http://software.sci.utah.edu

- The MIT License

- Copyright (c) 2005
- Scientific Computing and Imaging Institue, University of Utah
-
- License for the specific language governing rights and limitations under
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:

- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.

- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
- */
+  For more information, please see: http://software.sci.utah.edu
+  
+  The MIT License
+  
+  Copyright (c) 2005
+  Scientific Computing and Imaging Institue, University of Utah
+  
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+  
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+  
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
 
 #ifndef __FRUSTUMKDTREE_H__
 #define __FRUSTUMKDTREE_H__
@@ -34,32 +34,35 @@
 #include <Model/Groups/KDTree.h>
 
 namespace Manta {
-       
-       namespace Kdtree {
 
-               
/////////////////////////////////////////////////////////////////////////////
-               
/////////////////////////////////////////////////////////////////////////////
-               // PACKET FRUSTUM  PACKET FRUSTUM  PACKET FRUSTUM  PACKET 
FRUSTUM  PACKET
-               
/////////////////////////////////////////////////////////////////////////////
-               
/////////////////////////////////////////////////////////////////////////////
-               
-               // Container for a bounding frustum about a ray packet.
-               class PacketFrustum {
-               private:
-                       Point  frustum_origin;             // Common origin.
-                       Vector frustum_bound[4];           // Four vectors 
which bound the frustum.
-                       unsigned int frustum_direction[3]; // All rays in 
frustum must have the same direction.
-      
-               public:
-                       // Create a frustum around the specified ray packet. 
Assumes all rays 
-                       // have common origin and all rays are in the same 
hemisphere.
-                       PacketFrustum( const RayPacket &rays );
-      
+  namespace Kdtree {
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // PACKET FRUSTUM  PACKET FRUSTUM  PACKET FRUSTUM  PACKET FRUSTUM  PACKET
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+
+    // Container for a bounding frustum about a ray packet.
+    class PacketFrustum {
+    private:
+      Point  frustum_origin;             // Common origin.
+      Vector frustum_bound[4];           // Four vectors which bound
+                                         // the frustum.
+      unsigned int frustum_direction[3]; // All rays in frustum must
+                                         // have the same direction.
+
+    public:
+      // Create a frustum around the specified ray packet. Assumes all
+      // rays have common origin and all rays are in the same
+      // hemisphere.
+      PacketFrustum( const RayPacket &rays );
+
       // Create a frustum given a common origin and four bounding vectors.
       PacketFrustum( const Point &origin_, const Vector &bound0_, 
-                                           const Vector &bound1_, 
-                                           const Vector &bound2_, 
-                                           const Vector &bound3_ ) : 
+                     const Vector &bound1_, 
+                     const Vector &bound2_, 
+                     const Vector &bound3_ ) : 
         frustum_origin( origin_ ) 
       {
         frustum_bound[0] = bound0_;
@@ -67,64 +70,69 @@
         frustum_bound[2] = bound2_;
         frustum_bound[3] = bound3_;
       }
-               
-                       // Accessors.
-                       const Point  &origin()       const { return 
frustum_origin;    };
-                       const Vector &bound( int i ) const { return 
frustum_bound[i]; };
-      
+
+      // Accessors.
+      const Point  &origin()       const { return frustum_origin;    };
+      const Vector &bound( int i ) const { return frustum_bound[i]; };
+
       // Direction, sign mask of all bounding rays assumed to be the same.
       unsigned int direction( int i ) const { return frustum_direction[i]; };
-               };
+    };
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    // FRUSTUM KD TREE  FRUSTUM KD TREE  FRUSTUM KD TREE  FRUSTUM KD TREE  FR
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+
+    // This class implements a kdtree traversal where the frustrum of
+    // a ray packet is first intersected with the kdtree before
+    // individual rays are intersected with the tree.
 
-               
/////////////////////////////////////////////////////////////////////////////
-               
/////////////////////////////////////////////////////////////////////////////
-               // FRUSTUM KD TREE  FRUSTUM KD TREE  FRUSTUM KD TREE  FRUSTUM 
KD TREE  FR
-               
/////////////////////////////////////////////////////////////////////////////
-               
/////////////////////////////////////////////////////////////////////////////
-               
-               // This class implements a kdtree traversal where the 
frustrum of a ray packet
-               // is first intersected with the kdtree before individual 
rays are intersected
-               // with the tree.
-               
-               class FrustumKDTree : public KDTree {
-               // protected:
+    class FrustumKDTree : public KDTree {
+      // protected:
     public:
-                       
/////////////////////////////////////////////////////////////////////////
-                       // Create a frustum from a ray packet, and intersect 
with the kdtree.
-                       void packet_intersect(const RenderContext& context, 
RayPacket &rays );
-                       
-                       
/////////////////////////////////////////////////////////////////////////
-                       // Intersect the specified frustrum with the kdtree.
-                       enum IntersectCase { INTERSECT_NONE = 0x0,  // Cannot 
be determined by basic tests. 
-                                            INTERSECT_MIN  = 0x1, 
-                                                                             
                           INTERSECT_MAX  = 0x2, 
-                                                                             
                           INTERSECT_BOTH = 0x3 };
-                       
-                       // Intersect the specified frustrum with an internal 
node.
-                       IntersectCase frustum_node_intersect(const 
RenderContext& context, 
+      
/////////////////////////////////////////////////////////////////////////
+      // Create a frustum from a ray packet, and intersect with the kdtree.
+      void packet_intersect(const RenderContext& context, RayPacket &rays );
+
+      
/////////////////////////////////////////////////////////////////////////
+      // Intersect the specified frustrum with the kdtree.
+      enum IntersectCase { INTERSECT_NONE = 0x0,  // Cannot be determined by
+                                                  // basic tests.
+                           INTERSECT_MIN  = 0x1, 
+                           INTERSECT_MAX  = 0x2, 
+                           INTERSECT_BOTH = 0x3 };
+
+      // Intersect the specified frustrum with an internal node.
+      IntersectCase frustum_node_intersect(const RenderContext& context, 
                                            const KDTreeNode *node, 
                                            const PacketFrustum &frustum, 
                                            const BBox &node_bounds );
-                       
-                       // Intersect the specified frustrum with a leaf.
-                       IntersectCase frustum_leaf_intersect(const 
RenderContext& context, KDTreeLeafNode *node, PacketFrustum &frustum );
-               
-               public:
-                       
/////////////////////////////////////////////////////////////////////////
-                       // Create a FrustrumKDTree which data may be loaded 
into.
-                       FrustumKDTree( Material *material_ ) : KDTree( 
material_ ) {  };
-                       
-                       // Use data owned by another kdtree.
-                       FrustumKDTree( KDTree *kdtree_, Material *material_ ) 
: KDTree( kdtree_, material_ ) {  }
-                       
-                       // Intersection method -- Intersect frustrum with 
kdtree then call 
-                       // KDTree::intersect.
-                       virtual void intersect(const RenderContext& context, 
RayPacket& rays) const;
-               };
-               
-       };
-       
-};
+
+      // Intersect the specified frustrum with a leaf.
+      IntersectCase frustum_leaf_intersect(const RenderContext& context,
+                                           KDTreeLeafNode *node,
+                                           PacketFrustum &frustum );
+
+    public:
+      
/////////////////////////////////////////////////////////////////////////
+      // Create a FrustrumKDTree which data may be loaded into.
+      FrustumKDTree( Material *material_ ) : KDTree( material_ ) {  };
+
+      // Use data owned by another kdtree.
+      FrustumKDTree( KDTree *kdtree_, Material *material_ ) :
+        KDTree( kdtree_, material_ )
+      {  }
+
+      // Intersection method -- Intersect frustrum with kdtree then call 
+      // KDTree::intersect.
+      virtual void intersect(const RenderContext& context, RayPacket& rays) 
const;
+    };
+
+  }; // end namespace Frustrum
+
+}; // end namespace Manta
 
 #endif
 




  • [MANTA] r544 - branches/itanium2/Model/Groups, bigler, 09/13/2005

Archive powered by MHonArc 2.6.16.

Top of page