[OvldGenCallTarget] public static void Rectangle([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode, [OvldDefault("false")] bool hollow, [OvldDefault("Vector3.zero")] Vector3 pos, [OvldDefault("Quaternion.identity")] Quaternion rot, Rect rect, [OvldDefault(nameof(Color))] Color color, [OvldDefault("0f")] float thickness = 0f, [OvldDefault("default")] Vector4 cornerRadii = default) { bool rounded = ShapesMath.MaxComp(cornerRadii) >= 0.0001f; if (hollow && thickness * 2 >= Mathf.Min(rect.width, rect.height)) { hollow = false; } Material mat = ShapesMaterialUtils.GetRectMaterial(hollow, rounded)[blendMode]; mat.SetColor(ShapesMaterialUtils.propColor, color); mat.SetVector(ShapesMaterialUtils.propRect, rect.ToVector4()); if (rounded) { mat.SetVector(ShapesMaterialUtils.propCornerRadii, cornerRadii); } if (hollow) { mat.SetFloat(ShapesMaterialUtils.propThickness, thickness); mat.SetInt(ShapesMaterialUtils.propScaleMode, (int)ScaleMode); } DrawMesh(pos, rot, ShapesMeshUtils.QuadMesh, mat); }
[OvldGenCallTarget] static void Rectangle_Internal([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode, [OvldDefault("false")] bool hollow, Rect rect, [OvldDefault(nameof(Color))] Color color, [OvldDefault(nameof(Thickness))] float thickness, [OvldDefault("default")] Vector4 cornerRadii) { bool rounded = ShapesMath.MaxComp(cornerRadii) >= 0.0001f; // positive vibes only if (rect.width < 0) { rect.x -= rect.width *= -1; } if (rect.height < 0) { rect.y -= rect.height *= -1; } using (new IMDrawer(mpbRect, ShapesMaterialUtils.GetRectMaterial(hollow, rounded)[blendMode], ShapesMeshUtils.QuadMesh[0])) { MetaMpb.ApplyColorOrFill(mpbRect, color); MetaMpb.ApplyDashSettings(mpbRect, thickness); mpbRect.rect.Add(rect.ToVector4()); mpbRect.cornerRadii.Add(cornerRadii); mpbRect.thickness.Add(thickness); mpbRect.thicknessSpace.Add((int)Draw.ThicknessSpace); mpbRect.scaleMode.Add((int)ScaleMode); } }
[OvldGenCallTarget] static void Rectangle([OvldDefault(nameof(BlendMode))] ShapesBlendMode blendMode, [OvldDefault("false")] bool hollow, [OvldDefault("Vector3.zero")] Vector3 pos, [OvldDefault("Quaternion.identity")] Quaternion rot, Rect rect, [OvldDefault(nameof(Color))] Color color, [OvldDefault("0f")] float thickness = 0f, [OvldDefault("default")] Vector4 cornerRadii = default) { bool rounded = ShapesMath.MaxComp(cornerRadii) >= 0.0001f; // positive vibes only if (rect.width < 0) { rect.x -= rect.width *= -1; } if (rect.height < 0) { rect.y -= rect.height *= -1; } if (hollow && thickness * 2 >= Mathf.Min(rect.width, rect.height)) { hollow = false; } using (new IMDrawer(mpbRectangle, ShapesMaterialUtils.GetRectMaterial(hollow, rounded)[blendMode], ShapesMeshUtils.QuadMesh[0], pos, rot)) { mpbRectangle.color.Add(color); mpbRectangle.rect.Add(rect.ToVector4()); mpbRectangle.cornerRadii.Add(cornerRadii); mpbRectangle.thickness.Add(thickness); mpbRectangle.scaleMode.Add((int)ScaleMode); } }