Axiom.Core.BillboardChain.UpdateIndexBuffer C# (CSharp) Метод

UpdateIndexBuffer() защищенный Метод

protected UpdateIndexBuffer ( ) : void
Результат void
		protected virtual void UpdateIndexBuffer()
		{
			this.SetupBuffers();

			if ( this.indexContentDirty )
			{
				IntPtr pBufferBase = this.indexData.indexBuffer.Lock( BufferLocking.Discard );
				this.indexData.indexCount = 0;

				unsafe
				{
					ushort* pShort = (ushort*)pBufferBase.ToPointer();
					// indexes
					foreach ( ChainSegment segment in this.chainSegmentList )
					{
						// Skip 0 or 1 element segment counts
						if ( segment.head != SEGMENT_EMPTY && segment.head != segment.tail )
						{
							// Start from head + 1 since it's only useful in pairs
							int laste = segment.head;

							while ( true )
							{
								int e = laste + 1;
								// Wrap Forwards
								if ( e == this.maxElementsPerChain )
								{
									e = 0;
								}
								// indexes of this element are (e * 2) and (e * 2) + 1
								// indexes of the last element are the same, -2
								ushort baseIndex = (ushort)( ( e + segment.start ) * 2 );
								ushort lastBaseIndex = (ushort)( ( laste + segment.start ) * 2 );

								*pShort++ = lastBaseIndex;
								*pShort++ = (ushort)( lastBaseIndex + 1 );
								*pShort++ = baseIndex;
								*pShort++ = (ushort)( lastBaseIndex + 1 );
								*pShort++ = (ushort)( baseIndex + 1 );
								*pShort++ = baseIndex;

								this.indexData.indexCount += 6;

								if ( e == segment.tail )
								{
									break;
								}

								laste = e;
							}
						}
					}
				}

				this.indexData.indexBuffer.Unlock();
				this.indexContentDirty = false;
			}
		}