Axiom.Core.BillboardChain.AddChainElement C# (CSharp) Method

AddChainElement() public method

public AddChainElement ( int chainIndex, Element billboardChainElement ) : void
chainIndex int
billboardChainElement Element
return void
		public virtual void AddChainElement( int chainIndex, Element billboardChainElement )
		{
			if ( chainIndex >= this.chainCount )
			{
				throw new IndexOutOfRangeException();
			}
			ChainSegment segment = this.chainSegmentList[ chainIndex ];
			if ( segment.head == SEGMENT_EMPTY )
			{
				// Tail starts at end, head grows backwards
				segment.tail = this.maxElementsPerChain - 1;
				segment.head = segment.tail;
				this.indexContentDirty = true;
			}
			else
			{
				if ( segment.head == 0 )
				{
					// Wrap backwards
					segment.head = this.maxElementsPerChain - 1;
				}
				else
				{
					// just step backwards
					--segment.head;
				}
				// Run out of elements?
				if ( segment.head == segment.tail )
				{
					// Move tail backwards too, losing the end of the segment and re-using
					// it in the head
					if ( segment.head == 0 )
					{
						segment.tail = this.maxElementsPerChain - 1;
					}
					else
					{
						--segment.tail;
					}
				}
			}

			// set the details
			this.chainElementList[ segment.start + segment.head ] = billboardChainElement;

			this.indexContentDirty = true;
			this.boundsDirty = true;

			// tell parent node to update bounds
			if ( ParentNode != null )
			{
				ParentNode.NeedUpdate();
			}
		}