private SplitPlane CalculateBestSplitPlane(List <Boundable> boundables) { var bestSplitPlane = new SplitPlane(float.MaxValue, null, null); for (int i = 1; i < boundables.Count; i++) { var left = boundables.Take(i).ToList(); var leftB = BoundingBox.FromBoundables(left); var right = boundables.Skip(i).ToList(); var rightB = BoundingBox.FromBoundables(right); var cost = leftB.Area * left.Count + rightB.Area * right.Count; if (cost < bestSplitPlane.Cost) { bestSplitPlane = new SplitPlane(cost, left, right); } } return(bestSplitPlane); }
private SplitPlane CalculateBestSplitPlane(List<Boundable> boundables) { var bestSplitPlane = new SplitPlane(float.MaxValue, null, null); for (int i = 1; i < boundables.Count; i++) { var left = boundables.Take(i).ToList(); var leftB = BoundingBox.FromBoundables(left); var right = boundables.Skip(i).ToList(); var rightB = BoundingBox.FromBoundables(right); var cost = leftB.Area * left.Count + rightB.Area * right.Count; if (cost < bestSplitPlane.Cost) { bestSplitPlane = new SplitPlane(cost, left, right); } } return bestSplitPlane; }