diff --git a/Documentation~/images/utilities-triangle-coloring.svg b/Documentation~/images/utilities-triangle-coloring.svg new file mode 100644 index 0000000..4ca24f9 --- /dev/null +++ b/Documentation~/images/utilities-triangle-coloring.svg @@ -0,0 +1,798 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Documentation~/manual/utilities.md b/Documentation~/manual/utilities.md index 06fd3d0..581cca0 100644 --- a/Documentation~/manual/utilities.md +++ b/Documentation~/manual/utilities.md @@ -19,6 +19,27 @@ var halfedges = new int[triangles.Length]; Utilities.GenerateHalfedges(halfdeges, triangles, Allocator.Persistent); ``` +## GenerateTriangleColors + +The method [GenerateTriangleColors][generate-triangle-colors] can be used to generate triangle colors using the provided halfedges. +Triangles that share a common edge are assigned the same color index. +The resulting colors contains values in the range $[0, \,\mathtt{colorsCount})$. +Below is an illustration of an example coloring result, where colors represent actual visual colors rather than ids. +Please note that coloring is based on shared edges, i.e. triangles that share only a single vertex may not receive the same color. + +
+

+
+ +Example usage: + +```csharp +var halfedges = new int[] {...}; +var colors = new int[halfedges.Length / 3]; + +Utilities.GenerateTriangleColors(colors, halfedges, out var colorsCount, Allocator.Persistent); +``` + ## InsertSubMesh The [InsertSubMesh][insert-submesh] utility can be used to combine meshes by inserting a sub-mesh into the *main* mesh. @@ -69,5 +90,6 @@ for (int he = 0; he < halfedges.Length; he++) [Utilities]: xref:andywiecko.BurstTriangulator.Utilities [Extensions]: xref:andywiecko.BurstTriangulator.Extensions [generate-halfedges]: xref:andywiecko.BurstTriangulator.Utilities.GenerateHalfedges* +[generate-triangle-colors]: xref:andywiecko.BurstTriangulator.Utilities.GenerateTriangleColors* [insert-submesh]: xref:andywiecko.BurstTriangulator.Utilities.InsertSubMesh* [next-halfedge]: xref:andywiecko.BurstTriangulator.Utilities.NextHalfedge* diff --git a/Documentation~/unity-xrefmap.yml b/Documentation~/unity-xrefmap.yml index f5d6c63..9c4c535 100644 --- a/Documentation~/unity-xrefmap.yml +++ b/Documentation~/unity-xrefmap.yml @@ -58,4 +58,8 @@ references: - uid: UnityEngine.MonoBehaviour name: MonoBehaviour - href: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html \ No newline at end of file + href: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html + +- uid: UnityEngine.Mesh + name: Mesh + href: https://docs.unity3d.com/ScriptReference/Mesh.html \ No newline at end of file