Minor fixes and refactors

This commit is contained in:
2026-09-24 20:25:29 +02:00
parent ea94b65f06
commit 1f357b4e87
5 changed files with 21 additions and 29 deletions

2
castle

Submodule castle updated: af5f035830...99b8cf1d8e

View File

@@ -123,13 +123,13 @@ pub fn refresh(self: *Chunk, blocks: *const Blocks, neighbors: Neighbors) !void
if (wall.material != .empty and self.getOpposite(side, ix, iy, iz, blocks, neighbors) == .empty) { if (wall.material != .empty and self.getOpposite(side, ix, iy, iz, blocks, neighbors) == .empty) {
const matrix = getMatrix(side, origin); const matrix = getMatrix(side, origin);
try uniforms.append(allocator_frame, .{ try uniforms.append(allocator_frame, .{
.matrixOStoWS_i = matrix.getIVersor().dropW(), .matrixOStoWS = .{
.matrixOStoWS_j = matrix.getJVersor().dropW(), matrix.getIVersor().dropW(),
.matrixOStoWS_k = matrix.getKVersor().dropW(), matrix.getJVersor().dropW(),
.matrixOStoWS_t = matrix.getTranslationVector().dropW(), matrix.getKVersor().dropW(),
matrix.getTranslationVector().dropW(),
},
.texCoordTransform = wall.transform.getMatrix(), .texCoordTransform = wall.transform.getMatrix(),
.material = wall.material, .material = wall.material,
}); });
} }

View File

@@ -86,9 +86,9 @@ pub fn init() !Game {
.mag_filter = .linear, .mag_filter = .linear,
.min_filter = .linear, .min_filter = .linear,
.mipmap_mode = .linear, .mipmap_mode = .linear,
.address_mode_u = .repeat, .address_mode_u = .clamp_to_edge,
.address_mode_v = .repeat, .address_mode_v = .clamp_to_edge,
.address_mode_w = .repeat, .address_mode_w = .clamp_to_edge,
.mip_lod_bias = 0, .mip_lod_bias = 0,
.anisotropy_enable = .false, .anisotropy_enable = .false,
.max_anisotropy = 0, .max_anisotropy = 0,
@@ -909,11 +909,12 @@ fn render(self: *Game) !void {
const ambient_light = vm.Vector3.init(0.01, 0.01, 0.01); const ambient_light = vm.Vector3.init(0.01, 0.01, 0.01);
self.global_uniforms_staging_ptr.* = .{ self.global_uniforms_staging_ptr.* = .{
.matrixWStoVS_i = matrix_ws_to_vs.getIVersor().dropW(), .matrixWStoVS = .{
.matrixWStoVS_j = matrix_ws_to_vs.getJVersor().dropW(), matrix_ws_to_vs.getIVersor().dropW(),
.matrixWStoVS_k = matrix_ws_to_vs.getKVersor().dropW(), matrix_ws_to_vs.getJVersor().dropW(),
.matrixWStoVS_t = matrix_ws_to_vs.getTranslationVector().dropW(), matrix_ws_to_vs.getKVersor().dropW(),
matrix_ws_to_vs.getTranslationVector().dropW(),
},
.matrixVStoCS = matrix_vs_to_cs, .matrixVStoCS = matrix_vs_to_cs,
.matrixSSPXtoCS = matrix_sspx_to_cs, .matrixSSPXtoCS = matrix_sspx_to_cs,

View File

@@ -133,9 +133,9 @@ pub fn init() !*Gui {
.mag_filter = .linear, .mag_filter = .linear,
.min_filter = .linear, .min_filter = .linear,
.mipmap_mode = .linear, .mipmap_mode = .linear,
.address_mode_u = .repeat, .address_mode_u = .clamp_to_edge,
.address_mode_v = .repeat, .address_mode_v = .clamp_to_edge,
.address_mode_w = .repeat, .address_mode_w = .clamp_to_edge,
.mip_lod_bias = 0, .mip_lod_bias = 0,
.anisotropy_enable = .false, .anisotropy_enable = .false,
.max_anisotropy = 0, .max_anisotropy = 0,

View File

@@ -44,11 +44,7 @@ pub const Vertex = extern struct {
pub const Index = u16; pub const Index = u16;
pub const GlobalUniforms = extern struct { pub const GlobalUniforms = extern struct {
matrixWStoVS_i: vm.Vector3, matrixWStoVS: [4]vm.Vector3,
matrixWStoVS_j: vm.Vector3,
matrixWStoVS_k: vm.Vector3,
matrixWStoVS_t: vm.Vector3,
matrixVStoCS: vm.Matrix4x4, matrixVStoCS: vm.Matrix4x4,
matrixSSPXtoCS: vm.Matrix3x2, matrixSSPXtoCS: vm.Matrix3x2,
@@ -98,13 +94,8 @@ pub const Material = extern struct {
pub const ObjectUniforms = extern struct { pub const ObjectUniforms = extern struct {
// Limited to a composition of translation and rotation // Limited to a composition of translation and rotation
matrixOStoWS_i: vm.Vector3, matrixOStoWS: [4]vm.Vector3,
matrixOStoWS_j: vm.Vector3,
matrixOStoWS_k: vm.Vector3,
matrixOStoWS_t: vm.Vector3,
texCoordTransform: vm.Matrix3x2, texCoordTransform: vm.Matrix3x2,
material: Materials.Id, material: Materials.Id,
}; };