From 0d8153c5075733fcb013a4fa42a8882a3a51b715 Mon Sep 17 00:00:00 2001 From: andywiecko Date: Thu, 26 Sep 2024 19:32:25 +0200 Subject: [PATCH] chore: add editor attributes for settings --- Runtime/Triangulator.cs | 102 ++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/Runtime/Triangulator.cs b/Runtime/Triangulator.cs index 216c8c1..0ddb013 100644 --- a/Runtime/Triangulator.cs +++ b/Runtime/Triangulator.cs @@ -144,40 +144,30 @@ public class RefinementThresholds /// Specifies the maximum area constraint for triangles in the resulting mesh refinement. /// Ensures that no triangle in the mesh has an area larger than the specified value. /// - [field: SerializeField] + [field: SerializeField, Min(0)] + [field: Tooltip( + "Specifies the maximum area constraint for triangles in the resulting mesh refinement. " + + "Ensures that no triangle in the mesh has an area larger than the specified value." + )] public float Area { get; set; } = 1f; /// /// Specifies the refinement angle constraint for triangles in the resulting mesh. /// Ensures that no triangle in the mesh has an angle smaller than the specified value. /// /// - /// Expressed in radians. + /// Expressed in radians. Note that in the literature, the upper boundary for convergence is approximately π / 6. /// - [field: SerializeField] + [field: SerializeField, Range(0, math.PI / 4)] + [field: Tooltip( + "Specifies the refinement angle constraint for triangles in the resulting mesh. " + + "Ensures that no triangle in the mesh has an angle smaller than the specified value.\n\n" + + "Expressed in radians. Note that in the literature, the upper boundary for convergence is approximately π / 6.")] public float Angle { get; set; } = math.radians(5); } [Serializable] public class TriangulationSettings { - /// - /// If set to , holes and boundaries will be created automatically - /// depending on the provided . - /// - /// - /// The current implementation detects only 1-level islands. - /// It will not detect holes in solid meshes inside other holes. - /// - [field: SerializeField] - public bool AutoHolesAndBoundary { get; set; } = false; - [field: SerializeField] - public RefinementThresholds RefinementThresholds { get; private set; } = new(); - /// - /// If refines mesh using - /// Ruppert's algorithm. - /// - [field: SerializeField] - public bool RefineMesh { get; set; } = false; /// /// If set to , the provided and /// will be validated before executing the triangulation procedure. The input , @@ -191,7 +181,17 @@ public class TriangulationSettings /// /// Input validation can be expensive. If you are certain of your input, consider disabling this option for additional performance. /// - [field: SerializeField] + [field: Header("General")] + [field: SerializeField, Tooltip( + "If set to true, the provided Input and TriangulationSettings will be validated before executing the triangulation procedure. " + + "The input Positions, ConstraintEdges, and TriangulationSettings have certain restrictions. " + + "For more details, see the manual. If any of the validation conditions are not met, the triangulation will not be performed. " + + "This can be detected as an error by checking the Output.Status value (native, and usable in jobs)." + + "Additionally, if Verbose is set to true, corresponding errors/warnings will be logged in the Console. " + + "Note that some conditions may result in warnings only.\n" + + "\n" + + "Input validation can be expensive. If you are certain of your input, consider disabling this option for additional performance." + )] public bool ValidateInput { get; set; } = true; /// /// If set to , caught errors and warnings with will be logged in the Console. @@ -200,30 +200,72 @@ public class TriangulationSettings /// See also the settings. /// /// - [field: SerializeField] + [field: SerializeField, Tooltip("If set to true, caught errors and warnings with Triangulator will be logged in the Console.")] public bool Verbose { get; set; } = true; /// + /// Preprocessing algorithm for the input data. Default is . + /// + [field: SerializeField, Tooltip("Preprocessing algorithm for the input data.")] + public Preprocessor Preprocessor { get; set; } = Preprocessor.None; + + /// + /// If set to , holes and boundaries will be created automatically + /// depending on the provided . + /// + /// + /// The current implementation detects only 1-level islands. + /// It will not detect holes in solid meshes inside other holes. + /// + [field: Header("Constraints and holes")] + [field: SerializeField] + [field: Tooltip( + "If set to true, holes and boundaries will be created automatically " + + "depending on the provided Input.ConstraintEdges.\n" + + "\n" + + "The current implementation detects only 1-level islands. " + + "It will not detect holes in solid meshes inside other holes." + )] + public bool AutoHolesAndBoundary { get; set; } = false; + /// /// If the mesh boundary is restored using . /// [field: SerializeField] + [field: Tooltip("If true the mesh boundary is restored using Input.ConstraintEdges.")] public bool RestoreBoundary { get; set; } = false; /// /// Max iteration count during Sloan's algorithm (constraining edges). /// Modify this only if you know what you are doing. /// - [field: SerializeField] + [field: SerializeField, Min(0)] + [field: Tooltip( + "Max iteration count during Sloan's algorithm (constraining edges). " + + "Modify this only if you know what you are doing." + )] public int SloanMaxIters { get; set; } = 1_000_000; + /// - /// Constant used in concentric shells segment splitting. - /// Modify this only if you know what you are doing! + /// If refines mesh using + /// Ruppert's algorithm. /// + [field: Header("Refinement")] [field: SerializeField] - public float ConcentricShellsParameter { get; set; } = 0.001f; + [field: Tooltip("If true refines mesh using Ruppert's algorithm.")] + public bool RefineMesh { get; set; } = false; /// - /// Preprocessing algorithm for the input data. Default is . + /// Thresholds used in mesh refinement. See and . /// - [field: SerializeField] - public Preprocessor Preprocessor { get; set; } = Preprocessor.None; + [field: SerializeField, Tooltip("Thresholds used in mesh refinement. See Angle and Area.")] + public RefinementThresholds RefinementThresholds { get; private set; } = new(); + /// + /// Constant used in concentric shells segment splitting. + /// Modify this only if you know what you are doing! + /// + [field: SerializeField, Min(0)] + [field: Tooltip( + "Constant used in concentric shells segment splitting. " + + "Modify this only if you know what you are doing!" + )] + public float ConcentricShellsParameter { get; set; } = 0.001f; } public class InputData where T2 : unmanaged