MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _moveTrackingNode

Method _moveTrackingNode

Engine/source/util/scopeTracker.h:601–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599
600template< S32 NUM_DIMENSIONS, class Object >
601void 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

Callers

nothing calls this directly

Calls 13

isReferenceMethod · 0.80
setPrevMethod · 0.80
isMinMethod · 0.80
isMaxMethod · 0.80
setInScopeMethod · 0.80
isInScopeMethod · 0.80
getPositionMethod · 0.45
getPrevMethod · 0.45
setPositionMethod · 0.45
getNextMethod · 0.45
setNextMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected