Skip to content

Commit f302f0b

Browse files
committed
add CI
1 parent d955a01 commit f302f0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5336
-4879
lines changed

.github/workflows/prek.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Prek checks
2+
on: [push, pull_request]
3+
4+
jobs:
5+
prek:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v6
9+
- name: Install uv
10+
uses: astral-sh/setup-uv@v7
11+
- name: Set up Python
12+
run: uv python install
13+
- uses: j178/prek-action@v1

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: builtin
3+
hooks:
4+
- id: trailing-whitespace
5+
- id: mixed-line-ending
6+
- id: detect-private-key
7+
exclude: ^(imgs|py|target|test_data)
8+

crates/chunk_gen/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ Packet {
7070
},
7171
SendReliableCommand {
7272
data_length: 246,
73-
data:
73+
data:
7474
23 26 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d | #&<?xml version=
7575
22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 | "1.0" encoding="
7676
55 54 46 2d 38 22 3f 3e 0a 3c 21 44 4f 43 54 59 | UTF-8"?>.<!DOCTY
77-
50 45 20 70 6c 69 73 74 20 50 55 42 4c 49 43 20 | PE plist PUBLIC
77+
50 45 20 70 6c 69 73 74 20 50 55 42 4c 49 43 20 | PE plist PUBLIC
7878
22 2d 2f 2f 41 70 70 6c 65 2f 2f 44 54 44 20 50 | "-//Apple//DTD P
7979
4c 49 53 54 20 31 2e 30 2f 2f 45 4e 22 20 22 68 | LIST 1.0//EN" "h
8080
74 74 70 3a 2f 2f 77 77 77 2e 61 70 70 6c 65 2e | ttp://www.apple.
8181
63 6f 6d 2f 44 54 44 73 2f 50 72 6f 70 65 72 74 | com/DTDs/Propert
8282
79 4c 69 73 74 2d 31 2e 30 2e 64 74 64 22 3e 0a | yList-1.0.dtd">.
8383
3c 70 6c 69 73 74 20 76 65 72 73 69 6f 6e 3d 22 | <plist version="
84-
31 2e 30 22 3e 0a 3c 64 69 63 74 3e 0a 20 20 20 | 1.0">.<dict>.
84+
31 2e 30 22 3e 0a 3c 64 69 63 74 3e 0a 20 20 20 | 1.0">.<dict>.
8585
20 3c 6b 65 79 3e 77 6f 72 6c 64 49 44 3c 2f 6b | <key>worldID</k
8686
65 79 3e 0a 20 20 20 20 3c 73 74 72 69 6e 67 3e | ey>. <string>
8787
33 64 37 5f 6d 6f 64 69 66 69 65 64 3c 2f 73 74 | 3d7_modified</st
@@ -127,7 +127,7 @@ Packet {
127127
},
128128
SendReliableCommand {
129129
data_length: 417,
130-
data:
130+
data:
131131
01 1f 8b 08 00 00 00 00 00 00 03 75 93 5d 4f 83 | ...........u.]O.
132132
30 14 86 ef f7 2b 2a f7 a3 14 74 1d 06 31 2a 33 | 0....+*...t..1*3
133133
21 d9 07 71 a8 f1 ca 34 f4 6c 6b 04 4a 4a b3 8f | !..q...4.lk.JJ..
@@ -223,7 +223,7 @@ Packet {
223223
},
224224
SendReliableCommand {
225225
data_length: 591,
226-
data:
226+
data:
227227
1f 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 | .<?xml version="
228228
31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 55 | 1.0" encoding="U
229229
54 46 2d 38 22 3f 3e 0a 3c 21 44 4f 43 54 59 50 | TF-8"?>.<!DOCTYP
@@ -290,7 +290,7 @@ Packet {
290290
},
291291
SendReliableCommand {
292292
data_length: 9,
293-
data:
293+
data:
294294
03 4f 21 00 00 01 00 00 00 | .O!...... ,
295295
},
296296
),

crates/gui/.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: cargo-fmt
5+
name: cargo fmt
6+
entry: cargo fmt
7+
language: system
8+
types: [rust]
9+
pass_filenames: false
10+
11+
- id: cargo-check
12+
name: cargo check
13+
entry: cargo check
14+
language: system
15+
types: [rust]
16+
pass_filenames: false
17+
18+
- id: clippy
19+
name: clippy
20+
entry: cargo clippy -- -D warnings
21+
language: system
22+
types: [rust]
23+
pass_filenames: false

crates/gui/src/dw_icon.wgsl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ struct DynObjVSOutput {
4646
@vertex
4747
fn vs_dynamic_object_icon(model: DynObjVertexInput, instance: DynObjInstanceInput) -> DynObjVSOutput {
4848
var out: DynObjVSOutput;
49-
49+
5050
let world_pos = vec3<f32>(instance.instance_pos + model.position, 2.0);
5151
let pos_in_view = world_pos - camera.world_offset.xyz;
5252
out.clip_position = camera.view_proj * vec4<f32>(pos_in_view, 1.0);
53-
53+
5454
// Pass model position to fragment shader for UV calculation
5555
// Remap from [-0.5, 0.5] to [0, 1]
5656
out.uv = model.position + 0.5;
@@ -117,15 +117,15 @@ fn render_block_icon(uv: vec2<f32>, block_type_id: u32) -> vec4<f32> {
117117
face_normal = select(vec3<f32>(0.0, 0.0, -1.0), vec3<f32>(0.0, 0.0, 1.0), hit_pos.z > 0.0); // Set normal
118118
}
119119
face_uv.y = 1.0 - face_uv.y;
120-
120+
121121
// Now sample the tilemap using the determined face
122122
let atlas_lookup_idx = (block_type_id * 6u) + hit_face_id;
123123
let tile_index = voxel_uv_atlas[atlas_lookup_idx];
124-
124+
125125
let tile_x = f32(tile_index % VOXEL_TILES_PER_ROW);
126126
let tile_y = f32(tile_index / VOXEL_TILES_PER_ROW);
127127
let uv_min_tile = vec2<f32>(tile_x * VOXEL_TILE_SIZE_UV, tile_y * VOXEL_TILE_SIZE_UV);
128-
128+
129129
let final_atlas_uv = uv_min_tile + face_uv * VOXEL_TILE_SIZE_UV;
130130
var surface_color = textureSampleLevel(tilemap_texture, tilemap_sampler, final_atlas_uv, 0.0);
131131

@@ -156,7 +156,7 @@ fn fs_dynamic_object_icon(in: DynObjVSOutput) -> @location(0) vec4<f32> {
156156
let tile_x = f32(tile_index % ITEMS_TILES_PER_ROW);
157157
let tile_y = f32(tile_index / ITEMS_TILES_PER_ROW);
158158
let uv_min_tile = vec2<f32>(tile_x * ITEMS_TILE_SIZE_UV.x, tile_y * ITEMS_TILE_SIZE_UV.y);
159-
159+
160160
let final_atlas_uv = uv_min_tile + in.uv * ITEMS_TILE_SIZE_UV;
161161
final_color = textureSampleLevel(items_texture, items_sampler, final_atlas_uv, 0.0);
162162
}
@@ -174,7 +174,7 @@ fn fs_dynamic_object_icon(in: DynObjVSOutput) -> @location(0) vec4<f32> {
174174
// You might want a more sophisticated blend mode depending on desired effect
175175
final_color = mix(final_color, outline_color, outline_color.a);
176176
}
177-
177+
178178
let gamma = 2.2;
179179
let corrected_color = pow(final_color.rgb, vec3<f32>(1.0 / gamma));
180180
return vec4<f32>(corrected_color, final_color.a);

crates/gui/src/grid.wgsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn fs_grid(in: VertexOutput) -> @location(0) vec4<f32> {
5656

5757
// --- 2. Ray-Plane Intersection ---
5858
// Find intersection with plane world.z = GRID_Z
59-
59+
6060
// Discard if ray is parallel to the plane
6161
if (abs(ray_dir_world.z) < 1e-6) {
6262
discard;
@@ -72,13 +72,13 @@ fn fs_grid(in: VertexOutput) -> @location(0) vec4<f32> {
7272
let world_pos = ray_origin_world + ray_dir_world * t;
7373

7474
// --- 3. Check World Boundaries ---
75-
if (world_pos.x < 0.0 || world_pos.x > WORLD_DIM_X_F32 ||
75+
if (world_pos.x < 0.0 || world_pos.x > WORLD_DIM_X_F32 ||
7676
world_pos.y < 0.0 || world_pos.y > WORLD_DIM_Y_F32) {
7777
discard;
7878
}
7979

8080
// --- 4. Calculate Anti-Aliased Grid Lines ---
81-
81+
8282
// Get the width of one pixel in world coordinates
8383
let line_width_vec = fwidth(world_pos.xy);
8484
let line_width = (line_width_vec.x + line_width_vec.y) * 0.5 * 1.0; // 1.0 pixel wide
@@ -87,7 +87,7 @@ fn fs_grid(in: VertexOutput) -> @location(0) vec4<f32> {
8787
let d = world_pos.xy % CHUNK_SIZE;
8888
// `dist` = distance to the *nearest* grid line
8989
let dist = min(d, CHUNK_SIZE - d);
90-
90+
9191
// `grid_line` will be 0.0 on the line, and increase as we move away
9292
let grid_line = dist / line_width;
9393

crates/gui/src/voxel.wgsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn render_and_blend(
148148
let ambient_light = 0.2;
149149
let diffuse_factor = max(dot(face_normal_f32, light_direction), 0.0);
150150
let final_light_factor = ambient_light + (1.0 - ambient_light) * diffuse_factor;
151-
151+
152152
let lit_rgb = surface_color.rgb * final_light_factor;
153153

154154
let min_depth_factor = 0.85;
@@ -218,7 +218,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
218218
var current_ray_pos = ray_origin_world + ray_dir_world * t_min_intersect;
219219
var current_voxel_coords = vec3<i32>(floor(current_ray_pos / VOXEL_SIZE));
220220
current_voxel_coords = clamp(current_voxel_coords, vec3<i32>(0), vec3<i32>(i32(WORLD_DIM_X)-1, i32(WORLD_DIM_Y)-1, i32(WORLD_DIM_Z)-1));
221-
221+
222222
var step_dir = sign(ray_dir_world);
223223
if (ray_dir_world.x == 0.0) { step_dir.x = 0.0; }
224224
if (ray_dir_world.y == 0.0) { step_dir.y = 0.0; }
@@ -262,7 +262,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
262262
t_first_hit = t_hit;
263263
}
264264
}
265-
265+
266266
prev_voxel_type = current_voxel_type;
267267

268268
if (t_max_axis.x < t_max_axis.y && t_max_axis.x < t_max_axis.z) {
@@ -297,12 +297,12 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
297297
// This is the standard "over" alpha blending operation.
298298
// Final RGB = Highlight RGB + Scene RGB * (1 - Highlight Alpha)
299299
let final_rgb = mix(accumulated_color.rgb, highlight_color.rgb, highlight_color.a);
300-
300+
301301
// The final alpha is also a combination of the highlight and scene alphas.
302302
let final_a = highlight_color.a + accumulated_color.a * (1.0 - highlight_color.a);
303303

304304
accumulated_color = vec4<f32>(final_rgb, final_a);
305-
}
305+
}
306306

307307
if (ever_hit_hover_on_block) {
308308
let highlight_color = vec4<f32>(0.0, 0.0, 1.0, 0.1);
@@ -311,7 +311,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
311311
// This is the standard "over" alpha blending operation.
312312
// Final RGB = Highlight RGB + Scene RGB * (1 - Highlight Alpha)
313313
let final_rgb = mix(accumulated_color.rgb, highlight_color.rgb, highlight_color.a);
314-
314+
315315
// The final alpha is also a combination of the highlight and scene alphas.
316316
let final_a = highlight_color.a + accumulated_color.a * (1.0 - highlight_color.a);
317317

crates/lib/.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: cargo-fmt
5+
name: cargo fmt
6+
entry: cargo fmt
7+
language: system
8+
types: [rust]
9+
pass_filenames: false
10+
11+
- id: cargo-check
12+
name: cargo check
13+
entry: cargo check
14+
language: system
15+
types: [rust]
16+
pass_filenames: false
17+
18+
- id: clippy
19+
name: clippy
20+
entry: cargo clippy -- -D warnings
21+
language: system
22+
types: [rust]
23+
pass_filenames: false
24+
25+
- id: cargo-test
26+
name: cargo test
27+
entry: cargo test
28+
language: system
29+
types: [rust]
30+
pass_filenames: false

crates/lib/src/game/coord.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,21 @@ mod tests {
251251
if let Ok(block_coord) = BlockCoord::new(x, y) {
252252
let (chunk_coord, chunk_block_coord) = block_coord.decompose();
253253
let params_recomposed = BlockCoord::from_decomposed(chunk_coord, chunk_block_coord);
254-
assert_eq!(block_coord, params_recomposed, "Round trip failed for ({}, {})", x, y);
254+
assert_eq!(
255+
block_coord, params_recomposed,
256+
"Round trip failed for ({}, {})",
257+
x, y
258+
);
255259
}
256260
}
257261
}
258262

259263
#[test]
260264
fn test_chunk_coord_parse() {
261-
assert_eq!(ChunkCoord::try_from_str("10_20").unwrap(), ChunkCoord::new(10, 20).unwrap());
265+
assert_eq!(
266+
ChunkCoord::try_from_str("10_20").unwrap(),
267+
ChunkCoord::new(10, 20).unwrap()
268+
);
262269
assert!(ChunkCoord::try_from_str("10_32").is_err());
263270
assert!(ChunkCoord::try_from_str("abc_20").is_err());
264271
assert!(ChunkCoord::try_from_str("10_abc").is_err());
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: cargo-fmt
5+
name: cargo fmt
6+
entry: cargo fmt
7+
language: system
8+
types: [rust]
9+
pass_filenames: false
10+
11+
- id: cargo-check
12+
name: cargo check
13+
entry: cargo check
14+
language: system
15+
types: [rust]
16+
pass_filenames: false
17+
18+
- id: clippy
19+
name: clippy
20+
entry: cargo clippy -- -D warnings
21+
language: system
22+
types: [rust]
23+
pass_filenames: false
24+
25+
- id: cargo-test
26+
name: cargo test
27+
entry: cargo test
28+
language: system
29+
types: [rust]
30+
pass_filenames: false

0 commit comments

Comments
 (0)