feat(gui): add toolbar widget

feat(gui): add grid_select, toggle, panel, status_bar, image widgets
fix(bsp): fill in exterior cells
This commit is contained in:
asrael 2026-02-27 06:50:49 -06:00
parent 5a565844dd
commit 8d491612ab
63 changed files with 3150 additions and 1686 deletions

View file

@ -179,13 +179,8 @@ static pxl8_bsp* assembly_to_bsp(pxl8_world_chunk_assembly* a) {
pxl8_stream s = pxl8_stream_create(a->data, (u32)a->data_size);
pxl8_bsp_wire_header wire_hdr;
pxl8_protocol_deserialize_bsp_wire_header(a->data, 44, &wire_hdr);
s.offset = 44;
pxl8_debug("[CLIENT] Wire header: verts=%u edges=%u faces=%u planes=%u nodes=%u leafs=%u surfedges=%u visdata=%u",
wire_hdr.num_vertices, wire_hdr.num_edges, wire_hdr.num_faces,
wire_hdr.num_planes, wire_hdr.num_nodes, wire_hdr.num_leafs,
wire_hdr.num_surfedges, wire_hdr.visdata_size);
pxl8_protocol_deserialize_bsp_wire_header(a->data, 48, &wire_hdr);
s.offset = 48;
if (wire_hdr.num_vertices > 0) {
bsp->vertices = pxl8_calloc(wire_hdr.num_vertices, sizeof(pxl8_bsp_vertex));
@ -273,21 +268,42 @@ static pxl8_bsp* assembly_to_bsp(pxl8_world_chunk_assembly* a) {
}
}
pxl8_debug("Deserialized BSP: %u verts, %u faces, %u nodes, %u leafs",
bsp->num_vertices, bsp->num_faces, bsp->num_nodes, bsp->num_leafs);
if (wire_hdr.num_heightfield > 0) {
bsp->heightfield = pxl8_calloc(wire_hdr.num_heightfield, sizeof(f32));
bsp->num_heightfield = wire_hdr.num_heightfield;
for (u32 i = 0; i < wire_hdr.num_heightfield; i++) {
u32 raw = pxl8_read_u32_be(&s);
memcpy(&bsp->heightfield[i], &raw, sizeof(f32));
}
bsp->heightfield_w = pxl8_read_u16_be(&s);
bsp->heightfield_h = pxl8_read_u16_be(&s);
u32 ox_raw = pxl8_read_u32_be(&s);
memcpy(&bsp->heightfield_ox, &ox_raw, sizeof(f32));
u32 oz_raw = pxl8_read_u32_be(&s);
memcpy(&bsp->heightfield_oz, &oz_raw, sizeof(f32));
u32 cs_raw = pxl8_read_u32_be(&s);
memcpy(&bsp->heightfield_cell_size, &cs_raw, sizeof(f32));
}
u32 raw;
raw = pxl8_read_u32_be(&s);
memcpy(&bsp->bounds_min_x, &raw, sizeof(f32));
raw = pxl8_read_u32_be(&s);
memcpy(&bsp->bounds_min_z, &raw, sizeof(f32));
raw = pxl8_read_u32_be(&s);
memcpy(&bsp->bounds_max_x, &raw, sizeof(f32));
raw = pxl8_read_u32_be(&s);
memcpy(&bsp->bounds_max_z, &raw, sizeof(f32));
return bsp;
}
static pxl8_result assemble_bsp(pxl8_world_chunk_cache* cache, pxl8_world_chunk_assembly* a) {
pxl8_debug("[CLIENT] assemble_bsp: id=%u data_size=%zu", a->id, a->data_size);
pxl8_bsp* bsp = assembly_to_bsp(a);
if (!bsp) {
pxl8_debug("[CLIENT] assemble_bsp: assembly_to_bsp returned NULL!");
assembly_reset(a);
return PXL8_ERROR_INVALID_ARGUMENT;
}
pxl8_debug("[CLIENT] assemble_bsp: BSP created with %u verts %u faces", bsp->num_vertices, bsp->num_faces);
pxl8_world_chunk_cache_entry* entry = find_entry_bsp(cache, a->id);
if (entry) {