style: apply code-style cleanup (explicit types, this-qualification, switch expressions)
This commit is contained in:
@@ -21,7 +21,12 @@ public sealed class ChunkMesher : IChunkMesher
|
||||
(float, float, float) @base, (float, float, float) u,
|
||||
(float, float, float) v, float shade)
|
||||
{
|
||||
Kind = kind; Normal = normal; Base = @base; U = u; V = v; Shade = shade;
|
||||
this.Kind = kind;
|
||||
this.Normal = normal;
|
||||
this.Base = @base;
|
||||
this.U = u;
|
||||
this.V = v;
|
||||
this.Shade = shade;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +47,7 @@ public sealed class ChunkMesher : IChunkMesher
|
||||
|
||||
public float[] Build(Chunk chunk, BlockRegistry registry)
|
||||
{
|
||||
var verts = new List<float>();
|
||||
List<float> verts = new();
|
||||
|
||||
for (int x = 0; x < Chunk.Size; x++)
|
||||
for (int y = 0; y < Chunk.Size; y++)
|
||||
@@ -51,7 +56,7 @@ public sealed class ChunkMesher : IChunkMesher
|
||||
IBlock block = registry.Get(chunk[x, y, z]);
|
||||
if (!block.IsOpaque) continue;
|
||||
|
||||
foreach (Face face in Faces)
|
||||
foreach (Face face in ChunkMesher.Faces)
|
||||
{
|
||||
int nx = x + face.Normal.x;
|
||||
int ny = y + face.Normal.y;
|
||||
@@ -62,7 +67,7 @@ public sealed class ChunkMesher : IChunkMesher
|
||||
Chunk.InBounds(nx, ny, nz) && registry.Get(chunk[nx, ny, nz]).IsOpaque;
|
||||
if (neighborOpaque) continue;
|
||||
|
||||
AddFace(verts, x, y, z, face, block.GetTextureIndex(face.Kind));
|
||||
ChunkMesher.AddFace(verts, x, y, z, face, block.GetTextureIndex(face.Kind));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,22 +76,21 @@ public sealed class ChunkMesher : IChunkMesher
|
||||
|
||||
private static void AddFace(List<float> verts, int x, int y, int z, Face face, int texIndex)
|
||||
{
|
||||
float tileWidth = 1f / AtlasTiles;
|
||||
float tileWidth = 1f / ChunkMesher.AtlasTiles;
|
||||
float uBase = texIndex * tileWidth;
|
||||
|
||||
foreach (int corner in Triangle)
|
||||
foreach (int corner in ChunkMesher.Triangle)
|
||||
{
|
||||
(float cu, float cv) = Corners[corner];
|
||||
(float cu, float cv) = ChunkMesher.Corners[corner];
|
||||
|
||||
float px = x + face.Base.x + face.U.x * cu + face.V.x * cv;
|
||||
float py = y + face.Base.y + face.U.y * cu + face.V.y * cv;
|
||||
float pz = z + face.Base.z + face.U.z * cu + face.V.z * cv;
|
||||
|
||||
float u = uBase + cu * tileWidth;
|
||||
float v = cv;
|
||||
|
||||
verts.Add(px); verts.Add(py); verts.Add(pz);
|
||||
verts.Add(u); verts.Add(v);
|
||||
verts.Add(u); verts.Add(cv);
|
||||
verts.Add(face.Shade);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user