protected override void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List <RecognizedPrimitiveIndex> lastIndexIdList) { int length = oneIndexBufferPtr.Length; unsafe { var array = (byte *)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; for (i = i + 3; i < length; i++) { var value = array[i]; if (value == lastVertexId && (i - nearestRestartIndex) % 4 == 0) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 3]); item.IndexIdList.Add(array[i - 2]); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
internal override uint[] Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List <uint> indexList = lastIndexId.IndexIdList; if (indexList.Count < 3) { throw new ArgumentException(); } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer <uint>(DrawMode.LineLoop, BufferUsage.StaticDraw)) { buffer.Create(indexList.Count); unsafe { var array = (uint *)buffer.Header.ToPointer(); for (int i = 0; i < indexList.Count; i++) { array[i] = indexList[i]; } } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id == indexList[0]) { return(new uint[] { indexList[indexList.Count - 1], id, }); } else { uint[] result = null; for (int i = 1; i < indexList.Count; i++) { if (id == indexList[i]) { result = new uint[] { indexList[i - 1], indexList[i], }; break; } } if (result != null) { return(result); } else { throw new Exception("This should not happen!"); } } }
protected override void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (byte*)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; while (i < length && array[i] == primitiveRestartIndex) { nearestRestartIndex = i; i++; } for (i = i + 2; i < length; i++) { var value = array[i]; if (value == primitiveRestartIndex) { // try the loop back line. nearestRestartIndex = i; } else if (value == lastVertexId && array[i - 1] != primitiveRestartIndex && array[nearestRestartIndex + 1] != primitiveRestartIndex && nearestRestartIndex + 2 < i) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[nearestRestartIndex + 1]); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
protected override void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List <RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (uint *)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; while (i < length && array[i] == primitiveRestartIndex) { nearestRestartIndex = i; i++; } for (i = i + 1; i < length; i++) { var value = array[i]; if (value == primitiveRestartIndex) { nearestRestartIndex = i; } else if (value == lastVertexId && array[i - 1] != primitiveRestartIndex && (i - nearestRestartIndex) % 2 == 0) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
internal override uint Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List<uint> indexList = lastIndexId.IndexIdList; if (indexList.Count < 3) { throw new ArgumentException(); } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer<uint>(DrawMode.Points, BufferUsage.StaticDraw)) { buffer.Alloc(indexList.Count); unsafe { var array = (uint*)buffer.Header.ToPointer(); for (int i = 0; i < indexList.Count; i++) { array[i] = indexList[i]; } } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id != uint.MaxValue) { return id; } else { throw new Exception("This should not happen!"); } }
protected override void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List <RecognizedPrimitiveIndex> lastIndexIdList) { int length = oneIndexBufferPtr.Length; unsafe { var array = (uint *)pointer.ToPointer(); for (uint i = 1; i < length; i++) { var value = array[i]; if (value == lastVertexId) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } if (array[0] == lastVertexId && length > 1) { var item = new RecognizedPrimitiveIndex(lastVertexId, 0); item.IndexIdList.Add(array[length - 1]); item.IndexIdList.Add(lastVertexId); lastIndexIdList.Add(item); } } }
/// <summary> /// 将共享点前移,构成2个图元组成的新的小小的索引。 /// </summary> /// <param name="recognizedPrimitiveIndex0"></param> /// <param name="recognizedPrimitiveIndex1"></param> /// <returns></returns> private List<uint> ArrangeIndexes( RecognizedPrimitiveIndex recognizedPrimitiveIndex0, RecognizedPrimitiveIndex recognizedPrimitiveIndex1, DrawMode drawMode, out uint lastIndex0, out uint lastIndex1) { List<uint> sameIndexList = new List<uint>(); List<uint> array0 = new List<uint>(recognizedPrimitiveIndex0.IndexIdList); List<uint> array1 = new List<uint>(recognizedPrimitiveIndex1.IndexIdList); array0.Sort(); array1.Sort(); int p0 = 0, p1 = 0; while (p0 < array0.Count && p1 < array1.Count) { if (array0[p0] < array1[p1]) { p0++; } else if (array0[p0] > array1[p1]) { p1++; } else { sameIndexList.Add(array0[p0]); array0.RemoveAt(p0); array1.RemoveAt(p1); } } if (array0.Count == 0 && array1.Count == 0) { throw new Exception("Two primitives are totally the same!"); } if (array0.Count > 0) { lastIndex0 = array0.Last(); } else { if (sameIndexList.Count == 0) { throw new Exception("array0 is totally empty!"); } lastIndex0 = sameIndexList.Last(); } if (array1.Count > 0) { lastIndex1 = array1.Last(); } else { if (sameIndexList.Count == 0) { throw new Exception("array1 is totally empty!"); } lastIndex1 = sameIndexList.Last(); } if (lastIndex0 == lastIndex1) { throw new Exception(); } List<uint> result = new List<uint>(); result.AddRange(sameIndexList); result.AddRange(array0); result.Add(uint.MaxValue);// primitive restart index result.AddRange(sameIndexList); result.AddRange(array1); return result; }
internal override uint[] Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List <uint> indexList = lastIndexId.IndexIdList; if (indexList.Count != 4) { throw new ArgumentException(); } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer <uint>(DrawMode.Lines, BufferUsage.StaticDraw)) { buffer.Create(8); unsafe { var array = (uint *)buffer.Header.ToPointer(); array[0] = indexList[0]; array[1] = indexList[1]; array[2] = indexList[1]; array[3] = indexList[2]; array[4] = indexList[2]; array[5] = indexList[3]; array[6] = indexList[3]; array[7] = indexList[0]; } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id == indexList[1]) { return(new uint[] { indexList[0], indexList[1], }); } else if (id == indexList[2]) { return(new uint[] { indexList[1], indexList[2], }); } else if (id == indexList[3]) { return(new uint[] { indexList[2], indexList[3], }); } else if (id == indexList[0]) { return(new uint[] { indexList[2], indexList[0], }); } else { throw new Exception("This should not happen!"); } }
/// <summary> /// 是三角形,就pick一个三角形;是四边形,就pick一个四边形,是多边形,就pick一个多边形。 /// </summary> /// <param name="stageVertexId"></param> /// <param name="lastIndexId"></param> /// <param name="typeOfMode"></param> /// <returns></returns> private PickedGeometry PickWhateverItIs(uint stageVertexId, RecognizedPrimitiveIndex lastIndexId, GeometryType typeOfMode) { PickedGeometry pickedGeometry = new PickedGeometry(); pickedGeometry.GeometryType = typeOfMode; pickedGeometry.StageVertexId = stageVertexId; pickedGeometry.From = this; pickedGeometry.Indexes = lastIndexId.IndexIdList.ToArray(); pickedGeometry.Positions = FillPickedGeometrysPosition(pickedGeometry.Indexes); return(pickedGeometry); }
protected override void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List <RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (byte *)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; while (i < length && array[i] == primitiveRestartIndex) { nearestRestartIndex = i; i++; } for (i = i + 1; i < length; i++) { var value = array[i]; if (value == primitiveRestartIndex) { // try the loop back line. if (array[nearestRestartIndex + 1] == lastVertexId && array[i - 1] != primitiveRestartIndex && nearestRestartIndex + 1 < i - 1) { var item = new RecognizedPrimitiveIndex(lastVertexId, (uint)(nearestRestartIndex + 1)); item.IndexIdList.Add(value); item.IndexIdList.Add(lastVertexId); lastIndexIdList.Add(item); } nearestRestartIndex = i; } else if (value == lastVertexId && array[i - 1] != primitiveRestartIndex) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } if (array[nearestRestartIndex + 1] == lastVertexId && array[length - 1] != primitiveRestartIndex && nearestRestartIndex + 1 < length - 1) { var item = new RecognizedPrimitiveIndex(lastVertexId, (uint)(nearestRestartIndex + 1)); item.IndexIdList.Add(array[length - 1]); item.IndexIdList.Add(lastVertexId); lastIndexIdList.Add(item); } } }
internal override uint[] Search(RenderEventArg arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List<uint> indexList = lastIndexId.IndexIdList; if (indexList.Count < 3) { throw new ArgumentException(); } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer<uint>(DrawMode.LineLoop, BufferUsage.StaticDraw)) { buffer.Alloc(indexList.Count); unsafe { var array = (uint*)buffer.Header.ToPointer(); for (int i = 0; i < indexList.Count; i++) { array[i] = indexList[i]; } } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id == indexList[0]) { return new uint[] { indexList[indexList.Count - 1], id, }; } else { uint[] result = null; for (int i = 1; i < indexList.Count; i++) { if (id == indexList[i]) { result = new uint[] { indexList[i - 1], indexList[i], }; break; } } if (result != null) { return result; } else { throw new Exception("This should not happen!"); } } }
private RecognizedPrimitiveIndex GetLastIndexIdOfPickedGeometry( RenderEventArgs arg, uint lastVertexId, int x, int y) { List <RecognizedPrimitiveIndex> lastIndexIdList = GetLastIndexIdList(arg, lastVertexId); if (lastIndexIdList.Count == 0) { return(null); } RecognizedPrimitiveIndex lastIndexId = GetLastIndexId( arg, lastIndexIdList, x, y); return(lastIndexId); }
protected override void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (uint*)pointer.ToPointer(); for (uint i = 0; i < length; i++) { var value = array[i]; if (value == lastVertexId) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
protected override void RecognizeUShort(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List <RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (ushort *)pointer.ToPointer(); for (uint i = 0; i < length; i++) { var value = array[i]; if (value == lastVertexId) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
internal override uint Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List <uint> indexList = lastIndexId.IndexIdList; if (indexList.Count < 3) { throw new ArgumentException(); } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer <uint>(DrawMode.Points, BufferUsage.StaticDraw)) { buffer.Alloc(indexList.Count); unsafe { var array = (uint *)buffer.Header.ToPointer(); for (int i = 0; i < indexList.Count; i++) { array[i] = indexList[i]; } } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id != uint.MaxValue) { return(id); } else { throw new Exception("This should not happen!"); } }
internal override uint[] Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer) { List<uint> indexList = lastIndexId.IndexIdList; if (indexList.Count != 3) { throw new ArgumentException(); } //if (indexList[0] == indexList[1]) { return new uint[] { indexList[0], indexList[2], }; } //else if (indexList[0] == indexList[2]) { return new uint[] { indexList[0], indexList[1], }; } //else if (indexList[1] == indexList[2]) { return new uint[] { indexList[1], indexList[0], }; } OneIndexBufferPtr indexBufferPtr = null; using (var buffer = new OneIndexBuffer<uint>(DrawMode.Lines, BufferUsage.StaticDraw)) { buffer.Alloc(6); unsafe { var array = (uint*)buffer.Header.ToPointer(); array[0] = indexList[0]; array[1] = indexList[1]; array[2] = indexList[1]; array[3] = indexList[2]; array[4] = indexList[2]; array[5] = indexList[0]; } indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr; } modernRenderer.Render4InnerPicking(arg, indexBufferPtr); uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height); indexBufferPtr.Dispose(); if (id == indexList[1]) { return new uint[] { indexList[0], indexList[1], }; } else if (id == indexList[2]) { return new uint[] { indexList[1], indexList[2], }; } else if (id == indexList[0]) { return new uint[] { indexList[2], indexList[0], }; } else { throw new Exception("This should not happen!"); } }
protected override void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList) { int length = oneIndexBufferPtr.Length; unsafe { var array = (byte*)pointer.ToPointer(); uint i = 0; for (i = i + 2; i < length; i++) { var value = array[i]; if (value == lastVertexId) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[0]); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
protected override void RecognizeUInt(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList) { int length = oneIndexBufferPtr.Length; unsafe { var array = (uint*)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; for (i = i + 2; i < length; i++) { var value = array[i]; if (value == lastVertexId && (i - nearestRestartIndex) % 3 == 0) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 2]); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
/// <summary> /// 将共享点前移,然后重新渲染、拾取 /// </summary> /// <param name="recognizedPrimitiveIndex0"></param> /// <param name="recognizedPrimitiveIndex1"></param> /// <param name="drawMode"></param> /// <param name="oneIndexBufferPtr"></param> /// <param name="lastIndex0"></param> /// <param name="lastIndex1"></param> private void AssembleIndexBuffer( RecognizedPrimitiveIndex recognizedPrimitiveIndex0, RecognizedPrimitiveIndex recognizedPrimitiveIndex1, DrawMode drawMode, out OneIndexBufferPtr oneIndexBufferPtr, out uint lastIndex0, out uint lastIndex1) { List <uint> indexArray = ArrangeIndexes( recognizedPrimitiveIndex0, recognizedPrimitiveIndex1, drawMode, out lastIndex0, out lastIndex1); if (indexArray.Count != recognizedPrimitiveIndex0.IndexIdList.Count + 1 + recognizedPrimitiveIndex1.IndexIdList.Count) { throw new Exception(); } using (var indexBuffer = new OneIndexBuffer <uint>(drawMode, BufferUsage.StaticDraw)) { indexBuffer.Create( recognizedPrimitiveIndex0.IndexIdList.Count + 1 + recognizedPrimitiveIndex1.IndexIdList.Count); unsafe { var array = (uint *)indexBuffer.Header.ToPointer(); for (int i = 0; i < indexArray.Count; i++) { array[i] = indexArray[i]; } } oneIndexBufferPtr = indexBuffer.GetBufferPtr() as OneIndexBufferPtr; } }
/// <summary> /// 将共享点前移,然后重新渲染、拾取 /// </summary> /// <param name="recognizedPrimitiveIndex0"></param> /// <param name="recognizedPrimitiveIndex1"></param> /// <param name="drawMode"></param> /// <param name="oneIndexBufferPtr"></param> /// <param name="lastIndex0"></param> /// <param name="lastIndex1"></param> private void AssembleIndexBuffer( RecognizedPrimitiveIndex recognizedPrimitiveIndex0, RecognizedPrimitiveIndex recognizedPrimitiveIndex1, DrawMode drawMode, out OneIndexBufferPtr oneIndexBufferPtr, out uint lastIndex0, out uint lastIndex1) { List<uint> indexArray = ArrangeIndexes( recognizedPrimitiveIndex0, recognizedPrimitiveIndex1, drawMode, out lastIndex0, out lastIndex1); if (indexArray.Count != recognizedPrimitiveIndex0.IndexIdList.Count + 1 + recognizedPrimitiveIndex1.IndexIdList.Count) { throw new Exception(); } using (var indexBuffer = new OneIndexBuffer<uint>(drawMode, BufferUsage.StaticDraw)) { indexBuffer.Alloc( recognizedPrimitiveIndex0.IndexIdList.Count + 1 + recognizedPrimitiveIndex1.IndexIdList.Count); unsafe { var array = (uint*)indexBuffer.Header.ToPointer(); for (int i = 0; i < indexArray.Count; i++) { array[i] = indexArray[i]; } } oneIndexBufferPtr = indexBuffer.GetBufferPtr() as OneIndexBufferPtr; } }
internal abstract uint[] Search(RenderEventArg arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer);
protected override void RecognizeUShort(uint lastVertexId, IntPtr pointer, OneIndexBufferPtr oneIndexBufferPtr, List<RecognizedPrimitiveIndex> lastIndexIdList, uint primitiveRestartIndex) { int length = oneIndexBufferPtr.Length; unsafe { var array = (ushort*)pointer.ToPointer(); long nearestRestartIndex = -1; uint i = 0; while (i < length && array[i] == primitiveRestartIndex) { nearestRestartIndex = i; i++; } for (i = i + 1; i < length; i++) { var value = array[i]; if (value == primitiveRestartIndex) { nearestRestartIndex = i; } else if (value == lastVertexId && array[i - 1] != primitiveRestartIndex && (i - nearestRestartIndex) % 2 == 0) { var item = new RecognizedPrimitiveIndex(lastVertexId, i); item.IndexIdList.Add(array[i - 1]); item.IndexIdList.Add(value); lastIndexIdList.Add(item); } } } }
private PickedGeometry SearchLine(RenderEventArgs arg, uint stageVertexId, int x, int y, uint lastVertexId, RecognizedPrimitiveIndex lastIndexId, OneIndexLineSearcher searcher) { PickedGeometry pickedGeometry = new PickedGeometry(); pickedGeometry.From = this; pickedGeometry.GeometryType = GeometryType.Line; pickedGeometry.StageVertexId = stageVertexId; pickedGeometry.Indexes = searcher.Search(arg, x, y, lastIndexId, this); pickedGeometry.Positions = FillPickedGeometrysPosition(pickedGeometry.Indexes); return(pickedGeometry); }
public override PickedGeometry Pick(RenderEventArgs arg, uint stageVertexId, int x, int y) { uint lastVertexId; if (!this.GetLastVertexIdOfPickedGeometry(stageVertexId, out lastVertexId)) { return(null); } // 找到 lastIndexId RecognizedPrimitiveIndex lastIndexId = this.GetLastIndexIdOfPickedGeometry( arg, lastVertexId, x, y); if (lastIndexId == null) { Debug.WriteLine( "Got lastVertexId[{0}] but no lastIndexId! Params are [{1}] [{2}] [{3}] [{4}]", lastVertexId, arg, stageVertexId, x, y); { return(null); } } GeometryType geometryType = arg.PickingGeometryType; DrawMode mode = this.indexBufferPtr.Mode; GeometryType typeOfMode = mode.ToGeometryType(); if (geometryType == GeometryType.Point) { // 获取pickedGeometry if (typeOfMode == GeometryType.Point) { return(PickWhateverItIs(stageVertexId, lastIndexId, typeOfMode)); } else if (typeOfMode == GeometryType.Line) { if (this.OnPrimitiveTest(lastVertexId, mode)) { return(PickPoint(stageVertexId, lastVertexId)); } else { return(null); } } else { OneIndexPointSearcher searcher = GetPointSearcher(mode); if (searcher != null)// line is from triangle, quad or polygon { return(SearchPoint(arg, stageVertexId, x, y, lastVertexId, lastIndexId, searcher)); } else { throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); } } } else if (geometryType == GeometryType.Line) { // 获取pickedGeometry if (geometryType == typeOfMode) { return(PickWhateverItIs(stageVertexId, lastIndexId, typeOfMode)); } else { OneIndexLineSearcher searcher = GetLineSearcher(mode); if (searcher != null)// line is from triangle, quad or polygon { return(SearchLine(arg, stageVertexId, x, y, lastVertexId, lastIndexId, searcher)); } else if (mode == DrawMode.Points)// want a line when rendering GL_POINTS { return(null); } else { throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); } } } else { if (typeOfMode == geometryType)// I want what it is { return(PickWhateverItIs(stageVertexId, lastIndexId, typeOfMode)); } else { return(null); } //{ throw new Exception(string.Format("Lack of searcher for [{0}]", mode)); } } }
internal abstract uint Search(RenderEventArgs arg, int x, int y, RecognizedPrimitiveIndex lastIndexId, OneIndexRenderer modernRenderer);
/// <summary> /// 将共享点前移,构成2个图元组成的新的小小的索引。 /// </summary> /// <param name="recognizedPrimitiveIndex0"></param> /// <param name="recognizedPrimitiveIndex1"></param> /// <param name="drawMode"></param> /// <param name="lastIndex0"></param> /// <param name="lastIndex1"></param> /// <returns></returns> private List <uint> ArrangeIndexes( RecognizedPrimitiveIndex recognizedPrimitiveIndex0, RecognizedPrimitiveIndex recognizedPrimitiveIndex1, DrawMode drawMode, out uint lastIndex0, out uint lastIndex1) { List <uint> sameIndexList = new List <uint>(); List <uint> array0 = new List <uint>(recognizedPrimitiveIndex0.IndexIdList); List <uint> array1 = new List <uint>(recognizedPrimitiveIndex1.IndexIdList); array0.Sort(); array1.Sort(); int p0 = 0, p1 = 0; while (p0 < array0.Count && p1 < array1.Count) { if (array0[p0] < array1[p1]) { p0++; } else if (array0[p0] > array1[p1]) { p1++; } else { sameIndexList.Add(array0[p0]); array0.RemoveAt(p0); array1.RemoveAt(p1); } } if (array0.Count == 0 && array1.Count == 0) { throw new Exception("Two primitives are totally the same!"); } if (array0.Count > 0) { lastIndex0 = array0.Last(); } else { if (sameIndexList.Count == 0) { throw new Exception("array0 is totally empty!"); } lastIndex0 = sameIndexList.Last(); } if (array1.Count > 0) { lastIndex1 = array1.Last(); } else { if (sameIndexList.Count == 0) { throw new Exception("array1 is totally empty!"); } lastIndex1 = sameIndexList.Last(); } if (lastIndex0 == lastIndex1) { throw new Exception(); } List <uint> result = new List <uint>(); result.AddRange(sameIndexList); result.AddRange(array0); result.Add(uint.MaxValue);// primitive restart index result.AddRange(sameIndexList); result.AddRange(array1); return(result); }