Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,234 changes: 550 additions & 684 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ members = ["client", "server", "common", "save", "save/gen-protos"]

[workspace.dependencies]
hecs = "0.11.0"
nalgebra = { version = "0.34.1", features = ["libm-force"] }
nalgebra = { version = "0.35.0", features = ["libm-force"] }
quinn = { version = "0.11", default-features = false, features = ["rustls", "ring", "runtime-tokio"] }
toml = { version = "0.9.12", default-features = false, features = ["parse", "serde", "std"] }
toml = { version = "1.1.4", default-features = false, features = ["parse", "serde", "std"] }

[profile.dev]
opt-level = 1
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ common = { path = "../common" }
server = { path = "../server" }
tracing = "0.1.10"
ash = { version = "0.38.0", default-features = false, features = ["loaded", "debug", "std"] }
lahar = { git = "https://github.com/Ralith/lahar", rev = "7963ae5750ea61fa0a894dbb73d3be0ac77255d2" }
lahar = { git = "https://github.com/Ralith/lahar", rev = "cb2ceca83aa3a02f20727772f6dc1bcf39fc2462" }
yakui = "0.3.0"
yakui-vulkan = "0.3.0"
winit = "0.30.4"
Expand Down
6 changes: 4 additions & 2 deletions client/src/graphics/voxels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ impl Voxels {
self.states.get_mut(slot).refcount += 1;
frame.drawn.push(slot);
// Transfer transform
frame.surface.transforms_mut()[slot as usize] =
na::Matrix4::from(*node_transform) * vertex.chunk_to_node();
unsafe {
frame.surface.transforms_mut()[slot as usize] =
na::Matrix4::from(*node_transform) * vertex.chunk_to_node();
}
}
if let (None, &VoxelData::Dense(ref data)) = (&surface, voxels) {
// Extract a surface so it can be drawn in future frames
Expand Down
6 changes: 4 additions & 2 deletions client/src/graphics/voxels/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ impl Frame {
}
}

pub fn transforms_mut(&mut self) -> &mut [na::Matrix4<f32>] {
&mut self.transforms
/// # Safety
/// The returned reference must not be used while this `Frame` is in active use by Vulkan.
pub unsafe fn transforms_mut(&mut self) -> &mut [na::Matrix4<f32>] {
unsafe { self.transforms.as_mut() }
}
}

Expand Down
4 changes: 3 additions & 1 deletion client/src/graphics/voxels/surface_extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,11 @@ impl ScratchBuffer {
pub fn storage(&mut self, index: u32) -> &mut [Material] {
let start = index as usize * (self.voxel_buffer_unit as usize / mem::size_of::<Material>());
let length = (self.dimension + 2).pow(3) as usize;
&mut self.voxels_staging[start..start + length]
unsafe { &mut self.voxels_staging.as_mut()[start..start + length] }
}

/// # Safety
/// The mutable reference returned by `storage` must not be in use while the surface is being extracted.
pub unsafe fn extract(
&mut self,
device: &Device,
Expand Down
10 changes: 6 additions & 4 deletions client/src/graphics/voxels/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ fn surface_extraction() {
test.run();

assert_eq!(
test.indirect.vertex_count, 0,
unsafe { test.indirect.as_ref() }.vertex_count,
0,
"empty chunks have no surfaces"
);

Expand All @@ -172,7 +173,8 @@ fn surface_extraction() {
test.run();

assert_eq!(
test.indirect.vertex_count, 0,
unsafe { test.indirect.as_ref() }.vertex_count,
0,
"solid chunks have no surfaces"
);

Expand All @@ -191,11 +193,11 @@ fn surface_extraction() {
test.run();

assert_eq!(
test.indirect.vertex_count,
unsafe { test.indirect.as_ref() }.vertex_count,
6 * DIMENSION.pow(2) as u32,
"half-solid chunks have n^2 surfaces"
);
let surfaces = &test.surfaces[..DIMENSION.pow(2)];
let surfaces = &unsafe { test.surfaces.as_ref() }[..DIMENSION.pow(2)];
for expected in &[
Surface {
x: 0,
Expand Down
10 changes: 4 additions & 6 deletions client/src/graphics/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,10 @@ impl Window {
}
}
},
WindowEvent::Focused(focused) => {
if !focused {
let _ = self.window.set_cursor_grab(CursorGrabMode::None);
self.window.set_cursor_visible(true);
self.input.mouse_captured = false;
}
WindowEvent::Focused(focused) if !focused => {
let _ = self.window.set_cursor_grab(CursorGrabMode::None);
self.window.set_cursor_visible(true);
self.input.mouse_captured = false;
}
_ => {}
}
Expand Down
8 changes: 4 additions & 4 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fxhash = "0.2.1"
tracing = "0.1.10"
hecs = { workspace = true }
tracing-subscriber = { version = "0.3.15", default-features = false, features = ["env-filter", "smallvec", "fmt", "ansi", "time", "parking_lot"] }
rand = "0.9.0"
rand_pcg = "0.9.0"
rand_distr = "0.5.0"
simba = "0.9.0"
rand = "0.10.2"
rand_pcg = "0.10.2"
rand_distr = "0.6.0"
simba = "0.10.2"

[dev-dependencies]
approx = "0.5.1"
Expand Down
8 changes: 4 additions & 4 deletions common/src/character_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ fn get_ground_normal(
position,
allowed_displacement.displacement(),
);
if let Some(collision) = collision_result.collision.as_ref() {
{
// Get the collision, returning `None` if we travel the whole `allowed_displacement` and don't find the ground.
let collision = collision_result.collision.as_ref()?;

if is_ground(ctx, &collision.normal) {
// We found the ground, so return its normal.
return Some(collision.normal);
Expand All @@ -155,9 +158,6 @@ fn get_ground_normal(
collision.normal,
true,
));
} else {
// Return `None` if we travel the whole `allowed_displacement` and don't find the ground.
return None;
}
}
// Return `None` if we fail to find the ground after the maximum number of attempts
Expand Down
2 changes: 1 addition & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::needless_borrowed_reference)]

use rand::{
Rng,
Rng, RngExt,
distr::{Distribution, StandardUniform},
};

Expand Down
2 changes: 1 addition & 1 deletion common/src/worldgen/horosphere.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use libm::{cosf, sinf, sqrtf};
use rand::{Rng, SeedableRng};
use rand::{RngExt, SeedableRng};
use rand_distr::Poisson;
use rand_pcg::Pcg64Mcg;

Expand Down
2 changes: 1 addition & 1 deletion common/src/worldgen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use horosphere::{HorosphereChunk, HorosphereNode};
use plane::Plane;
use rand::{Rng, SeedableRng, distr::Uniform};
use rand::{RngExt, SeedableRng, distr::Uniform};
use rand_distr::Normal;
use terraingen::VoronoiInfo;

Expand Down
4 changes: 2 additions & 2 deletions save/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ edition = "2024"

[dependencies]
prost = "0.14.3"
redb = "3.1.1"
redb = "4.1.0"
thiserror = "2.0.0"
zstd = { package = "zstd-safe", version = "7.1.0", default-features = false, features = ["std", "experimental"] }

[dev-dependencies]
tempfile = "3.4"
criterion = "0.8.2"
rand = { version = "0.9.0", features = ["small_rng"] }
rand = "0.10.2"

[[bench]]
name = "bench"
Expand Down
7 changes: 5 additions & 2 deletions save/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::hint::black_box;
use save::Save;

use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use rand::{Rng, SeedableRng, rngs::SmallRng};
use rand::{
RngExt, SeedableRng,
rngs::{SmallRng, SysRng},
};

fn save(c: &mut Criterion) {
let mut write = c.benchmark_group("write");
Expand All @@ -13,7 +16,7 @@ fn save(c: &mut Criterion) {
voxels: vec![0; 12 * 12 * 12 * 2],
}],
};
let mut rng = SmallRng::from_os_rng();
let mut rng = SmallRng::try_from_rng(&mut SysRng).unwrap();
for count in [1, 100, 10000] {
write.throughput(Throughput::Elements(count));
write.bench_function(BenchmarkId::from_parameter(count), |b| {
Expand Down
7 changes: 5 additions & 2 deletions save/tests/heavy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ use std::time::Instant;

use save::Save;

use rand::{Rng, SeedableRng, rngs::SmallRng};
use rand::{
RngExt, SeedableRng,
rngs::{SmallRng, SysRng},
};

#[test]
fn write() {
let mut rng = SmallRng::from_os_rng();
let mut rng = SmallRng::try_from_rng(&mut SysRng).unwrap();
let file = tempfile::NamedTempFile::new().unwrap();
let save = Save::open(file.path(), 12).unwrap();
let node = save::VoxelNode {
Expand Down
7 changes: 5 additions & 2 deletions save/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use rand::{Rng, SeedableRng, rngs::SmallRng};
use rand::{
RngExt, SeedableRng,
rngs::{SmallRng, SysRng},
};

use save::Save;

Expand Down Expand Up @@ -41,7 +44,7 @@ fn persist_character() {
let save = Save::open(file.path(), 12).unwrap();
let mut writer_guard = save.write().unwrap();
let mut writer = writer_guard.get().unwrap();
let mut rng = SmallRng::from_os_rng();
let mut rng = SmallRng::try_from_rng(&mut SysRng).unwrap();
let mut path = Vec::with_capacity(17000);
for _ in 0..17000 {
path.push(rng.random_range(0..12));
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ anyhow = "1.0.26"
rcgen = { version = "0.14.6", default-features = false, features = ["ring"] }
hostname = "0.4.0"
hecs = { workspace = true }
rand = { version = "0.9.0", features = ["small_rng"] }
rand = "0.10.2"
fxhash = "0.2.1"
nalgebra = { workspace = true }
libm = "0.2.16"
Expand Down
6 changes: 3 additions & 3 deletions server/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use common::world::Material;
use common::{GraphEntities, node::ChunkId};
use fxhash::{FxHashMap, FxHashSet};
use hecs::{DynamicBundle, Entity, EntityBuilder};
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use rand::rngs::{SmallRng, SysRng};
use rand::{RngExt, SeedableRng};
use save::ComponentType;
use serde::{Deserialize, Serialize};
use tracing::{error, error_span, info, trace};
Expand Down Expand Up @@ -52,7 +52,7 @@ pub struct Sim {
impl Sim {
pub fn new(cfg: Arc<SimConfig>, save: &save::Save) -> Self {
let mut result = Self {
rng: SmallRng::from_os_rng(),
rng: SmallRng::try_from_rng(&mut SysRng).unwrap(),
step: 0,
entity_ids: FxHashMap::default(),
world: hecs::World::new(),
Expand Down
Loading