Changeset 13041 for OpenSceneGraph/trunk/src/osg/Node.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Node.cpp (modified) (29 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Node.cpp
r12511 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 { 31 31 public: 32 CollectParentPaths(const osg::Node* haltTraversalAtNode=0) : 32 CollectParentPaths(const osg::Node* haltTraversalAtNode=0) : 33 33 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS), 34 34 _haltTraversalAtNode(haltTraversalAtNode) … … 59 59 _boundingSphereComputed = false; 60 60 _nodeMask = 0xffffffff; 61 61 62 62 _numChildrenRequiringUpdateTraversal = 0; 63 63 … … 91 91 { 92 92 // cleanly detatch any associated stateset (include remove parent links) 93 setStateSet(0); 93 setStateSet(0); 94 94 } 95 95 … … 111 111 void Node::accept(NodeVisitor& nv) 112 112 { 113 if (nv.validNodeMask(*this)) 113 if (nv.validNodeMask(*this)) 114 114 { 115 115 nv.pushOntoNodePath(this); … … 129 129 // do nothing if nothing changed. 130 130 if (_stateset==stateset) return; 131 131 132 132 // track whether we need to account for the need to do a update or event traversal. 133 133 int delta_update = 0; 134 134 int delta_event = 0; 135 135 136 // remove this node from the current statesets parent list 136 // remove this node from the current statesets parent list 137 137 if (_stateset.valid()) 138 138 { … … 141 141 if (_stateset->requiresEventTraversal()) --delta_event; 142 142 } 143 143 144 144 // set the stateset. 145 145 _stateset = stateset; 146 146 147 147 // add this node to the new stateset to the parent list. 148 148 if (_stateset.valid()) … … 152 152 if (_stateset->requiresEventTraversal()) ++delta_event; 153 153 } 154 154 155 155 if (delta_update!=0) 156 156 { … … 181 181 CollectParentPaths cpp(haltTraversalAtNode); 182 182 const_cast<Node*>(this)->accept(cpp); 183 183 184 184 MatrixList matrices; 185 185 186 186 for(NodePathList::iterator itr = cpp._nodePaths.begin(); 187 187 itr != cpp._nodePaths.end(); … … 198 198 } 199 199 } 200 200 201 201 return matrices; 202 202 } … … 206 206 // if no changes just return. 207 207 if (_updateCallback==nc) return; 208 208 209 209 // updated callback has been changed, will need to update 210 210 // both _updateCallback and possibly the numChildrenRequiringAppTraversal … … 229 229 itr != _parents.end(); 230 230 ++itr) 231 { 231 { 232 232 (*itr)->setNumChildrenRequiringUpdateTraversal( 233 233 (*itr)->getNumChildrenRequiringUpdateTraversal()+delta ); … … 252 252 if (!_updateCallback && !_parents.empty()) 253 253 { 254 255 // need to pass on changes to parents. 254 255 // need to pass on changes to parents. 256 256 int delta = 0; 257 257 if (_numChildrenRequiringUpdateTraversal>0) --delta; … … 265 265 itr != _parents.end(); 266 266 ++itr) 267 { 267 { 268 268 (*itr)->setNumChildrenRequiringUpdateTraversal( 269 269 (*itr)->getNumChildrenRequiringUpdateTraversal()+delta … … 273 273 } 274 274 } 275 275 276 276 // finally update this objects value. 277 277 _numChildrenRequiringUpdateTraversal=num; 278 278 279 279 } 280 280 … … 284 284 // if no changes just return. 285 285 if (_eventCallback==nc) return; 286 286 287 287 // event callback has been changed, will need to Event 288 288 // both _EventCallback and possibly the numChildrenRequiringAppTraversal … … 307 307 itr != _parents.end(); 308 308 ++itr) 309 { 309 { 310 310 (*itr)->setNumChildrenRequiringEventTraversal( 311 311 (*itr)->getNumChildrenRequiringEventTraversal()+delta ); … … 330 330 if (!_eventCallback && !_parents.empty()) 331 331 { 332 333 // need to pass on changes to parents. 332 333 // need to pass on changes to parents. 334 334 int delta = 0; 335 335 if (_numChildrenRequiringEventTraversal>0) --delta; … … 343 343 itr != _parents.end(); 344 344 ++itr) 345 { 345 { 346 346 (*itr)->setNumChildrenRequiringEventTraversal( 347 347 (*itr)->getNumChildrenRequiringEventTraversal()+delta … … 351 351 } 352 352 } 353 353 354 354 // finally Event this objects value. 355 355 _numChildrenRequiringEventTraversal=num; 356 356 357 357 } 358 358 … … 361 361 // if no changes just return. 362 362 if (_cullingActive == active) return; 363 363 364 364 // culling active has been changed, will need to update 365 365 // both _cullActive and possibly the parents numChildrenWithCullingDisabled … … 383 383 itr != _parents.end(); 384 384 ++itr) 385 { 385 { 386 386 (*itr)->setNumChildrenWithCullingDisabled( 387 387 (*itr)->getNumChildrenWithCullingDisabled()+delta ); … … 405 405 if (_cullingActive && !_parents.empty()) 406 406 { 407 408 // need to pass on changes to parents. 407 408 // need to pass on changes to parents. 409 409 int delta = 0; 410 410 if (_numChildrenWithCullingDisabled>0) --delta; … … 418 418 itr != _parents.end(); 419 419 ++itr) 420 { 420 { 421 421 (*itr)->setNumChildrenWithCullingDisabled( 422 422 (*itr)->getNumChildrenWithCullingDisabled()+delta … … 426 426 } 427 427 } 428 428 429 429 // finally update this objects value. 430 430 _numChildrenWithCullingDisabled=num; … … 442 442 if (!dynamic_cast<OccluderNode*>(this) && !_parents.empty()) 443 443 { 444 445 // need to pass on changes to parents. 444 445 // need to pass on changes to parents. 446 446 int delta = 0; 447 447 if (_numChildrenWithOccluderNodes>0) --delta; … … 455 455 itr != _parents.end(); 456 456 ++itr) 457 { 457 { 458 458 (*itr)->setNumChildrenWithOccluderNodes( 459 459 (*itr)->getNumChildrenWithOccluderNodes()+delta … … 463 463 } 464 464 } 465 465 466 466 // finally update this objects value. 467 467 _numChildrenWithOccluderNodes=num; 468 468 469 469 } 470 470 … … 545 545 { 546 546 Object::setThreadSafeRefUnref(threadSafe); 547 547 548 548 if (_stateset.valid()) _stateset->setThreadSafeRefUnref(threadSafe); 549 549 if (_updateCallback.valid()) _updateCallback->setThreadSafeRefUnref(threadSafe);
