Changeset 13041 for OpenSceneGraph/trunk/include/osg/KdTree
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/KdTree (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/KdTree
r12139 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 24 24 25 25 /** Implementation of a kdtree for Geometry leaves, to enable fast intersection tests.*/ 26 class OSG_EXPORT KdTree : public osg::Shape 26 class OSG_EXPORT KdTree : public osg::Shape 27 27 { 28 28 public: 29 30 29 30 31 31 KdTree(); 32 32 33 33 KdTree(const KdTree& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 34 34 35 35 META_Shape(osg, KdTree) 36 36 37 37 struct OSG_EXPORT BuildOptions 38 38 { 39 39 BuildOptions(); 40 40 41 41 unsigned int _numVerticesProcessed; 42 42 unsigned int _targetNumTrianglesPerLeaf; 43 43 unsigned int _maxNumLevels; 44 44 }; 45 46 45 46 47 47 /** Build the kdtree from the specified source geometry object. 48 * retun true on success. */ 48 * retun true on success. */ 49 49 virtual bool build(BuildOptions& buildOptions, osg::Geometry* geometry); 50 50 51 51 struct LineSegmentIntersection 52 52 { … … 78 78 79 79 unsigned int primitiveIndex; 80 }; 81 80 }; 81 82 82 83 83 typedef std::vector<LineSegmentIntersection> LineSegmentIntersections; 84 84 85 85 /** compute the intersection of a line segment and the kdtree, return true if an intersection has been found.*/ 86 86 virtual bool intersect(const osg::Vec3d& start, const osg::Vec3d& end, LineSegmentIntersections& intersections) const; … … 101 101 osg::BoundingBox bb; 102 102 103 value_type first; 103 value_type first; 104 104 value_type second; 105 105 }; 106 106 107 107 struct Triangle 108 108 { 109 109 Triangle(): 110 110 p0(0),p1(0),p2(0) {} 111 111 112 112 Triangle(unsigned int ip0, unsigned int ip1, unsigned int ip2): 113 113 p0(ip0), p1(ip1), p2(ip2) {} … … 132 132 int addNode(const KdNode& node) 133 133 { 134 int num = static_cast<int>(_kdNodes.size()); 135 _kdNodes.push_back(node); 134 int num = static_cast<int>(_kdNodes.size()); 135 _kdNodes.push_back(node); 136 136 return num; 137 137 } … … 139 139 KdNode& getNode(int nodeNum) { return _kdNodes[nodeNum]; } 140 140 const KdNode& getNode(int nodeNum) const { return _kdNodes[nodeNum]; } 141 141 142 142 KdNodeList& getNodes() { return _kdNodes; } 143 143 const KdNodeList& getNodes() const { return _kdNodes; } … … 171 171 { 172 172 public: 173 173 174 174 KdTreeBuilder(); 175 175 176 176 KdTreeBuilder(const KdTreeBuilder& rhs); 177 177 … … 181 181 182 182 void apply(osg::Geode& geode); 183 183 184 184 KdTree::BuildOptions _buildOptions; 185 185 … … 187 187 188 188 189 189 190 190 protected: 191 191 192 192 virtual ~KdTreeBuilder() {} 193 193 194 194 }; 195 195
