Axiom.Core.PatchSurface.SubdivideCurve C# (CSharp) Method

SubdivideCurve() protected method

protected SubdivideCurve ( IntPtr lockedBuffer, int startIdx, int stepSize, int numSteps, int iterations ) : void
lockedBuffer System.IntPtr
startIdx int
stepSize int
numSteps int
iterations int
return void
		protected void SubdivideCurve( IntPtr lockedBuffer, int startIdx, int stepSize, int numSteps, int iterations )
		{
			// Subdivides a curve within a sparsely populated buffer (gaps are already there to be interpolated into)
			int leftIdx, rightIdx, destIdx, halfStep, maxIdx;
			bool firstSegment;

			maxIdx = startIdx + ( numSteps * stepSize );
			int step = stepSize;

			while ( iterations-- > 0 )
			{
				halfStep = step / 2;
				leftIdx = startIdx;
				destIdx = leftIdx + halfStep;
				rightIdx = leftIdx + step;
				firstSegment = true;

				while ( leftIdx < maxIdx )
				{
					// Interpolate
					InterpolateVertexData( lockedBuffer, leftIdx, rightIdx, destIdx );

					// If 2nd or more segment, interpolate current left between current and last mid points
					if ( !firstSegment )
					{
						InterpolateVertexData( lockedBuffer, leftIdx - halfStep, leftIdx + halfStep, leftIdx );
					}
					// Next segment
					leftIdx = rightIdx;
					destIdx = leftIdx + halfStep;
					rightIdx = leftIdx + step;
					firstSegment = false;
				}

				step = halfStep;
			}
		}