SpatialAccel.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  SpatialAccel
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @date   Fall 2008
00005    
00006    @brief
00007       Generic interface for intersection acceleration data structures used 
00008    for ray visibility testing and sampling during rendering.
00009    <!-------------------------------------------------------------------->**/
00010 
00011 #ifndef SPATIAL_ACCEL_H_
00012 #define SPATIAL_ACCEL_H_
00013 
00014 #include <utils/PropertyMap.h>
00015 #include <shapes/Intersectable.h>
00016 #include <vector>
00017 
00018 class SpatialAccel : public PropertyMap, public SSEAligned {
00019    
00020    public:
00021       ///@name Constructors
00022       //@{-----------------------------------------------------------------
00023       
00024       inline SpatialAccel() 
00025          : m_primitives(NULL)
00026       { }
00027       
00028       virtual ~SpatialAccel() 
00029       { }
00030       
00031       
00032       //@}-----------------------------------------------------------------
00033       ///@name Initialization Routines
00034       //@{-----------------------------------------------------------------
00035       
00036       virtual void setGeometry(IntersectableList *primitives) {
00037          m_primitives = primitives;
00038       }
00039       
00040       /// Initializes the AABB surrounding all of the geometry
00041       virtual void init() {
00042          ASSERT(m_primitives);
00043          m_aabb = AABB();
00044          
00045          FOREACH(IntersectableListConstIter, *m_primitives, iter) {
00046             const Intersectable *shape = *iter;
00047             
00048             const AABB &aabb = shape->getAABB();
00049             ASSERT(aabb.isValid());
00050             
00051             if (!aabb.isPoint())
00052                m_aabb.add(aabb);
00053          }
00054       }
00055       
00056       
00057       //@}-----------------------------------------------------------------
00058       ///@name Main usage interface
00059       //@{-----------------------------------------------------------------
00060       
00061       virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt) = 0;
00062       
00063       virtual bool intersects(const Ray &ray, real_t tMax = INFINITY) = 0;
00064       
00065       virtual void preview();
00066       
00067       
00068       //@}-----------------------------------------------------------------
00069       ///@name Accessors
00070       //@{-----------------------------------------------------------------
00071       
00072       inline const IntersectableList *getIntersectables() const {
00073          return m_primitives;
00074       }
00075       
00076       inline const AABB &getAABB() const {
00077          return m_aabb;
00078       }
00079       
00080       
00081       //@}-----------------------------------------------------------------
00082       
00083    protected:
00084       AABB               m_aabb;
00085       IntersectableList *m_primitives;
00086 };
00087 
00088 #endif // SPATIAL_ACCEL_H_
00089 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6