Changeset 8038
- Timestamp:
- 04/03/08 20:36:50 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 11 modified
-
CMakeLists.txt (modified) (3 diffs)
-
applications/osgversion/osgversion.cpp (modified) (3 diffs)
-
include/osg/BoundingBox (modified) (9 diffs)
-
include/osg/BoundingSphere (modified) (5 diffs)
-
include/osg/LOD (modified) (3 diffs)
-
include/osg/ProxyNode (modified) (3 diffs)
-
include/osg/Vec4d (modified) (2 diffs)
-
src/osg/BoundingSphere.cpp (modified) (4 diffs)
-
src/osgGA/NodeTrackerManipulator.cpp (modified) (1 diff)
-
src/osgGA/TerrainManipulator.cpp (modified) (1 diff)
-
src/osgPlugins/Inventor/ConvertToInventor.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/CMakeLists.txt
r8019 r8038 178 178 ######################################################################################################## 179 179 180 OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float matrix instead of double." OFF)180 OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." OFF) 181 181 MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX) 182 182 IF(OSG_USE_FLOAT_MATRIX) … … 184 184 ENDIF(OSG_USE_FLOAT_MATRIX) 185 185 186 OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float matrixinstead of double." OFF)186 OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." OFF) 187 187 MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE) 188 188 IF(OSG_USE_FLOAT_PLANE) … … 190 190 ENDIF(OSG_USE_FLOAT_PLANE) 191 191 192 OPTION(OSG_USE_FLOAT_BOUNDINGSPHERE "Set to ON to build OpenSceneGraph with float BoundingSphere instead of double." ON) 193 MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE) 194 IF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE) 195 ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE) 196 ENDIF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE) 197 198 OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON) 199 MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX) 200 IF(NOT OSG_USE_FLOAT_BOUNDINGBOX) 201 ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX) 202 ENDIF(NOT OSG_USE_FLOAT_BOUNDINGBOX) 192 203 193 204 ################################################################################ -
OpenSceneGraph/trunk/applications/osgversion/osgversion.cpp
r8025 r8038 2 2 #include <osg/ArgumentParser> 3 3 #include <osg/ApplicationUsage> 4 5 #include <osg/Matrix> 6 #include <osg/Plane> 7 #include <osg/BoundingBox> 8 #include <osg/BoundingSphere> 9 10 4 11 #include <OpenThreads/Version> 5 12 … … 720 727 arguments.getApplicationUsage()->addCommandLineOption("--openthreads-version-number","Print out version number for OpenThreads only"); 721 728 arguments.getApplicationUsage()->addCommandLineOption("--openthreads-soversion-number","Print out shared object version number for OpenThreads only"); 729 arguments.getApplicationUsage()->addCommandLineOption("Matrix::value_type","Print the value of Matrix::value_type"); 730 arguments.getApplicationUsage()->addCommandLineOption("Plane::value_type","Print the value of Plane::value_type"); 731 arguments.getApplicationUsage()->addCommandLineOption("BoundingSphere::value_type","Print the value of BoundingSphere::value_type"); 732 arguments.getApplicationUsage()->addCommandLineOption("BoundingBox::value_type","Print the value of BoundingBox::value_type"); 722 733 arguments.getApplicationUsage()->addCommandLineOption("-r <file> or --read <file>","Read the ChangeLog to generate an estimated contributors list."); 723 734 … … 777 788 return 0; 778 789 } 779 780 790 781 791 if (arguments.read("--openthreads-soversion-number")) 782 792 { 783 793 std::cout<<OpenThreadsGetSOVersion()<<std::endl; 794 return 0; 795 } 796 797 798 if (arguments.read("Matrix::value_type")) 799 { 800 std::cout<<((sizeof(osg::Matrix::value_type)==4)?"float":"double")<<std::endl; 801 return 0; 802 } 803 804 if (arguments.read("Plane::value_type")) 805 { 806 std::cout<<((sizeof(osg::Plane::value_type)==4)?"float":"double")<<std::endl; 807 return 0; 808 } 809 810 if (arguments.read("BoundingSphere::value_type")) 811 { 812 std::cout<<((sizeof(osg::BoundingSphere::value_type)==4)?"float":"double")<<std::endl; 813 return 0; 814 } 815 if (arguments.read("BoundingBox::value_type")) 816 { 817 std::cout<<((sizeof(osg::BoundingBox::value_type)==4)?"float":"double")<<std::endl; 784 818 return 0; 785 819 } -
OpenSceneGraph/trunk/include/osg/BoundingBox
r7648 r8038 17 17 #include <osg/Export> 18 18 #include <osg/Vec3> 19 #include <osg/Vec3d> 19 20 #include <float.h> 20 21 … … 31 32 public: 32 33 34 #ifdef OSG_USE_DOUBLE_BOUNDINGBOX 35 typedef Vec3d vec_type; 36 typedef doulbe value_type; 37 #else 38 typedef Vec3f vec_type; 39 typedef float value_type; 40 #endif 41 42 33 43 /** Minimum extent. (Smallest X, Y, and Z values of all coordinates.) */ 34 Vec3_min;44 vec_type _min; 35 45 /** Maximum extent. (Greatest X, Y, and Z values of all coordinates.) */ 36 Vec3_max;46 vec_type _max; 37 47 38 48 /** Creates an uninitialized bounding box. */ … … 41 51 42 52 /** Creates a bounding box initialized to the given extents. */ 43 inline BoundingBox( float xmin,float ymin,floatzmin,44 float xmax,float ymax,floatzmax) :45 _min(xmin,ymin,zmin),46 _max(xmax,ymax,zmax) {}53 inline BoundingBox(value_type xmin, value_type ymin, value_type zmin, 54 value_type xmax, value_type ymax, value_type zmax) : 55 _min(xmin,ymin,zmin), 56 _max(xmax,ymax,zmax) {} 47 57 48 58 /** Creates a bounding box initialized to the given extents. */ 49 inline BoundingBox(const Vec3& min,const Vec3& max) :59 inline BoundingBox(const vec_type& min,const vec_type& max) : 50 60 _min(min), 51 61 _max(max) {} … … 65 75 66 76 /** Sets the bounding box extents. */ 67 inline void set ( float xmin,float ymin,floatzmin,68 float xmax,float ymax,floatzmax)77 inline void set (value_type xmin, value_type ymin, value_type zmin, 78 value_type xmax, value_type ymax, value_type zmax) 69 79 { 70 80 _min.set(xmin,ymin,zmin); … … 73 83 74 84 /** Sets the bounding box extents. */ 75 inline void set(const Vec3& min,const Vec3& max)85 inline void set(const vec_type& min,const vec_type& max) 76 86 { 77 87 _min = min; … … 80 90 81 91 82 inline float& xMin() { return _min.x(); }83 inline floatxMin() const { return _min.x(); }84 85 inline float& yMin() { return _min.y(); }86 inline floatyMin() const { return _min.y(); }87 88 inline float& zMin() { return _min.z(); }89 inline floatzMin() const { return _min.z(); }90 91 inline float& xMax() { return _max.x(); }92 inline floatxMax() const { return _max.x(); }93 94 inline float& yMax() { return _max.y(); }95 inline floatyMax() const { return _max.y(); }96 97 inline float& zMax() { return _max.z(); }98 inline floatzMax() const { return _max.z(); }92 inline value_type& xMin() { return _min.x(); } 93 inline value_type xMin() const { return _min.x(); } 94 95 inline value_type& yMin() { return _min.y(); } 96 inline value_type yMin() const { return _min.y(); } 97 98 inline value_type& zMin() { return _min.z(); } 99 inline value_type zMin() const { return _min.z(); } 100 101 inline value_type& xMax() { return _max.x(); } 102 inline value_type xMax() const { return _max.x(); } 103 104 inline value_type& yMax() { return _max.y(); } 105 inline value_type yMax() const { return _max.y(); } 106 107 inline value_type& zMax() { return _max.z(); } 108 inline value_type zMax() const { return _max.z(); } 99 109 100 110 /** Calculates and returns the bounding box center. */ 101 inline const Vec3center() const102 { 103 return (_min+_max)*0.5 f;111 inline const vec_type center() const 112 { 113 return (_min+_max)*0.5; 104 114 } 105 115 106 116 /** Calculates and returns the bounding box radius. */ 107 inline floatradius() const108 { 109 return sqrt f(radius2());117 inline value_type radius() const 118 { 119 return sqrt(radius2()); 110 120 } 111 121 112 122 /** Calculates and returns the squared length of the bounding box radius. 113 123 * Note, radius2() is faster to calculate than radius(). */ 114 inline floatradius2() const115 { 116 return 0.25 f*((_max-_min).length2());124 inline value_type radius2() const 125 { 126 return 0.25*((_max-_min).length2()); 117 127 } 118 128 … … 122 132 * most-significant. Unset bits select the minimum value 123 133 * for that axis, and set bits select the maximum. */ 124 inline const Vec3corner(unsigned int pos) const125 { 126 return Vec3(pos&1?_max.x():_min.x(),pos&2?_max.y():_min.y(),pos&4?_max.z():_min.z());134 inline const vec_type corner(unsigned int pos) const 135 { 136 return vec_type(pos&1?_max.x():_min.x(),pos&2?_max.y():_min.y(),pos&4?_max.z():_min.z()); 127 137 } 128 138 129 139 /** Expands the bounding box to include the given coordinate. 130 140 * If the box is uninitialized, set its min and max extents to v. */ 131 inline void expandBy(const Vec3& v)141 inline void expandBy(const vec_type& v) 132 142 { 133 143 if(v.x()<_min.x()) _min.x() = v.x(); … … 144 154 * If the box is uninitialized, set its min and max extents to 145 155 * Vec3(x,y,z). */ 146 inline void expandBy( float x,float y,floatz)156 inline void expandBy(value_type x,value_type y,value_type z) 147 157 { 148 158 if(x<_min.x()) _min.x() = x; … … 181 191 182 192 /** Returns true if this bounding box contains the specified coordinate. */ 183 inline bool contains(const Vec3& v) const193 inline bool contains(const vec_type& v) const 184 194 { 185 195 return valid() && -
OpenSceneGraph/trunk/include/osg/BoundingSphere
r5328 r8038 16 16 17 17 #include <osg/Export> 18 #include <osg/Vec3> 18 #include <osg/Vec3f> 19 #include <osg/Vec3d> 19 20 20 21 namespace osg { … … 31 32 { 32 33 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 33 42 34 Vec3_center;35 float_radius;43 vec_type _center; 44 value_type _radius; 36 45 37 46 /** Construct a default bounding sphere with radius to -1.0f, representing an invalid/unset bounding sphere.*/ 38 BoundingSphere() : _center(0.0 f,0.0f,0.0f),_radius(-1.0f) {}47 BoundingSphere() : _center(0.0,0.0,0.0),_radius(-1.0) {} 39 48 40 49 /** Creates a bounding sphere initialized to the given extents. */ 41 BoundingSphere(const Vec3& center,floatradius) : _center(center),_radius(radius) {}50 BoundingSphere(const vec_type& center,value_type radius) : _center(center),_radius(radius) {} 42 51 43 52 /** Creates a bounding sphere initialized to the given extents. */ … … 45 54 46 55 /** Creates a bounding sphere initialized to the given extents. */ 47 BoundingSphere(const BoundingBox& bb) : _center(0.0 f,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); } 48 57 49 58 /** Clear the bounding sphere. Reset to default values. */ 50 59 inline void init() 51 60 { 52 _center.set(0.0 f,0.0f,0.0f);53 _radius = -1.0 f;61 _center.set(0.0,0.0,0.0); 62 _radius = -1.0; 54 63 } 55 64 56 65 /** Returns true of the bounding sphere extents are valid, false 57 66 * otherwise. */ 58 inline bool valid() const { return _radius>=0.0 f; }67 inline bool valid() const { return _radius>=0.0; } 59 68 60 /** Set the bounding sphere to the given center/radius . */61 inline void set(const Vec3& center,floatradius)69 /** Set the bounding sphere to the given center/radius using floats. */ 70 inline void set(const vec_type& center,value_type radius) 62 71 { 63 72 _center = center; … … 66 75 67 76 /** Returns the center of the bounding sphere. */ 68 inline Vec3& center() { return _center; } 77 inline vec_type& center() { return _center; } 78 69 79 /** 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; } 71 81 72 82 /** Returns the radius of the bounding sphere. */ 73 inline float& radius() { return _radius; }83 inline value_type& radius() { return _radius; } 74 84 /** Returns the const radius of the bounding sphere. */ 75 inline floatradius() const { return _radius; }85 inline value_type radius() const { return _radius; } 76 86 77 87 /** Returns the squared length of the radius. Note, For performance 78 88 * reasons, the calling method is responsible for checking to make 79 89 * sure the sphere is valid. */ 80 inline floatradius2() const { return _radius*_radius; }90 inline value_type radius2() const { return _radius*_radius; } 81 91 82 92 /** Expands the sphere to encompass the given point. Repositions the 83 93 * sphere center to minimize the radius increase. If the sphere is 84 94 * uninitialized, set its center to v and radius to zero. */ 85 void expandBy(const Vec3 & v);95 void expandBy(const Vec3f& v); 86 96 87 97 /** Expands the sphere to encompass the given point. Does not 88 98 * reposition the sphere center. If the sphere is 89 99 * 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); 91 111 92 112 /** Expands the sphere to encompass the given sphere. Repositions the … … 109 129 110 130 /** Returns true if v is within the sphere. */ 111 inline bool contains(const Vec3& v) const131 inline bool contains(const vec_type& v) const 112 132 { 113 133 return valid() && ((v-_center).length2()<=radius2()); 114 134 } 135 115 136 116 137 /** Returns true if there is a non-empty intersection with the given -
OpenSceneGraph/trunk/include/osg/LOD
r7648 r8038 44 44 META_Node(osg, LOD); 45 45 46 typedef osg::BoundingSphere::vec_type vec_type; 47 typedef osg::BoundingSphere::value_type value_type; 48 46 49 virtual void traverse(NodeVisitor& nv); 47 50 … … 70 73 /** Sets the object-space point which defines the center of the osg::LOD. 71 74 center is affected by any transforms in the hierarchy above the osg::LOD.*/ 72 inline void setCenter(const Vec3& center) { _centerMode=USER_DEFINED_CENTER; _userDefinedCenter = center; }75 inline void setCenter(const vec_type& center) { _centerMode=USER_DEFINED_CENTER; _userDefinedCenter = center; } 73 76 74 77 /** return the LOD center point. */ 75 inline const Vec3& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); }78 inline const vec_type& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); } 76 79 77 80 78 81 /** Set the object-space reference radius of the volume enclosed by the LOD. 79 82 * Used to determine the bounding sphere of the LOD in the absence of any children.*/ 80 inline void setRadius( floatradius) { _radius = radius; }83 inline void setRadius(value_type radius) { _radius = radius; } 81 84 82 85 /** Get the object-space radius of the volume enclosed by the LOD.*/ 83 inline floatgetRadius() const { return _radius; }86 inline value_type getRadius() const { return _radius; } 84 87 85 88 … … 125 128 126 129 CenterMode _centerMode; 127 Vec3_userDefinedCenter;128 float_radius;130 vec_type _userDefinedCenter; 131 value_type _radius; 129 132 130 133 RangeMode _rangeMode; -
OpenSceneGraph/trunk/include/osg/ProxyNode
r7881 r8038 32 32 META_Node(osg, ProxyNode); 33 33 34 typedef osg::BoundingSphere::vec_type vec_type; 35 typedef osg::BoundingSphere::value_type value_type; 36 34 37 virtual void traverse(NodeVisitor& nv); 35 38 … … 82 85 83 86 /** return the ProxyNode center point. */ 84 inline const Vec3& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); }87 inline const vec_type& getCenter() const { if (_centerMode==USER_DEFINED_CENTER) return _userDefinedCenter; else return getBound().center(); } 85 88 86 89 87 90 /** Set the object-space reference radius of the volume enclosed by the ProxyNode. 88 91 * Used to determine the bounding sphere of the ProxyNode in the absence of any children.*/ 89 inline void setRadius( floatradius) { _radius = radius; }92 inline void setRadius(value_type radius) { _radius = radius; } 90 93 91 94 /** Get the object-space radius of the volume enclosed by the ProxyNode.*/ 92 inline floatgetRadius() const { return _radius; }95 inline value_type getRadius() const { return _radius; } 93 96 94 97 virtual BoundingSphere computeBound() const; … … 106 109 107 110 CenterMode _centerMode; 108 Vec3_userDefinedCenter;109 float_radius;111 vec_type _userDefinedCenter; 112 value_type _radius; 110 113 111 114 }; -
OpenSceneGraph/trunk/include/osg/Vec4d
r7648 r8038 249 249 } 250 250 251 /** Compute the dot product of a (Vec3,1.0) and a Vec4d. */ 252 inline Vec4d::value_type operator * (const Vec3f& lhs,const Vec4d& rhs) 253 { 254 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3]; 255 } 256 257 /** Compute the dot product of a (Vec3,1.0) and a Vec4d. */ 258 inline Vec4d::value_type operator * (const Vec3d& lhs,const Vec4f& rhs) 259 { 260 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3]; 261 } 262 263 251 264 /** Compute the dot product of a Vec4d and a (Vec3,1.0). */ 252 265 inline Vec4d::value_type operator * (const Vec4d& lhs,const Vec3d& rhs) … … 255 268 } 256 269 270 /** Compute the dot product of a Vec4d and a (Vec3,1.0). */ 271 inline Vec4d::value_type operator * (const Vec4d& lhs,const Vec3f& rhs) 272 { 273 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3]; 274 } 275 276 /** Compute the dot product of a Vec4d and a (Vec3,1.0). */ 277 inline Vec4d::value_type operator * (const Vec4f& lhs,const Vec3d& rhs) 278 { 279 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3]; 280 } 281 257 282 } // end of namespace osg 258 283 -
OpenSceneGraph/trunk/src/osg/BoundingSphere.cpp
r6050 r8038 16 16 using namespace osg; 17 17 18 void BoundingSphere::expandBy(const Vec3 & v)19 { 20 if (valid()) 21 { 22 Vec3dv = v-_center;23 floatr = dv.length();18 void BoundingSphere::expandBy(const Vec3f& v) 19 { 20 if (valid()) 21 { 22 vec_type dv = v-_center; 23 value_type r = dv.length(); 24 24 if (r>_radius) 25 25 { 26 float dr = (r-_radius)*0.5f;26 value_type dr = (r-_radius)*0.5; 27 27 _center += dv*(dr/r); 28 28 _radius += dr; … … 32 32 { 33 33 _center = v; 34 _radius = 0.0 f;35 } 36 } 37 38 39 void BoundingSphere::expandRadiusBy(const Vec3 & v)40 { 41 if (valid()) 42 { 43 floatr = (v-_center).length();34 _radius = 0.0; 35 } 36 } 37 38 39 void BoundingSphere::expandRadiusBy(const Vec3f& v) 40 { 41 if (valid()) 42 { 43 value_type r = (v-_center).length(); 44 44 if (r>_radius) _radius = r; 45 45 // else do nothing as vertex is within sphere. … … 48 48 { 49 49 _center = v; 50 _radius = 0.0f; 51 } 52 } 50 _radius = 0.0; 51 } 52 } 53 54 55 56 void BoundingSphere::expandBy(const Vec3d& v) 57 { 58 if (valid()) 59 { 60 vec_type dv = v-_center; 61 value_type r = dv.length(); 62 if (r>_radius) 63 { 64 value_type dr = (r-_radius)*0.5; 65 _center += dv*(dr/r); 66 _radius += dr; 67 } // else do nothing as vertex is within sphere. 68 } 69 else 70 { 71 _center = v; 72 _radius = 0.0; 73 } 74 } 75 76 77 void BoundingSphere::expandRadiusBy(const Vec3d& v) 78 { 79 if (valid()) 80 { 81 value_type r = (v-_center).length(); 82 if (r>_radius) _radius = r; 83 // else do nothing as vertex is within sphere. 84 } 85 else 86 { 87 _center = v; 88 _radius = 0.0; 89 } 90 } 91 53 92 54 93 … … 108 147 if (valid()) 109 148 { 110 floatr = (sh._center-_center).length()+sh._radius;149 value_type r = (sh._center-_center).length()+sh._radius; 111 150 if (r>_radius) _radius = r; 112 151 // else do nothing as vertex is within sphere. -
OpenSceneGraph/trunk/src/osgGA/NodeTrackerManipulator.cpp
r7102 r8038 106 106 const float minimumDistanceScale = 0.001f; 107 107 _minimumDistance = osg::clampBetween( 108 boundingSphere._radius* minimumDistanceScale,108 float(boundingSphere._radius) * minimumDistanceScale, 109 109 0.00001f,1.0f); 110 110 -
OpenSceneGraph/trunk/src/osgGA/TerrainManipulator.cpp
r7792 r8038 52 52 const float minimumDistanceScale = 0.001f; 53 53 _minimumDistance = osg::clampBetween( 54 boundingSphere._radius* minimumDistanceScale,54 float(boundingSphere._radius) * minimumDistanceScale, 55 55 0.00001f,1.0f); 56 56 -
OpenSceneGraph/trunk/src/osgPlugins/Inventor/ConvertToInventor.cpp
r7782 r8038 1995 1995 1996 1996 // set center 1997 lod->center.setValue(node.getCenter().ptr()); 1997 osg::Vec3f center(node.getCenter()); 1998 lod->center.setValue(center.ptr()); 1998 1999 1999 2000 ivLOD = lod;
