private static float SelectMaxDepth(StandardBoxBuilding building) { if (!Utils.EachValid(building.right, building.left)) { return(0f); } return(Mathf.Max( building.right.length, building.left.length )); }
private static float SelectMaxLength(StandardBoxBuilding building) { if (!Utils.EachValid(building.front, building.back)) { return(0f); } return(Mathf.Max( building.front.length, building.back.length )); }
private static float SelectMaxHeight(StandardBoxBuilding building) { if (!Utils.EachValid(building.front, building.right, building.back, building.left)) { return(0f); } return(Mathf.Max( building.front.height, building.right.height, building.back.height, building.left.height )); }
private static float CalculateHeightScale(StandardBoxBuilding building, float targetHeight) { if (!Utils.IsValid(building)) { return(1f); } var items = building.sides.GetValidItems(); var array = new float[items.Count]; for (int i = 0; i < array.Length; i++) { array[i] = items[i].CalculateHeightScale(targetHeight); } return(Utils.GetAverage(array)); }
/// ====================================================================== private static BoxGenerationSettings CreateBoxSettings(StandardBoxBuilding builder, BoxDraft draft) { var result = BoxGenerationSettings.Create(); result.length = draft.length; result.depth = draft.depth; var capHeight = Utils.IsValid(builder.cap) ? builder.cap.height : 0f; var wallScaledHeight = draft.height - capHeight; var scale = builder.CalculateHeightScale(wallScaledHeight); var roofScaledHeigh = capHeight * scale; var totalScaledHeight = wallScaledHeight + roofScaledHeigh; if (!Utils.ApproximatelyZero(totalScaledHeight)) { scale = draft.height / totalScaledHeight; } else { scale = 0f; } result.capHeight = capHeight * scale; result.sidesHeight = draft.height - result.capHeight; result.rightScale = builder.front.CalculateLengthScale(result.length); result.forwardScale = builder.right.CalculateLengthScale(result.depth); result.parent = draft.parent; result.pivot = draft.pivot; result.up = draft.up; result.right = draft.right; result.forward = draft.forward; return(result); }