- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgUtil/IntersectionVisitor.cpp
r11742 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 */ … … 51 51 { 52 52 IntersectorGroup* ig = new IntersectorGroup; 53 53 54 54 // now copy across all intersectors that arn't disabled. 55 55 for(Intersectors::iterator itr = _intersectors.begin(); … … 69 69 { 70 70 if (disabled()) return false; 71 71 72 72 bool foundIntersections = false; 73 73 74 74 for(Intersectors::iterator itr = _intersectors.begin(); 75 75 itr != _intersectors.end(); … … 80 80 else (*itr)->incrementDisabledCount(); 81 81 } 82 83 if (!foundIntersections) 82 83 if (!foundIntersections) 84 84 { 85 85 // need to call leave to clean up the DisabledCount's. … … 87 87 return false; 88 88 } 89 89 90 90 // we have found at least one suitable intersector, so return true 91 91 return true; … … 114 114 { 115 115 (*itr)->intersect(iv, drawable); 116 116 117 117 ++numTested; 118 118 } 119 119 } 120 120 121 121 // OSG_NOTICE<<"Number testing "<<numTested<<std::endl; 122 122 … … 126 126 { 127 127 Intersector::reset(); 128 128 129 129 for(Intersectors::iterator itr = _intersectors.begin(); 130 130 itr != _intersectors.end(); … … 156 156 // override the default node visitor mode. 157 157 setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); 158 158 159 159 _useKdTreesWhenAvailable = true; 160 160 _dummyTraversal = false; 161 161 162 162 _lodSelectionMode = USE_HIGHEST_LEVEL_OF_DETAIL; 163 163 _eyePointDirty = true; 164 164 165 165 LineSegmentIntersector* ls = dynamic_cast<LineSegmentIntersector*>(intersector); 166 if (ls) 166 if (ls) 167 167 { 168 168 setReferenceEyePoint(ls->getStart()); … … 176 176 177 177 setIntersector(intersector); 178 178 179 179 setReadCallback(readCallback); 180 180 } … … 196 196 osg::ref_ptr<Intersector> intersector = _intersectorStack.front(); 197 197 intersector->reset(); 198 198 199 199 _intersectorStack.clear(); 200 200 _intersectorStack.push_back(intersector); … … 309 309 else 310 310 targetRangeValue = 0; // Init low to find max value 311 311 312 312 const osg::LOD::RangeList rl = plod.getRangeList(); 313 313 osg::LOD::RangeList::const_iterator rit; … … 364 364 } 365 365 } 366 #else 366 #else 367 367 // older code than above block, that assumes that the PagedLOD is ordered correctly 368 368 // i.e. low res children first, no duplicate ranges. 369 369 370 370 osg::ref_ptr<osg::Node> highestResChild; 371 371 … … 374 374 highestResChild = _readCallback->readNodeFile( plod.getDatabasePath() + plod.getFileName(plod.getNumFileNames()-1) ); 375 375 } 376 376 377 377 if ( !highestResChild.valid() && plod.getNumChildren()>0) 378 378 { … … 404 404 405 405 traverse(transform); 406 406 407 407 // pop the clone. 408 408 pop_clone(); 409 409 410 410 popModelMatrix(); 411 411 … … 425 425 426 426 traverse(projection); 427 427 428 428 // pop the clone. 429 429 pop_clone(); 430 430 431 431 popProjectionMatrix(); 432 432 … … 441 441 // note, commenting out right now because default Camera setup is with the culling active. Should this be changed? 442 442 // if (!enter(camera)) return; 443 443 444 444 // OSG_NOTICE<<"inside apply(Camera&)"<<std::endl; 445 445 … … 456 456 model = new osg::RefMatrix(*getModelMatrix()); 457 457 } 458 else // pre multiply 458 else // pre multiply 459 459 { 460 460 projection = new osg::RefMatrix(camera.getProjectionMatrix()*(*getProjectionMatrix())); 461 461 view = new osg::RefMatrix(*getViewMatrix()); 462 462 model = new osg::RefMatrix(camera.getViewMatrix()*(*getModelMatrix())); 463 } 464 } 463 } 464 } 465 465 else 466 466 { … … 470 470 model = new osg::RefMatrix(); 471 471 } 472 472 473 473 if (camera.getViewport()) pushWindowMatrix( camera.getViewport() ); 474 474 pushProjectionMatrix(projection); … … 480 480 481 481 traverse(camera); 482 482 483 483 // pop the clone. 484 484 pop_clone(); 485 485 486 486 popModelMatrix(); 487 487 popViewMatrix(); … … 499 499 switch (_referenceEyePointCoordinateFrame) 500 500 { 501 case(Intersector::WINDOW): 501 case(Intersector::WINDOW): 502 502 if (getWindowMatrix()) matrix.preMult( *getWindowMatrix() ); 503 503 if (getProjectionMatrix()) matrix.preMult( *getProjectionMatrix() ); … … 505 505 if (getModelMatrix()) matrix.preMult( *getModelMatrix() ); 506 506 break; 507 case(Intersector::PROJECTION): 507 case(Intersector::PROJECTION): 508 508 if (getProjectionMatrix()) matrix.preMult( *getProjectionMatrix() ); 509 509 if (getViewMatrix()) matrix.preMult( *getViewMatrix() ); 510 510 if (getModelMatrix()) matrix.preMult( *getModelMatrix() ); 511 511 break; 512 case(Intersector::VIEW): 512 case(Intersector::VIEW): 513 513 if (getViewMatrix()) matrix.preMult( *getViewMatrix() ); 514 514 if (getModelMatrix()) matrix.preMult( *getModelMatrix() ); … … 524 524 _eyePoint = _referenceEyePoint * inverse; 525 525 _eyePointDirty = false; 526 526 527 527 return _eyePoint; 528 528 }
