Skip to content

Commit

Permalink
Removed unnecessary ref from ToMesh and ToMeshDraft, fixes Syomus#62
Browse files Browse the repository at this point in the history
  • Loading branch information
BasmanovDaniil committed Jan 7, 2021
1 parent e119921 commit ec1b817
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Runtime/CompoundMeshDraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public MeshDraft ToMeshDraft()
public Mesh ToMeshWithSubMeshes(bool calculateBounds = true, bool autoIndexFormat = true)
{
var mesh = new Mesh();
FillMesh(ref mesh, calculateBounds, autoIndexFormat);
FillMesh(mesh, calculateBounds, autoIndexFormat);
return mesh;
}

Expand All @@ -252,17 +252,17 @@ public Mesh ToMeshWithSubMeshes(bool calculateBounds = true, bool autoIndexForma
/// <param name="mesh"> Resulting mesh. Cleared before use. </param>
/// <param name="calculateBounds"> Calculate the bounding box of the Mesh after setting the triangles. </param>
/// <param name="autoIndexFormat"> Use 16 bit or 32 bit index buffers based on vertex count. </param>
public void ToMeshWithSubMeshes(ref Mesh mesh, bool calculateBounds = true, bool autoIndexFormat = true)
public void ToMeshWithSubMeshes(Mesh mesh, bool calculateBounds = true, bool autoIndexFormat = true)
{
if (mesh == null)
{
throw new ArgumentNullException(nameof(mesh));
}
mesh.Clear(false);
FillMesh(ref mesh, calculateBounds, autoIndexFormat);
FillMesh(mesh, calculateBounds, autoIndexFormat);
}

private void FillMesh(ref Mesh mesh, bool calculateBounds, bool autoIndexFormat)
private void FillMesh(Mesh mesh, bool calculateBounds, bool autoIndexFormat)
{
int vCount = vertexCount;
if (vCount > 65535)
Expand Down
8 changes: 4 additions & 4 deletions Runtime/MeshDraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ public MeshDraft Spherify(float radius, Vector3 center = default)
public Mesh ToMesh(bool calculateBounds = true, bool autoIndexFormat = true)
{
var mesh = new Mesh();
FillMesh(ref mesh, calculateBounds, autoIndexFormat);
FillMesh(mesh, calculateBounds, autoIndexFormat);
return mesh;
}

Expand All @@ -865,17 +865,17 @@ public Mesh ToMesh(bool calculateBounds = true, bool autoIndexFormat = true)
/// <param name="mesh"> Resulting mesh. Cleared before use. </param>
/// <param name="calculateBounds"> Calculate the bounding box of the Mesh after setting the triangles. </param>
/// <param name="autoIndexFormat"> Use 16 bit or 32 bit index buffers based on vertex count. </param>
public void ToMesh(ref Mesh mesh, bool calculateBounds = true, bool autoIndexFormat = true)
public void ToMesh(Mesh mesh, bool calculateBounds = true, bool autoIndexFormat = true)
{
if (mesh == null)
{
throw new ArgumentNullException(nameof(mesh));
}
mesh.Clear(false);
FillMesh(ref mesh, calculateBounds, autoIndexFormat);
FillMesh(mesh, calculateBounds, autoIndexFormat);
}

private void FillMesh(ref Mesh mesh, bool calculateBounds, bool autoIndexFormat)
private void FillMesh(Mesh mesh, bool calculateBounds, bool autoIndexFormat)
{
if (vertexCount > 65535)
{
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Tessellator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public MeshDraft ToMeshDraft()
/// <summary>
/// Converts the tessellated mesh to MeshDraft.
/// </summary>
public void ToMeshDraft(ref MeshDraft draft)
public void ToMeshDraft(MeshDraft draft)
{
draft.vertices.Clear();
draft.triangles.Clear();
Expand All @@ -149,9 +149,9 @@ public Mesh ToMesh()
/// <summary>
/// Converts the tessellated mesh to Mesh.
/// </summary>
public void ToMesh(ref Mesh mesh)
public void ToMesh(Mesh mesh)
{
ToMeshDraft().ToMesh(ref mesh);
ToMeshDraft().ToMesh(mesh);
}
}
}
4 changes: 2 additions & 2 deletions Samples/Common/ConfiguratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void AssignDraftToMeshFilter(MeshDraft draft, MeshFilter meshFilte
}
else
{
draft.ToMesh(ref mesh);
draft.ToMesh(mesh);
}
meshFilter.sharedMesh = mesh;
}
Expand All @@ -68,7 +68,7 @@ public static void AssignDraftToMeshFilter(CompoundMeshDraft compoundDraft, Mesh
}
else
{
compoundDraft.ToMeshWithSubMeshes(ref mesh);
compoundDraft.ToMeshWithSubMeshes(mesh);
}
meshFilter.sharedMesh = mesh;
}
Expand Down

0 comments on commit ec1b817

Please sign in to comment.