internal override uint[] Search(RenderEventArgs arg,
                                        int x, int y,
                                        uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            OneIndexBufferPtr indexBufferPtr = null;

            using (var buffer = new OneIndexBuffer(IndexElementType.UInt, DrawMode.Lines, BufferUsage.StaticDraw))
            {
                buffer.Create(8);
                unsafe
                {
                    var array = (uint *)buffer.Header.ToPointer();
                    array[0] = lastVertexId - 1; array[1] = lastVertexId - 0;
                    array[2] = lastVertexId - 2; array[3] = lastVertexId - 1;
                    array[4] = lastVertexId - 3; array[5] = lastVertexId - 2;
                    array[6] = lastVertexId - 0; array[7] = lastVertexId - 3;
                }

                indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr;
            }

            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, arg.CanvasRect.Height - y - 1);

            indexBufferPtr.Dispose();

            if (id + 3 == lastVertexId)
            {
                return(new uint[] { id + 3, id, });
            }
            else
            {
                return(new uint[] { id - 1, id, });
            }
        }
Пример #2
0
        internal override uint[] Search(RenderEventArgs arg,
                                        int x, int y,
                                        uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBufferPtr zeroIndexBufferPtr = modernRenderer.IndexBufferPtr;
            ZeroIndexBufferPtr indexBufferPtr     = null;

            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            using (var buffer = new ZeroIndexBuffer(DrawMode.LineLoop,
                                                    zeroIndexBufferPtr.FirstVertex, zeroIndexBufferPtr.VertexCount))
            {
                indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
            }
            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, arg.CanvasRect.Height - y - 1);

            indexBufferPtr.Dispose();

            if (id == zeroIndexBufferPtr.FirstVertex)
            {
                return(new uint[] { (uint)(zeroIndexBufferPtr.FirstVertex + zeroIndexBufferPtr.VertexCount - 1), id, });
            }
            else
            {
                return(new uint[] { id - 1, id, });
            }
        }