Changeset 13041 for OpenSceneGraph/trunk/include/osg/Polytope
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/Polytope (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/Polytope
r12744 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 */ … … 35 35 inline Polytope() {setupMask();} 36 36 37 inline Polytope(const Polytope& cv) : 37 inline Polytope(const Polytope& cv) : 38 38 _maskStack(cv._maskStack), 39 39 _resultMask(cv._resultMask), 40 40 _planeList(cv._planeList), 41 41 _referenceVertexList(cv._referenceVertexList) {} 42 42 43 43 inline Polytope(const PlaneList& pl) : _planeList(pl) {setupMask();} 44 44 … … 56 56 return *this; 57 57 } 58 58 59 59 /** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/ 60 60 void setToUnitFrustum(bool withNear=true, bool withFar=true) … … 95 95 return; 96 96 } 97 97 98 98 ClippingMask selector_mask = 0x1; 99 99 … … 109 109 selector_mask <<= 1; 110 110 } 111 111 112 112 _planeList.resize(numActivePlanes); 113 113 _resultMask = 0; … … 131 131 132 132 inline void set(const PlaneList& pl) { _planeList = pl; setupMask(); } 133 134 133 134 135 135 inline void add(const osg::Plane& pl) { _planeList.push_back(pl); setupMask(); } 136 136 … … 145 145 } 146 146 } 147 147 148 148 inline bool empty() const { return _planeList.empty(); } 149 149 … … 156 156 157 157 inline VertexList& getReferenceVertexList() { return _referenceVertexList; } 158 158 159 159 inline const VertexList& getReferenceVertexList() const { return _referenceVertexList; } 160 160 … … 177 177 178 178 inline ClippingMask getResultMask() const { return _resultMask; } 179 179 180 180 MaskStack& getMaskStack() { return _maskStack; } 181 181 182 182 const MaskStack& getMaskStack() const { return _maskStack; } 183 184 183 184 185 185 inline void pushCurrentMask() 186 186 { … … 197 197 { 198 198 if (!_maskStack.back()) return true; 199 199 200 200 unsigned int selector_mask = 0x1; 201 201 for(PlaneList::const_iterator itr=_planeList.begin(); … … 230 230 selector_mask <<= 1; 231 231 } 232 232 233 233 if (!outside) return true; 234 234 } … … 258 258 else if (res>0) _resultMask ^= selector_mask; // subsequent checks against this plane not required. 259 259 } 260 selector_mask <<= 1; 261 } 262 return true; 263 } 264 260 selector_mask <<= 1; 261 } 262 return true; 263 } 264 265 265 /** Check whether any part of a bounding box is contained within clipping set. 266 266 Using a mask to determine which planes should be used for the check, and … … 285 285 else if (res>0) _resultMask ^= selector_mask; // subsequent checks against this plane not required. 286 286 } 287 selector_mask <<= 1; 287 selector_mask <<= 1; 288 288 } 289 289 return true; … … 308 308 _resultMask ^= selector_mask; // subsequent checks against this plane not required. 309 309 } 310 selector_mask <<= 1; 310 selector_mask <<= 1; 311 311 } 312 312 return true; … … 320 320 _resultMask = _maskStack.back(); 321 321 ClippingMask selector_mask = 0x1; 322 322 323 323 for(PlaneList::const_iterator itr=_planeList.begin(); 324 324 itr!=_planeList.end(); … … 331 331 _resultMask ^= selector_mask; // subsequent checks against this plane not required. 332 332 } 333 selector_mask <<= 1; 334 } 335 return true; 336 } 337 333 selector_mask <<= 1; 334 } 335 return true; 336 } 337 338 338 /** Check whether the entire bounding box is contained within clipping set.*/ 339 339 inline bool containsAllOf(const osg::BoundingBox& bb) … … 354 354 _resultMask ^= selector_mask; // subsequent checks against this plane not required. 355 355 } 356 selector_mask <<= 1; 357 } 358 return true; 359 } 360 361 356 selector_mask <<= 1; 357 } 358 return true; 359 } 360 361 362 362 /** Transform the clipping set by matrix. Note, this operations carries out 363 * the calculation of the inverse of the matrix since a plane must 363 * the calculation of the inverse of the matrix since a plane must 364 364 * be multiplied by the inverse transposed to transform it. This 365 365 * makes this operation expensive. If the inverse has been already … … 372 372 transformProvidingInverse(inverse); 373 373 } 374 374 375 375 /** Transform the clipping set by provide a pre inverted matrix. 376 376 * see transform for details. */ … … 388 388 { 389 389 itr->transformProvidingInverse(matrix); 390 selector_mask <<= 1; 391 } 392 } 393 } 394 390 selector_mask <<= 1; 391 } 392 } 393 } 394 395 395 protected: 396 396 … … 405 405 } // end of namespace 406 406 407 #endif 407 #endif
