private static List <ColumnItem> CalculateItems(StandardColumn column, float height) { var totalMinHeight = GetTotalMinHeight(column); if (height < totalMinHeight) { var bottomItems = column.bottom.GetRequiredItems(); var middleItems = column.middle.GetRequiredItems(); var topItems = column.top.GetRequiredItems(); return(Utils.Combine(bottomItems, middleItems, topItems)); } else { var bottomItems = column.bottom.GetValidItems(); var topItems = column.top.GetValidItems(); var edgesHeight = 0f; edgesHeight += Utils.CalculateHeightSum(bottomItems); edgesHeight += Utils.CalculateHeightSum(topItems); var middleHeight = height - edgesHeight; var items = column.middle.GetValidItems(); var count = Utils.CalculateItemsCountByHeight(items, middleHeight); var middleItems = Utils.FillRepeated(items, count); return(Utils.Combine(bottomItems, middleItems, topItems)); } }
private static float CalculateLengthScale(StandardColumn column, float length) { if (Utils.ApproximatelyZero(length, column.length)) { return(1f); } return(length / column.length); }
private static float SelectMaxDepth(StandardColumn column) { var items = column.bottom.GetValidItems(); var bottomMax = Utils.SelectMaxDepth(items); items = column.middle.GetValidItems(); var middleMax = Utils.SelectMaxDepth(items); items = column.top.GetValidItems(); var topMax = Utils.SelectMaxDepth(items); return(Mathf.Max(bottomMax, middleMax, topMax)); }
private static float GetTotalMinHeight(StandardColumn column) { var result = 0f; var items = column.bottom.GetRequiredItems(); result += Utils.CalculateHeightSum(items); items = column.middle.GetRequiredItems(); result += Utils.CalculateHeightSum(items); items = column.top.GetRequiredItems(); result += Utils.CalculateHeightSum(items); return(result); }
private static float CalculateHeightScale(StandardColumn column, float height) { if (Utils.ApproximatelyZero(height, column.height)) { return(1f); } var items = CalculateItems(column, height); var totalHeight = Utils.CalculateHeightSum(items); if (Utils.ApproximatelyZero(totalHeight)) { return(1f); } return(height / totalHeight); }