static Bounds GetBounds(PF.Vector3[] points, Vector3 right, Vector3 up, Vector3 forward, Vector3 origin, float minimumHeight)
{
if (points == null || points.Length == 0)
{
return(new Bounds());
}
float miny = points[0].y, maxy = points[0].y;
for (int i = 0; i < points.Length; i++)
{
miny = Mathf.Min(miny, points[i].y);
maxy = Mathf.Max(maxy, points[i].y);
}
var extraHeight = Mathf.Max(minimumHeight - (maxy - miny), 0) * 0.5f;
miny -= extraHeight;
maxy += extraHeight;
Vector3 min = right * points[0].x + up * points[0].y + forward * points[0].z;
Vector3 max = min;
for (int i = 0; i < points.Length; i++)
{
var p = right * points[i].x + forward * points[i].z;
var p1 = p + up * miny;
var p2 = p + up * maxy;
min = Vector3.Min(min, p1);
min = Vector3.Min(min, p2);
max = Vector3.Max(max, p1);
max = Vector3.Max(max, p2);
}
return(new Bounds((min + max) * 0.5F + origin, max - min));
}