Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r335 - branches/itanium2/Model/Intersections
- Date: Mon, 23 May 2005 17:22:34 -0600 (MDT)
Author: abe
Date: Mon May 23 17:22:33 2005
New Revision: 335
Added:
branches/itanium2/Model/Intersections/
branches/itanium2/Model/Intersections/AxisAlignedBox.cc
branches/itanium2/Model/Intersections/AxisAlignedBox.cc~
branches/itanium2/Model/Intersections/AxisAlignedBox.h
branches/itanium2/Model/Intersections/AxisAlignedBox.h~
branches/itanium2/Model/Intersections/CMakeLists.txt
Log:
Updated and tested AxisAlignedBox
Added: branches/itanium2/Model/Intersections/AxisAlignedBox.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Intersections/AxisAlignedBox.cc Mon May 23
17:22:33 2005
@@ -0,0 +1,7 @@
+
+
+#include <Core/Geometry/BBox.h>
+#include "AxisAlignedBox.h"
+
+using namespace Manta;
+
Added: branches/itanium2/Model/Intersections/AxisAlignedBox.cc~
==============================================================================
Added: branches/itanium2/Model/Intersections/AxisAlignedBox.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Intersections/AxisAlignedBox.h Mon May 23
17:22:33 2005
@@ -0,0 +1,71 @@
+
+// AxisAlignedBox Intersection algorithm based on the Amy Williams
intersection
+// test.
+// Abe Stephens abe@sgi.com
+// May 2005
+
+#ifndef Manta_Model_Intersections_AxisAlignedBox__H
+#define Manta_Model_Intersections_AxisAlignedBox__H
+
+#include <limits>
+
+namespace Manta {
+ namespace Intersection {
+
+ // This intersection method uses the Amy Williams ray/box intersection
technique.
+ //
http://www.cs.utah.edu/~awilliam/box/box.pdf
+ // The BOX type must define a [] operator for accessing the min/max
points in
+ // the bounds.
+
+ // NOTE: The inverse direction and ray sign mask are in the
RayPacket::Element.
+
+ // This is the single ray version.
+ template< typename BOX, typename Scalar >
+ inline bool intersect_box(const BOX &bounds, // Object implementing
[]
+
+ Scalar &tmin, // Output min t.
+ Scalar &tmax, // Output max t.
+
+ const Ray &r, // Input Ray.
+ const int s[3], // Input Ray mask.
+ const Vector &d_inv, // Input 1.0 / ray
direction.
+
+ Scalar t0 = 0, // Input bounding
interval for t.
+ Scalar t1 = std::numeric_limits<Scalar>::max()
+ ) {
+
+ Scalar tymin, tymax, tzmin, tzmax;
+
+ tmin = (bounds[s[0] ][0] - r.origin()[0]) * d_inv[0];
+ tmax = (bounds[1-s[0]][0] - r.origin()[0]) * d_inv[0];
+ tymin = (bounds[s[1] ][1] - r.origin()[1]) * d_inv[1];
+ tymax = (bounds[1-s[1]][1] - r.origin()[1]) * d_inv[1];
+
+ // If boxes are allowed to be inside out.
+ // if (tmin > tmax)
+ // return false;
+
+ if ( (tmin > tymax) || (tymin > tmax) )
+ return false;
+ if ( tymin > tmin )
+ tmin = tymin;
+ if ( tymax < tmax )
+ tmax = tymax;
+
+ tzmin = (bounds[s[2] ][2] - r.origin()[2]) * d_inv[2];
+ tzmax = (bounds[1-s[2]][2] - r.origin()[2]) *
d_inv[2];
+
+ if ( (tmin > tzmax) || (tzmin > tmax) )
+ return false;
+ if ( tzmin > tmin )
+ tmin = tzmin;
+ if ( tzmax < tmax )
+ tmax = tzmax;
+
+ return ( (tmin < t1) && (tmax > t0) );
+ }
+
+ };
+};
+
+#endif
Added: branches/itanium2/Model/Intersections/AxisAlignedBox.h~
==============================================================================
Added: branches/itanium2/Model/Intersections/CMakeLists.txt
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Intersections/CMakeLists.txt Mon May 23
17:22:33 2005
@@ -0,0 +1,3 @@
+SET(Manta_Intersections_SRCS
+ # Intersections/AxisAlignedBox.cc
+)
- [MANTA] r335 - branches/itanium2/Model/Intersections, abe, 05/23/2005
Archive powered by MHonArc 2.6.16.