private RecognizedPrimitiveInfo GetLastIndexId(
RenderEventArgs arg,
List<RecognizedPrimitiveInfo> primitiveInfoList,
int x, int y)
{
if (primitiveInfoList == null || primitiveInfoList.Count == 0) { return null; }
#if DEBUG
SameLengths(primitiveInfoList);
#endif
if (primitiveInfoList[0].VertexIds.Length == 1)// picking a point.
{
return primitiveInfoList[0];
}
int current = 0;
#if DEBUG
NoPrimitiveRestartIndex(primitiveInfoList);
#endif
for (int i = 1; i < primitiveInfoList.Count; i++)
{
OneIndexBuffer twoPrimitivesIndexBuffer;
uint lastIndex0, lastIndex1;
AssembleIndexBuffer(
primitiveInfoList[current], primitiveInfoList[i], this.indexBuffer.Mode,
out twoPrimitivesIndexBuffer, out lastIndex0, out lastIndex1);
uint pickedIndex = Pick(arg, twoPrimitivesIndexBuffer,
x, y);
if (pickedIndex == lastIndex1)
{ current = i; }
else if (pickedIndex == lastIndex0)
{ /* nothing to do */}
else if (pickedIndex == uint.MaxValue)// 两个候选图元都没有被拾取到
{ /* nothing to do */}
else
{ throw new Exception("This should not happen!"); }
}
return primitiveInfoList[current];
}