style: drop redundant type qualifiers, use explicit types (IDE cleanup)
Pure formatting from the IDE's code cleanup: remove redundant ClassName./namespace qualifiers and replace var with explicit types. No behavior change.
This commit is contained in:
@@ -20,7 +20,7 @@ Log.Logger = new LoggerConfiguration()
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cfg = new Configuration();
|
Configuration cfg = new();
|
||||||
|
|
||||||
NativeWindowSettings nativeSettings = new()
|
NativeWindowSettings nativeSettings = new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using OpenTK.Graphics.OpenGL4;
|
|||||||
|
|
||||||
namespace VoxelEngine.Rendering;
|
namespace VoxelEngine.Rendering;
|
||||||
|
|
||||||
public sealed class ChunkRenderer : VoxelEngine.World.Streaming.IChunkRenderer
|
public sealed class ChunkRenderer : World.Streaming.IChunkRenderer
|
||||||
{
|
{
|
||||||
private const int FloatsPerVertex = 6; // pos.xyz, uv, shade
|
private const int FloatsPerVertex = 6; // pos.xyz, uv, shade
|
||||||
|
|
||||||
@@ -12,8 +12,8 @@ public sealed class ChunkRenderer : VoxelEngine.World.Streaming.IChunkRenderer
|
|||||||
|
|
||||||
public ChunkRenderer(float[] vertices)
|
public ChunkRenderer(float[] vertices)
|
||||||
{
|
{
|
||||||
this._vertexCount = vertices.Length / ChunkRenderer.FloatsPerVertex;
|
this._vertexCount = vertices.Length / FloatsPerVertex;
|
||||||
int stride = ChunkRenderer.FloatsPerVertex * sizeof(float);
|
int stride = FloatsPerVertex * sizeof(float);
|
||||||
|
|
||||||
this._vao = GL.GenVertexArray();
|
this._vao = GL.GenVertexArray();
|
||||||
GL.BindVertexArray(this._vao);
|
GL.BindVertexArray(this._vao);
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ public sealed class Chunk
|
|||||||
{
|
{
|
||||||
public const int Size = 16;
|
public const int Size = 16;
|
||||||
|
|
||||||
private readonly ushort[] _ids = new ushort[Chunk.Size * Chunk.Size * Chunk.Size];
|
private readonly ushort[] _ids = new ushort[Size * Size * Size];
|
||||||
|
|
||||||
public ushort this[int x, int y, int z]
|
public ushort this[int x, int y, int z]
|
||||||
{
|
{
|
||||||
get => this._ids[Chunk.Index(x, y, z)];
|
get => this._ids[Index(x, y, z)];
|
||||||
set => this._ids[Chunk.Index(x, y, z)] = value;
|
set => this._ids[Index(x, y, z)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool InBounds(int x, int y, int z) =>
|
public static bool InBounds(int x, int y, int z) =>
|
||||||
x is >= 0 and < Chunk.Size && y is >= 0 and < Chunk.Size && z is >= 0 and < Chunk.Size;
|
x is >= 0 and < Size && y is >= 0 and < Size && z is >= 0 and < Size;
|
||||||
|
|
||||||
private static int Index(int x, int y, int z) => (x * Chunk.Size + y) * Chunk.Size + z;
|
private static int Index(int x, int y, int z) => (x * Size + y) * Size + z;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ public sealed class ChunkMesher : IChunkMesher
|
|||||||
|
|
||||||
public ChunkMesher(int atlasWidthPixels, int atlasHeightPixels)
|
public ChunkMesher(int atlasWidthPixels, int atlasHeightPixels)
|
||||||
{
|
{
|
||||||
this._tileU = (float)ChunkMesher.TileSizePixels / atlasWidthPixels;
|
this._tileU = (float)TileSizePixels / atlasWidthPixels;
|
||||||
this._tileV = (float)ChunkMesher.TileSizePixels / atlasHeightPixels;
|
this._tileV = (float)TileSizePixels / atlasHeightPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-face geometry: base corner + two in-plane edge vectors (u, v) with
|
// Per-face geometry: base corner + two in-plane edge vectors (u, v) with
|
||||||
@@ -65,7 +65,7 @@ public sealed class ChunkMesher : IChunkMesher
|
|||||||
IBlock block = registry.Get(chunk[x, y, z]);
|
IBlock block = registry.Get(chunk[x, y, z]);
|
||||||
if (!block.IsOpaque) continue;
|
if (!block.IsOpaque) continue;
|
||||||
|
|
||||||
foreach (Face face in ChunkMesher.Faces)
|
foreach (Face face in Faces)
|
||||||
{
|
{
|
||||||
int nx = x + face.Normal.x;
|
int nx = x + face.Normal.x;
|
||||||
int ny = y + face.Normal.y;
|
int ny = y + face.Normal.y;
|
||||||
@@ -91,9 +91,9 @@ public sealed class ChunkMesher : IChunkMesher
|
|||||||
// Image is flipped on load, so offset from the top to keep tile (0,0) = top-left.
|
// Image is flipped on load, so offset from the top to keep tile (0,0) = top-left.
|
||||||
float vBase = 1f - (tile.Y + 1) * this._tileV;
|
float vBase = 1f - (tile.Y + 1) * this._tileV;
|
||||||
|
|
||||||
foreach (int corner in ChunkMesher.Triangle)
|
foreach (int corner in Triangle)
|
||||||
{
|
{
|
||||||
(float cu, float cv) = ChunkMesher.Corners[corner];
|
(float cu, float cv) = Corners[corner];
|
||||||
|
|
||||||
float px = x + face.Base.x + face.U.x * cu + face.V.x * cv;
|
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 py = y + face.Base.y + face.U.y * cu + face.V.y * cv;
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ public sealed class CaveCarver
|
|||||||
int chunkBaseY = chunkPos.Y * VoxelChunk.Size;
|
int chunkBaseY = chunkPos.Y * VoxelChunk.Size;
|
||||||
int chunkBaseZ = chunkPos.Z * VoxelChunk.Size;
|
int chunkBaseZ = chunkPos.Z * VoxelChunk.Size;
|
||||||
|
|
||||||
int chunkCellX = CaveCarver.FloorDiv(chunkBaseX, cellSize);
|
int chunkCellX = FloorDiv(chunkBaseX, cellSize);
|
||||||
int chunkCellY = CaveCarver.FloorDiv(chunkBaseY, cellSize);
|
int chunkCellY = FloorDiv(chunkBaseY, cellSize);
|
||||||
int chunkCellZ = CaveCarver.FloorDiv(chunkBaseZ, cellSize);
|
int chunkCellZ = FloorDiv(chunkBaseZ, cellSize);
|
||||||
|
|
||||||
for (int cdx = -radius; cdx <= radius; cdx++)
|
for (int cdx = -radius; cdx <= radius; cdx++)
|
||||||
for (int cdy = -radius; cdy <= radius; cdy++)
|
for (int cdy = -radius; cdy <= radius; cdy++)
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ namespace VoxelEngine.World.WorldGen;
|
|||||||
public static class WorldConstants
|
public static class WorldConstants
|
||||||
{
|
{
|
||||||
public const int WorldHeightChunks = 32;
|
public const int WorldHeightChunks = 32;
|
||||||
public const int WorldHeight = WorldConstants.WorldHeightChunks * VoxelChunk.Size; // 512
|
public const int WorldHeight = WorldHeightChunks * VoxelChunk.Size; // 512
|
||||||
public const int SeaLevel = 256;
|
public const int SeaLevel = 256;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user