Changeset 273 for osgVisual/trunk/include
- Timestamp:
- Mar 19, 2011, 5:39:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/include/util/visual_util.h
r226 r273 296 296 static bool strToBool(std::string s); 297 297 298 template<class T> 299 class FindTopMostNodeOfTypeVisitor : public osg::NodeVisitor 300 { 301 public: 302 FindTopMostNodeOfTypeVisitor(): 303 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), 304 _foundNode(0) 305 {} 306 307 void apply(osg::Node& node) 308 { 309 T* result = dynamic_cast<T*>(&node); 310 if (result) 311 { 312 _foundNode = result; 313 } 314 else 315 { 316 traverse(node); 317 } 318 } 319 320 T* _foundNode; 321 }; 322 323 template<class T> 324 static T* findTopMostNodeOfType(osg::Node* node) 325 { 326 if (!node) return 0; 327 328 FindTopMostNodeOfTypeVisitor<T> fnotv; 329 node->accept(fnotv); 330 331 return fnotv._foundNode; 332 } 333 298 334 private: 299 335 /**
Note: See TracChangeset
for help on using the changeset viewer.