Changeset 13041 for OpenSceneGraph/trunk/src/osg/Sequence.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Sequence.cpp (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Sequence.cpp
r12907 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 */ … … 40 40 _sync(false), 41 41 _clearOnStop(false) 42 42 43 43 { 44 44 setNumChildrenRequiringUpdateTraversal(1); … … 67 67 _clearOnStop(seq._clearOnStop) 68 68 { 69 setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); 69 setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); 70 70 } 71 71 … … 116 116 { 117 117 if (pos<_frameTime.size()) 118 _frameTime.erase(_frameTime.begin()+pos, 119 osg::minimum(_frameTime.begin()+(pos+numChildrenToRemove), 118 _frameTime.erase(_frameTime.begin()+pos, 119 osg::minimum(_frameTime.begin()+(pos+numChildrenToRemove), 120 120 _frameTime.end()) ); 121 121 _resetTotalTime = true; … … 141 141 } 142 142 } 143 143 144 144 } 145 145 … … 179 179 int ubegin, uend; 180 180 181 switch (mode) 181 switch (mode) 182 182 { 183 183 case START: … … 223 223 224 224 225 if (nv.getVisitorType()==NodeVisitor::UPDATE_VISITOR && 225 if (nv.getVisitorType()==NodeVisitor::UPDATE_VISITOR && 226 226 _mode == START && 227 227 !_frameTime.empty() && getNumChildren()!=0) 228 228 { 229 229 230 230 // if begin or end < 0, make it last frame 231 231 int _ubegin = (_begin < 0 ? (int)_frameTime.size()-1: _begin); … … 279 279 else 280 280 { 281 if ( (_loopMode == LOOP) && 282 ( (_step>0 && _value!=_send) || 281 if ( (_loopMode == LOOP) && 282 ( (_step>0 && _value!=_send) || 283 283 (_step<0 && _value!=_sbegin))) 284 284 { … … 294 294 } 295 295 } 296 296 297 297 // update local variables 298 298 _update(); … … 307 307 // most of the time it's just the next frame in the sequence 308 308 int nextValue = _getNextValue(); 309 if (!_sync || 309 if (!_sync || 310 310 ((_now - _start) <= (_frameTime[_value]+_frameTime[nextValue])*osg::absolute(_speed)) ) 311 311 { 312 312 _start += _frameTime[_value]*osg::absolute(_speed); 313 313 // repeat or change directions? 314 if ( (_step>0 && nextValue==_send) || 314 if ( (_step>0 && nextValue==_send) || 315 315 (_step<0 && nextValue==_sbegin)) 316 316 { … … 331 331 // elapsed time from start of the frame 332 332 double deltaT = _now - _start; 333 333 334 334 // factors _speed into account 335 335 double adjTotalTime = _totalTime*osg::absolute(_speed); 336 336 337 337 // how many laps? 338 338 int loops = (int)(deltaT/adjTotalTime); 339 340 339 340 341 341 // adjust reps & quick check to see if done becuase reps used up 342 342 343 343 if (_nreps>0) 344 344 { … … 347 347 else 348 348 _nrepsRemain -= 2*loops; 349 349 350 350 if (_nrepsRemain<=0) 351 351 { … … 355 355 } 356 356 } 357 357 358 358 // deduct off time for laps- _value shouldn't change as it's modulo the total time 359 359 double jumpStart = ((double)loops * adjTotalTime); 360 360 361 361 // step through frames one at a time until caught up 362 362 while (deltaT-jumpStart > _frameTime[_value]*osg::absolute(_speed)) … … 365 365 _value = _getNextValue(); 366 366 } 367 367 368 368 // set start time 369 369 _start += jumpStart; … … 399 399 int _ubegin = (_begin < 0 ? (int)_frameTime.size()-1: _begin); 400 400 int _uend = (_end < 0 ? (int)_frameTime.size()-1: _end); 401 401 402 402 int _sbegin = osg::minimum(_ubegin,_uend); 403 403 int _send = osg::maximum(_ubegin,_uend); … … 423 423 v+=vs; 424 424 } 425 425 426 426 return v; 427 427 } … … 445 445 int _ubegin = (_begin < 0 ? (int)_frameTime.size()-1: _begin); 446 446 int _uend = (_end < 0 ? (int)_frameTime.size()-1: _end); 447 447 448 448 int _sbegin = osg::minimum(_ubegin,_uend); 449 449 int _send = osg::maximum(_ubegin,_uend); … … 455 455 _resetTotalTime = true; 456 456 } 457 457 458 458 // if _start<0, new or restarted 459 459 if (_start<0) … … 462 462 _resetTotalTime = true; 463 463 } 464 464 465 465 // need to calculate time of a complete sequence? 466 466 // time is different depending on loop mode … … 491 491 _resetTotalTime = false; 492 492 } 493 494 } 493 494 }
