Changeset 13041 for OpenSceneGraph/trunk/src/osg/CullStack.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/CullStack.cpp (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/CullStack.cpp
r7212 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 */ … … 29 29 _index_modelviewCullingStack = 0; 30 30 _back_modelviewCullingStack = 0; 31 31 32 32 _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); 33 33 } … … 44 44 _index_modelviewCullingStack = 0; 45 45 _back_modelviewCullingStack = 0; 46 46 47 47 _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); 48 48 } … … 66 66 _referenceViewPoints.clear(); 67 67 _referenceViewPoints.push_back(osg::Vec3(0.0f,0.0f,0.0f)); 68 68 69 69 _eyePointStack.clear(); 70 70 _viewPointStack.clear(); … … 79 79 80 80 osg::Vec3 lookVector(0.0,0.0,-1.0); 81 81 82 82 _bbCornerFar = (lookVector.x()>=0?1:0) | 83 83 (lookVector.y()>=0?2:0) | … … 85 85 86 86 _bbCornerNear = (~_bbCornerFar)&7; 87 87 88 88 _currentReuseMatrixIndex=0; 89 89 } … … 94 94 _MVPW_Stack.push_back(0L); 95 95 96 if (_index_modelviewCullingStack==0) 96 if (_index_modelviewCullingStack==0) 97 97 { 98 98 if (_modelviewCullingStack.empty()) … … 101 101 _modelviewCullingStack[_index_modelviewCullingStack++].set(_projectionCullingStack.back()); 102 102 } 103 else 104 { 105 103 else 104 { 105 106 106 const osg::Viewport& W = *_viewportStack.back(); 107 107 const osg::Matrix& P = *_projectionStack.back(); … … 109 109 110 110 osg::Vec4 pixelSizeVector = CullingSet::computePixelSizeVector(W,P,M); 111 112 if (_index_modelviewCullingStack>=_modelviewCullingStack.size()) 111 112 if (_index_modelviewCullingStack>=_modelviewCullingStack.size()) 113 113 { 114 114 _modelviewCullingStack.push_back(CullingSet()); 115 115 } 116 116 117 117 _modelviewCullingStack[_index_modelviewCullingStack++].set(_projectionCullingStack.back(),*_modelviewStack.back(),pixelSizeVector); 118 119 } 120 118 119 } 120 121 121 _back_modelviewCullingStack = &_modelviewCullingStack[_index_modelviewCullingStack-1]; 122 122 … … 137 137 { 138 138 _MVPW_Stack.pop_back(); 139 139 140 140 --_index_modelviewCullingStack; 141 141 if (_index_modelviewCullingStack>0) _back_modelviewCullingStack = &_modelviewCullingStack[_index_modelviewCullingStack-1]; … … 158 158 { 159 159 _projectionStack.push_back(matrix); 160 160 161 161 _projectionCullingStack.push_back(osg::CullingSet()); 162 162 osg::CullingSet& cullingSet = _projectionCullingStack.back(); 163 163 164 164 // set up view frustum. 165 165 cullingSet.getFrustum().setToUnitFrustum(((_cullingMode&NEAR_PLANE_CULLING)!=0),((_cullingMode&FAR_PLANE_CULLING)!=0)); 166 166 cullingSet.getFrustum().transformProvidingInverse(*matrix); 167 167 168 168 // set the culling mask ( There should be a more elegant way!) Nikolaus H. 169 169 cullingSet.setCullingMask(_cullingMode); … … 171 171 // set the small feature culling. 172 172 cullingSet.setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize); 173 173 174 174 // set up the relevant occluders which a related to this projection. 175 175 for(ShadowVolumeOccluderList::iterator itr=_occluderList.begin(); … … 184 184 } 185 185 } 186 187 186 187 188 188 189 189 // need to recompute frustum volume. … … 211 211 212 212 _modelviewStack.push_back(matrix); 213 213 214 214 pushCullingSet(); 215 215 216 216 osg::Matrix inv; 217 217 inv.invert(*matrix); 218 218 219 219 220 220 switch(referenceFrame) 221 221 { … … 233 233 { 234 234 _eyePointStack.push_back(inv.getTrans()); 235 235 236 236 osg::Vec3 referenceViewPoint = getReferenceViewPoint(); 237 237 if (originalModelView) … … 250 250 251 251 252 osg::Vec3 lookVector = getLookVectorLocal(); 253 252 osg::Vec3 lookVector = getLookVectorLocal(); 253 254 254 _bbCornerFar = (lookVector.x()>=0?1:0) | 255 255 (lookVector.y()>=0?2:0) | … … 257 257 258 258 _bbCornerNear = (~_bbCornerFar)&7; 259 259 260 260 } 261 261 … … 263 263 { 264 264 _modelviewStack.pop_back(); 265 265 266 266 _eyePointStack.pop_back(); 267 267 _referenceViewPoints.pop_back(); … … 300 300 _frustumVolume = computeVolume(f1,f2,f3,b1,b2,b3)+ 301 301 computeVolume(f2,f3,f4,b1,b3,b4); 302 303 } 302 303 }
