[go: nahoru, domu]

Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrawk committed Mar 19, 2022
1 parent fcbc47f commit 6a369a0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion Assets/CGALDotNet/Extensions/IMeshExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace CGALDotNet.Polyhedra
public static class IMeshExtension
{

public static GameObject ToUnityMesh(this IMesh poly, string name, Material material, bool splitFaces = true)
public static GameObject ToUnityMesh<K>(this Polyhedron3<K> poly, string name, Material material, bool splitFaces = true)
where K : CGALKernel, new()
{
if (!poly.IsValid)
{
Expand All @@ -20,8 +21,34 @@ public static GameObject ToUnityMesh(this IMesh poly, string name, Material mate
}

if (!poly.IsTriangle)
{
poly = poly.Copy();
poly.Triangulate();
}

return IMeshToUnityMesh(poly, name, material, splitFaces);
}

public static GameObject ToUnityMesh<K>(this SurfaceMesh3<K> poly, string name, Material material, bool splitFaces = true)
where K : CGALKernel, new()
{
if (!poly.IsValid)
{
Debug.Log("Polyhedron3 is not valid");
return new GameObject(name);
}

if (!poly.IsTriangle)
{
poly = poly.Copy();
poly.Triangulate();
}

return IMeshToUnityMesh(poly, name, material, splitFaces);
}

private static GameObject IMeshToUnityMesh(this IMesh poly, string name, Material material, bool splitFaces = true)
{
int count = poly.VertexCount;
if (count == 0)
{
Expand Down
Binary file modified Assets/CGALDotNet/Plugins/CGALWrapper.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Assets/Examples/Processing/ProcessingExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void Start()

}

private GameObject CreateGameobject(string name, Polyhedron3 poly)
private GameObject CreateGameobject(string name, Polyhedron3<EIK> poly)
{
var go = poly.ToUnityMesh(name, material, false);
return go;
Expand Down

0 comments on commit 6a369a0

Please sign in to comment.