public void Pick(Ray ray) { if (!IsActive) { return; } PropertyGrid.SelectedObject = null; var depthPicked = ray.GetPlaneIntersection(-Vector3.UnitZ, new Vector3(0, 0, -PlatformWidth / 2)); Picked = ray.GetPlaneIntersection(-Vector3.UnitZ, Vector3.Zero); Vector2 nearestLine; float closest = float.MaxValue; LVDCollisionMaterial collisionMat = null; foreach (var point in LVD.GeneralPoints) { if (CrossMath.FastDistance(Picked, new Vector3(point.X, point.Y, point.Z), PickRange * 2.5f)) { PropertyGrid.SelectedObject = point; return; } } foreach (var bound in LVD.CameraBounds) { if (Ray.CheckBoundHit(Picked.Xy, new Vector2(bound.Left, bound.Top), new Vector2(bound.Right, bound.Bottom), PickRange)) { PropertyGrid.SelectedObject = bound; return; } } foreach (var bound in LVD.BlastZoneBounds) { if (Ray.CheckBoundHit(Picked.Xy, new Vector2(bound.Left, bound.Top), new Vector2(bound.Right, bound.Bottom), PickRange)) { PropertyGrid.SelectedObject = bound; return; } } foreach (var bound in LVD.ShrunkBlastZoneBounds) { if (Ray.CheckBoundHit(Picked.Xy, new Vector2(bound.Left, bound.Top), new Vector2(bound.Right, bound.Bottom), PickRange)) { PropertyGrid.SelectedObject = bound; return; } } foreach (var bound in LVD.ShrunkCameraBounds) { if (Ray.CheckBoundHit(Picked.Xy, new Vector2(bound.Left, bound.Top), new Vector2(bound.Right, bound.Bottom), PickRange)) { PropertyGrid.SelectedObject = bound; return; } } foreach (var spawn in LVD.Spawns) { if (CrossMath.FastDistance(Picked, new Vector3(spawn.X, spawn.Y, 0), PickRange * 2.5f)) { PropertyGrid.SelectedObject = spawn; return; } } foreach (var spawn in LVD.Respawns) { if (CrossMath.FastDistance(Picked, new Vector3(spawn.X, spawn.Y, 0), PickRange * 2.5f)) { PropertyGrid.SelectedObject = spawn; return; } } foreach (var col in LVD.Collisions) { for (int i = 0; i < col.Vertices.Count; i++) { var vert = col.Vertices[i]; if (i < col.Materials.Count) { var vert2 = col.Vertices[i + 1]; var dis = Ray.GetDistanceToSegment(depthPicked.Xy, new Vector2(vert.X, vert.Y), new Vector2(vert2.X, vert2.Y), out nearestLine); if (dis < PlatformWidth / 4 & dis < closest) { closest = dis; collisionMat = col.Materials[i]; } } if (CrossMath.FastDistance(Picked, new Vector3(vert.X, vert.Y, 0), PickRange)) { PropertyGrid.SelectedObject = vert; return; } } } if (PropertyGrid.SelectedObject == null && collisionMat != null) { PropertyGrid.SelectedObject = collisionMat; } }