private SelVertex[] PickVertices(int x, int y, int w = 0, int h = 0) { List<SelVertex> result = new List<SelVertex>(); if (this.allObjSel == null) return result.ToArray(); IEnumerable<SelPolyShape> shapes = this.allObjSel.OfType<SelPolyShape>(); foreach (SelPolyShape shape in shapes) { PolyShapeInfo polygon = shape.ActualObject as PolyShapeInfo; if (polygon == null) continue; Transform transform = polygon.Parent.GameObj.Transform; if (polygon.Parent == null || polygon.Parent.GameObj == null || polygon.Parent.GameObj.Transform == null) continue; Vector3 worldCoord = this.GetSpaceCoord(new Vector3(x, y, transform.Pos.Z)); float scale = GetScaleAtZ(transform.Pos.Z); Rect selectionRect = new Rect(worldCoord.X, worldCoord.Y, w/scale, h/scale); float size = VertexSize/scale; for (int i = 0; i < polygon.Vertices.Length; i++) { Vector2 vertexPosition = transform.GetWorldPoint(polygon.Vertices[i]); Rect vertexRect = new Rect(vertexPosition.X - size/2, vertexPosition.Y - size/2, size, size); if (selectionRect.Intersects(vertexRect)) { result.Add(new SelVertex(polygon, i)); } } } return result.ToArray(); }