Show
Ignore:
Timestamp:
04/03/08 20:36:50 (4 years ago)
Author:
robert
Message:

Introduced CMake build option for compiling double or float versions of osg::BoundingSphere? and osg::BoundingBox?.

Introduced code in BoundgingSphere?, BoundingBox?, ProxyNode? and LOD to utilise the above settings.

Added Matrix::value_type, Plane::value_type, BoundingSphere::value_type and BoundingBox::value_type command line
options that report where the types of floats or doubles.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/BoundingSphere

    r5328 r8038  
    1616 
    1717#include <osg/Export> 
    18 #include <osg/Vec3> 
     18#include <osg/Vec3f> 
     19#include <osg/Vec3d> 
    1920 
    2021namespace osg { 
     
    3132{ 
    3233    public: 
     34 
     35#ifdef OSG_USE_DOUBLE_BOUNDINGSPHERE 
     36        typedef Vec3d vec_type; 
     37        typedef double value_type; 
     38#else 
     39        typedef Vec3f vec_type; 
     40        typedef float value_type; 
     41#endif 
    3342         
    34         Vec3 _center; 
    35         float _radius; 
     43        vec_type    _center; 
     44        value_type _radius; 
    3645 
    3746        /** Construct a default bounding sphere with radius to -1.0f, representing an invalid/unset bounding sphere.*/  
    38         BoundingSphere() : _center(0.0f,0.0f,0.0f),_radius(-1.0f) {} 
     47        BoundingSphere() : _center(0.0,0.0,0.0),_radius(-1.0) {} 
    3948     
    4049        /** Creates a bounding sphere initialized to the given extents. */ 
    41         BoundingSphere(const Vec3& center,float radius) : _center(center),_radius(radius) {} 
     50        BoundingSphere(const vec_type& center,value_type radius) : _center(center),_radius(radius) {} 
    4251 
    4352        /** Creates a bounding sphere initialized to the given extents. */ 
     
    4554 
    4655        /** Creates a bounding sphere initialized to the given extents. */ 
    47         BoundingSphere(const BoundingBox& bb) : _center(0.0f,0.0f,0.0f),_radius(-1.0f) { expandBy(bb); } 
     56        BoundingSphere(const BoundingBox& bb) : _center(0.0,0.0,0.0),_radius(-1.0) { expandBy(bb); } 
    4857 
    4958        /** Clear the bounding sphere. Reset to default values. */ 
    5059        inline void init() 
    5160        { 
    52             _center.set(0.0f,0.0f,0.0f); 
    53             _radius = -1.0f; 
     61            _center.set(0.0,0.0,0.0); 
     62            _radius = -1.0; 
    5463        } 
    5564 
    5665        /** Returns true of the bounding sphere extents are valid, false 
    5766          * otherwise. */ 
    58         inline bool valid() const { return _radius>=0.0f; } 
     67        inline bool valid() const { return _radius>=0.0; } 
    5968 
    60         /** Set the bounding sphere to the given center/radius. */  
    61         inline void set(const Vec3& center,float radius) 
     69        /** Set the bounding sphere to the given center/radius using floats. */  
     70        inline void set(const vec_type& center,value_type radius) 
    6271        { 
    6372            _center = center; 
     
    6675 
    6776        /** Returns the center of the bounding sphere. */ 
    68         inline Vec3& center() { return _center; } 
     77        inline vec_type& center() { return _center; } 
     78         
    6979        /** Returns the const center of the bounding sphere. */ 
    70         inline const Vec3& center() const { return _center; } 
     80        inline const vec_type& center() const { return _center; } 
    7181 
    7282        /** Returns the radius of the bounding sphere. */ 
    73         inline float& radius() { return _radius; } 
     83        inline value_type& radius() { return _radius; } 
    7484        /** Returns the const radius of the bounding sphere. */ 
    75         inline float radius() const { return _radius; } 
     85        inline value_type radius() const { return _radius; } 
    7686         
    7787        /** Returns the squared length of the radius. Note, For performance 
    7888          * reasons, the calling method is responsible for checking to make 
    7989          * sure the sphere is valid. */ 
    80         inline float radius2() const { return _radius*_radius; } 
     90        inline value_type radius2() const { return _radius*_radius; } 
    8191 
    8292        /** Expands the sphere to encompass the given point. Repositions the 
    8393          * sphere center to minimize the radius increase. If the sphere is 
    8494          * uninitialized, set its center to v and radius to zero. */ 
    85         void expandBy(const Vec3& v); 
     95        void expandBy(const Vec3f& v); 
    8696 
    8797        /** Expands the sphere to encompass the given point. Does not 
    8898          * reposition the sphere center. If the sphere is 
    8999          * uninitialized, set its center to v and radius to zero. */ 
    90         void expandRadiusBy(const Vec3& v); 
     100        void expandRadiusBy(const Vec3f& v); 
     101 
     102        /** Expands the sphere to encompass the given point. Repositions the 
     103          * sphere center to minimize the radius increase. If the sphere is 
     104          * uninitialized, set its center to v and radius to zero. */ 
     105        void expandBy(const Vec3d& v); 
     106 
     107        /** Expands the sphere to encompass the given point. Does not 
     108          * reposition the sphere center. If the sphere is 
     109          * uninitialized, set its center to v and radius to zero. */ 
     110        void expandRadiusBy(const Vec3d& v); 
    91111 
    92112        /** Expands the sphere to encompass the given sphere. Repositions the 
     
    109129 
    110130        /** Returns true if v is within the sphere. */ 
    111         inline bool contains(const Vec3& v) const 
     131        inline bool contains(const vec_type& v) const 
    112132        { 
    113133            return valid() && ((v-_center).length2()<=radius2()); 
    114134        } 
     135 
    115136 
    116137        /** Returns true if there is a non-empty intersection with the given