| 599 | |
| 600 | template< S32 NUM_DIMENSIONS, class Object > |
| 601 | void ScopeTracker< NUM_DIMENSIONS, Object >::_moveTrackingNode( U32 dimension, NodeType* node, F32 newPosition ) |
| 602 | { |
| 603 | PROFILE_SCOPE( ScopeTracker_moveTrackingNode ); |
| 604 | |
| 605 | AssertFatal( TypeTraits< F32 >::MIN <= newPosition && newPosition <= TypeTraits< F32 >::MAX, "Invalid float in object coordinate!" ); |
| 606 | |
| 607 | enum EDirection |
| 608 | { |
| 609 | DIRECTION_Up, |
| 610 | DIRECTION_Down |
| 611 | }; |
| 612 | |
| 613 | // Determine in which direction we are sliding the node. |
| 614 | |
| 615 | EDirection direction; |
| 616 | if( newPosition < node->getPosition() ) |
| 617 | { |
| 618 | direction = DIRECTION_Down; |
| 619 | if( node->getPrev()->getPosition() <= newPosition ) |
| 620 | { |
| 621 | node->setPosition( newPosition ); |
| 622 | return; // Nothing to do. |
| 623 | } |
| 624 | } |
| 625 | else if( newPosition > node->getPosition() ) |
| 626 | { |
| 627 | direction = DIRECTION_Up; |
| 628 | if( node->getNext()->getPosition() >= newPosition ) |
| 629 | { |
| 630 | node->setPosition( newPosition ); |
| 631 | return; // Nothing to do. |
| 632 | } |
| 633 | } |
| 634 | else |
| 635 | return; // Nothing to to. |
| 636 | |
| 637 | const bool isReferenceNode = node->isReference(); |
| 638 | |
| 639 | // Unlink the node. |
| 640 | |
| 641 | NodeType* next = node->getNext(); |
| 642 | NodeType* prev = node->getPrev(); |
| 643 | |
| 644 | next->setPrev( prev ); |
| 645 | prev->setNext( next ); |
| 646 | |
| 647 | // Iterate through to the node's new position. |
| 648 | |
| 649 | while( ( direction == DIRECTION_Up && next->getPosition() < newPosition ) |
| 650 | || ( direction == DIRECTION_Down && prev->getPosition() > newPosition ) ) |
| 651 | { |
| 652 | NodeType* current = 0; |
| 653 | switch( direction ) |
| 654 | { |
| 655 | case DIRECTION_Up: current = next; break; |
| 656 | case DIRECTION_Down: current = prev; break; |
| 657 | } |
| 658 |
nothing calls this directly
no test coverage detected