Ignore:
Timestamp:
12/01/08 16:50:13 (16 years ago)
Author:
mattausch
Message:

finally found bvh tighter bounds bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h

    r3070 r3202  
    1717 
    1818 
     19/** A very simple ray structure. 
     20*/ 
    1921struct SimpleRay 
    2022{ 
     
    2224 
    2325        SimpleRay(const Vector3 &o, const Vector3 &d): mOrigin(o), mDirection(d) {} 
    24  
    25         Vector3 mOrigin; 
    26         Vector3 mDirection; 
    2726 
    2827        Vector3 Extrap(const float t) const  
     
    3029                return mOrigin + mDirection * t; 
    3130        } 
     31 
     32 
     33        //////////////7 
     34         
     35        Vector3 mOrigin; 
     36        Vector3 mDirection; 
     37 
    3238}; 
    3339 
     
    4551        //-- Constructors. 
    4652 
     53        /** Default constructor creating an existing box. 
     54                The user has to call Initialize once in order 
     55                to be able to use the box. 
     56        */ 
    4757        AxisAlignedBox3(); 
    48  
     58        /** Constructor taking the minimum and maximum as parameters. 
     59        */ 
    4960        AxisAlignedBox3(const Vector3 &nMin, const Vector3 &nMax); 
    5061        /** initialization to the non existing bounding box 
     
    5768        */ 
    5869        Vector3 Diagonal() const; 
    59  
     70        /** Computes the mid point in the given axis. 
     71        */ 
    6072        float Center(const int axis) const; 
    61  
     73        /** The vertex of the box with the smallest values in all dimensions. 
     74        */ 
    6275        float Min(const int axis) const; 
    63  
     76        /** The vertex of the box with the largest values in all dimensions. 
     77        */ 
    6478        float Max(const int axis) const; 
    65  
     79        /** The extent of the box in the given axis. 
     80        */ 
    6681        float Size(const int axis) const; 
    6782        /** Returns axis where box has largest extent. 
     
    7186        */ 
    7287        const Vector3& Min() const; 
     88        /** See Min 
     89        */ 
    7390        const Vector3& Max() const; 
    74  
     91        /** Enlarges box in all dimensions by adding with the given value. 
     92        */ 
    7593        void Enlarge(const Vector3 &v); 
    76  
     94        /** If the box is degenerate, this function enlarges the box 
     95                to the minimum valid size. 
     96        */ 
    7797        void EnlargeToMinSize(); 
    78  
     98        /** Sets a new minimum of the box. 
     99        */ 
    79100        void SetMin(const Vector3 &v); 
    80  
     101        /** Sets a new maximum of the box. 
     102        */ 
    81103        void SetMax(const Vector3 &v); 
    82  
     104        /** Sets the minimum for one dimension. 
     105        */ 
    83106        void SetMin(int axis, const float value); 
    84  
     107        /** Sets the maximum for one dimension. 
     108        */ 
    85109        void SetMax(int axis, const float value); 
    86110        /** Decrease box by given splitting plane 
    87111        */ 
    88112        void Reduce(int axis, int right, float value);  
    89  
     113        /** Returns true if the box intersects the line given by the end 
     114                vertices. 
     115        */ 
    90116        bool Intersects(const Vector3 &lStart, const Vector3 &lEnd) const; 
    91  
    92         // the size of the box along all the axes 
     117        /** The size of the box along all the axes 
     118        */ 
    93119        Vector3 Size() const; 
    94         float Radius() const { return 0.5f * Magnitude(Size()); } 
    95         float SqrRadius() const { return 0.5f * SqrMagnitude(Size()); } 
     120        /** The diagonal radius of the box. 
     121        */ 
     122        float Radius() const; 
     123        /** The square radius. 
     124        */ 
     125        float SqrRadius() const; 
    96126        /** Return whether the box is unbounded.  Unbounded boxes appear 
    97127                when unbounded objects such as quadric surfaces are included. 
     
    99129        bool Unbounded() const; 
    100130 
    101         // Expand the axis-aligned box to include the given object. 
     131        /** Expand the axis-aligned box to include the given object. 
     132        */ 
    102133        void Include(const Vector3 &newpt); 
    103134        void Include(const AxisAlignedBox3 &bbox); 
     
    111142        */ 
    112143        bool Includes(const AxisAlignedBox3 &b) const; 
    113  
    114144        /** Returns true if this point is inside box. 
    115145        */ 
     
    160190                                 ID_Top = 5}; 
    161191 
    162         // Writes a brief description of the object, indenting by the given 
    163         // number of spaces first. 
     192        /** Writes a brief description of the object, indenting by the given 
     193            number of spaces first. 
     194        */ 
    164195        virtual void Describe(std::ostream& app, int ind) const; 
    165196 
    166         // For edge .. number <0..11> returns two incident vertices 
     197        /** For edge .. number <0..11> returns two incident vertices 
     198        */ 
    167199        void GetEdge(int edge, Vector3 *a, Vector3 *b) const; 
    168  
    169         // Compute the coordinates of one vertex of the box for 0/1 in each axis 
    170         // 0 .. smaller coordinates, 1 .. large coordinates 
     200        /** Compute the coordinates of one vertex of the box for 0/1 in each axis 
     201            0 .. smaller coordinates, 1 .. large coordinates 
     202        */ 
    171203        Vector3 GetVertex(int xAxis, int yAxis, int zAxis) const; 
    172  
    173         // Compute the vertex for number N=<0..7>, N = 4*x + 2*y + z, where 
    174         // x,y,z are either 0 or 1; (0 .. lower coordinate, 1 .. large coordinate) 
    175         // (xmin,ymin, zmin) .. N = 0, (xmax, ymax, zmax) .. N= 7 
     204        /** Compute the vertex for number N=<0..7>, N = 4*x + 2*y + z, where 
     205            x,y,z are either 0 or 1; (0 .. lower coordinate, 1 .. large coordinate) 
     206           (xmin,ymin, zmin) .. N = 0, (xmax, ymax, zmax) .. N= 7 
     207    */ 
    176208        void GetVertex(int N, Vector3 &vertex) const; 
    177  
     209        /** Convencience method that returns a vertex internally using the  
     210                above routine. 
     211        */ 
    178212        Vector3 GetVertex(int N) const; 
     213        /** Uses different vertex order: vertices are chosen so that they 
     214                only differ by one value (min or max) in the x, y, z triple 
     215        */ 
     216        void GetVertex2(int N, Vector3 &vertex) const; 
    179217        /** get the extent of face. 
    180218        */ 
     
    322360// -------------------------------------------------------------------------- 
    323361// Implementation of inline (member) functions 
     362 
     363inline float AxisAlignedBox3::Radius() const  
     364{  
     365        return 0.5f * Magnitude(Size());  
     366} 
     367 
     368 
     369inline float AxisAlignedBox3::SqrRadius() const  
     370{  
     371        return 0.5f * SqrMagnitude(Size());  
     372} 
     373 
    324374 
    325375inline bool 
Note: See TracChangeset for help on using the changeset viewer.