convert submodules to normal folders for now

This commit is contained in:
catangent 2025-04-09 20:00:20 +01:00
parent 389e934900
commit ed1e0ecb6b
1041 changed files with 572002 additions and 13 deletions

View file

@ -5,8 +5,8 @@ const v3 = raylib_helper.v3;
const A7r = std.mem.Allocator;
const comptimePrint = std.fmt.comptimePrint;
const COORDINATE_FIELD_BYTES = 5; // 5 for 32x32x32 chunk size.
const CHUNK_SIZE = 1 >> COORDINATE_FIELD_BYTES; // 32
const VERTICES_BLOCK_SIZE = 2 * 3 * 3;
const TEXCOORDS_BLOCK_SIZE = 2 * 2 * 3;
const RawQuad = struct {
tile: u32,
@ -212,6 +212,7 @@ pub const Chunk = struct {
}
}
// Create OpenGL buffers
const triangle_count: i32 = @as(i32, @intCast(raw_quads.items.len)) * 2;
const arr_size: u32 = @as(u32, @intCast(triangle_count)) * 3 * @sizeOf(f32);
@ -223,21 +224,21 @@ pub const Chunk = struct {
const metadata1_packed: [*]f32 = @ptrCast(@alignCast(raylib.MemAlloc(arr_size * 4)));
for (raw_quads.items, 0..) |raw_quad, i| {
if (raw_quad.tile <= 0) continue;
if (raw_quad.tile <= 0) continue; // air tile, no texture
const tile = raw_quad.tile;
// Set normals for the quads (same as the triangles.)
for (0..6) |j| {
normals[18 * i + 3 * j + 0] = raw_quad.normal.x;
normals[18 * i + 3 * j + 1] = raw_quad.normal.y;
normals[18 * i + 3 * j + 2] = raw_quad.normal.z;
}
// Find UV coordinates of corresponding tiles.
const left_uv = @as(f32, @floatFromInt(tile % tile_columns)) / @as(f32, @floatFromInt(tile_columns));
const right_uv = @as(f32, @floatFromInt(tile % tile_columns + 1)) / @as(f32, @floatFromInt(tile_columns));
const top_uv = @as(f32, @floatFromInt(tile / tile_columns)) / @as(f32, @floatFromInt(tile_rows));
const bottom_uv = @as(f32, @floatFromInt(tile / tile_columns + 1)) / @as(f32, @floatFromInt(tile_rows));
const VERTICES_BLOCK_SIZE = 2 * 3 * 3;
const TEXCOORDS_BLOCK_SIZE = 2 * 2 * 3;
// Unwrap raw quads vertex coordinates and UV coordinates into OpenGL buffers.
const vertex_corners = .{ raw_quad.top_left, raw_quad.bottom_left, raw_quad.top_right, raw_quad.bottom_right, raw_quad.top_right, raw_quad.bottom_left };