Skip to content

Commit

Permalink
large mesh handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed Jun 30, 2018
1 parent f7f15ba commit b1bd5e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions platform/fMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public fMesh(int[] triangles, DMesh3 source, int[] source_vertices, bool bCopyNo

Mesh m = new Mesh();
m.vertices = vertices;

if (NV > 65000 || triangles.Length/3 > 65000)
m.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
m.triangles = triangles;

if (bCopyNormals && source.HasVertexNormals) {
Expand Down
5 changes: 3 additions & 2 deletions util/UnityUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public static UnityEngine.Mesh SimpleMeshToUnityMesh(SimpleMesh m, bool bSwapLef



public static fMesh DMeshToUnityMesh(DMesh3 m, bool bSwapLeftRight, bool bAllowLargeMeshes = false)
public static fMesh DMeshToUnityMesh(DMesh3 m, bool bSwapLeftRight, bool bAllowLargeMeshes = false, bool bRecalcNormalsIfMissing = true)
{
if (bSwapLeftRight)
throw new Exception("[RMSNOTE] I think this conversion is wrong, see MeshTransforms.SwapLeftRight. Just want to know if this code is ever hit.");
Expand Down Expand Up @@ -514,8 +514,9 @@ public static fMesh DMeshToUnityMesh(DMesh3 m, bool bSwapLeftRight, bool bAllowL
unityMesh.triangles = triangles;
}

if (m.HasVertexNormals == false)
if (m.HasVertexNormals == false && bRecalcNormalsIfMissing) {
unityMesh.RecalculateNormals();
}

return new fMesh(unityMesh);
}
Expand Down

0 comments on commit b1bd5e4

Please sign in to comment.