| 758 | |
| 759 | template< S32 NUM_DIMENSIONS, class Object > |
| 760 | void ScopeTracker< NUM_DIMENSIONS, Object >::_initTracking() |
| 761 | { |
| 762 | PROFILE_SCOPE( ScopeTracker_initTracking ); |
| 763 | |
| 764 | AssertFatal( bool( getReferenceObject() ), |
| 765 | "ScopeTracker::_initTracking - can only be called with a valid reference object" ); |
| 766 | |
| 767 | // Put a single tracking node onto each of the lists for |
| 768 | // the reference object center. |
| 769 | |
| 770 | F32 position[ NUM_DIMENSIONS ]; |
| 771 | Deref( mReferenceObject ).getReferenceCenter( position ); |
| 772 | |
| 773 | for( U32 n = 0; n < NUM_DIMENSIONS; ++ n ) |
| 774 | { |
| 775 | AssertFatal( TypeTraits< F32 >::MIN <= position[ n ] && position[ n ] <= TypeTraits< F32 >::MAX, "Invalid float in object coordinate!" ); |
| 776 | |
| 777 | NodeType* node = Deref( mReferenceObject ).getMinTrackingNode( n ); |
| 778 | node->mFlags.set( NodeType::FLAG_Reference ); |
| 779 | |
| 780 | node->setPosition( position[ n ] ); |
| 781 | |
| 782 | _insertTrackingNode( n, node ); |
| 783 | } |
| 784 | |
| 785 | // Update the surroundings of the reference object |
| 786 | // in the tracking lists for each dimension. |
| 787 | |
| 788 | for( U32 n = 0; n < NUM_DIMENSIONS; ++ n ) |
| 789 | { |
| 790 | //TODO: this could be optimized by dynamically determining whether to walk upwards |
| 791 | // or downwards depending on which span has fewer nodes; finding that out is not immediately |
| 792 | // obvious, though |
| 793 | |
| 794 | // Walk from the left bound node upwards until we reach the |
| 795 | // reference object's marker. Everything that has its max node |
| 796 | // past the reference object is in scope. |
| 797 | |
| 798 | F32 referencePos = Deref( mReferenceObject ).getMinTrackingNode( n )->getPosition(); |
| 799 | for( NodeType* node = mTrackingList[ n ][ 0 ]->getNext(); node->getPosition() < referencePos; node = node->getNext() ) |
| 800 | if( !node->isMax() && node->getOpposite()->getPosition() > referencePos ) |
| 801 | { |
| 802 | node->getObject()->setInScope( n, true ); |
| 803 | |
| 804 | // If this is the last dimension we're working on and |
| 805 | // the current object is in-scope on all dimension, |
| 806 | // promote to in-scope status. |
| 807 | |
| 808 | if( n == ( NUM_DIMENSIONS - 1 ) && node->getObject()->isInScope() ) |
| 809 | _onScopeIn( ( Object ) node->getObject() ); |
| 810 | } |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | //----------------------------------------------------------------------------- |
| 815 |
nothing calls this directly
no test coverage detected