- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/CollectOccludersVisitor.cpp
r6248 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 */ … … 30 30 FAR_PLANE_CULLING| 31 31 SMALL_FEATURE_CULLING); 32 32 33 33 _minimumShadowOccluderVolume = 0.005f; 34 34 _maximumNumberOfActiveOccluders = 10; 35 35 _createDrawables = false; 36 36 37 37 } 38 38 … … 63 63 const Matrix& matrix = *_modelviewStack.back(); 64 64 float dist = -(pos[0]*matrix(0,2)+pos[1]*matrix(1,2)+pos[2]*matrix(2,2)+matrix(3,2)); 65 65 66 66 if (withLODScale) return dist*getLODScale(); 67 67 else return dist*getLODScale(); … … 74 74 // push the culling mode. 75 75 pushCurrentMask(); 76 77 handle_cull_callbacks_and_traverse(node); 78 76 77 handle_cull_callbacks_and_traverse(node); 78 79 79 // pop the culling mode. 80 80 popCurrentMask(); … … 91 91 node.computeLocalToWorldMatrix(*matrix,this); 92 92 pushModelViewMatrix(matrix.get(), node.getReferenceFrame()); 93 93 94 94 handle_cull_callbacks_and_traverse(node); 95 95 … … 109 109 ref_ptr<osg::RefMatrix> matrix = createOrReuseMatrix(node.getMatrix()); 110 110 pushProjectionMatrix(matrix.get()); 111 111 112 112 handle_cull_callbacks_and_traverse(node); 113 113 … … 141 141 // list, if so disable the appropriate ShadowOccluderVolume 142 142 disableAndPushOccludersCurrentMask(_nodePath); 143 143 144 144 145 145 if (isCulled(node)) … … 165 165 if (svo.computeOccluder(_nodePath, *node.getOccluder(), *this,_createDrawables)) 166 166 { 167 167 168 168 if (svo.getVolume()>_minimumShadowOccluderVolume) 169 169 { … … 183 183 // pop the culling mode. 184 184 popCurrentMask(); 185 185 186 186 // pop the current mask for the disabled occluder 187 187 popOccludersCurrentMask(_nodePath); … … 191 191 { 192 192 if (_occluderSet.empty()) return; 193 193 194 194 ShadowVolumeOccluderSet::iterator occludeeItr=_occluderSet.begin(); 195 195 196 196 // skip the first element as this can't be occluded by anything else. 197 197 occludeeItr++; … … 202 202 ++occludeeItr) 203 203 { 204 204 205 205 // search for any occluders that occlude the current occluder, 206 206 // we only need to test any occluder near the front of the set since … … 225 225 break; 226 226 } 227 228 // now check all the holes in the occludee against the occluder, 227 228 // now check all the holes in the occludee against the occluder, 229 229 // do so in reverse order so that the iterators remain valid. 230 230 for(ShadowVolumeOccluder::HoleList::reverse_iterator holeItr=holeList.rbegin(); … … 240 240 ++holeItr; 241 241 } 242 243 } 244 242 243 } 244 245 245 } 246 246 } 247 247 248 248 249 249 if (_occluderSet.size()<=_maximumNumberOfActiveOccluders) return; 250 250 251 251 // move the iterator to the _maximumNumberOfActiveOccluders th occluder. 252 252 occludeeItr = _occluderSet.begin(); 253 253 for(unsigned int i=0;i<_maximumNumberOfActiveOccluders;++i) 254 254 ++occludeeItr; 255 255 256 256 // discard last occluders. 257 257 _occluderSet.erase(occludeeItr,_occluderSet.end()); 258 259 } 258 259 }
