Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bevy 0.14 #16

Merged
merged 4 commits into from
Jul 24, 2024
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
2,267 changes: 1,383 additions & 884 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name = "infinigen"
version = "0.0.0"
edition = "2021"
publish = false
rust-version = "1.76.0"
rust-version = "1.79.0"

[lib]
path = "src/lib/mod.rs"

[dependencies]
bevy = { version = "0.13.0" }
bevy_common_assets = { version = "0.10.0", features = ["ron"] }
bevy_egui = { version = "0.25.0" }
bevy-inspector-egui = { version = "0.23.4" }
bevy = { version = "0.14.0" }
bevy_common_assets = { version = "0.11.0", features = ["ron"] }
bevy_egui = { version = "0.28.0" }
bevy-inspector-egui = { version = "0.25.1" }

# config
config = { version = "0.14.0", default-features = false, features = ["ron"] }
Expand All @@ -22,12 +22,12 @@ block-mesh = { git = "https://github.com/bonsairobo/block-mesh-rs", rev = "793c5

# serialization
bincode = "1.3.3"
serde = { version = "1.0.197", features = ["derive"] }
serde = { version = "1.0.204", features = ["derive"] }

# utils
eyre = "0.6.12"
futures-lite = "2.2.0"
strum = { version = "0.26.1", features = ["derive"] }
futures-lite = "2.3.0"
strum = { version = "0.26.3", features = ["derive"] }
lru = "0.12.3"

# instrumentation
Expand All @@ -37,12 +37,12 @@ tracing-subscriber = "0.3.18"

# randomness
rand = "0.8.5"
noise = "0.8.2"
noise = "0.9.0"
bracket-noise = "0.8.7"
splines = "4.3.1"
ndarray = { version = "0.15.6", features = ["serde"] }
nalgebra = "0.32.4"
rustc-hash = "1.1.0"
nalgebra = "0.33.0"
rustc-hash = "2.0.0"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
12 changes: 6 additions & 6 deletions src/lib/debug/chunk_borders.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use crate::common::chunks::CHUNK_SIZE_F32;
use bevy::render::mesh::MeshVertexBufferLayoutRef;
use bevy::render::render_asset::RenderAssetUsages;
/// Adapted from lines example of Bevy
use bevy::{
pbr::{MaterialPipeline, MaterialPipelineKey},
prelude::*,
reflect::TypePath,
render::{
mesh::{MeshVertexBufferLayout, PrimitiveTopology},
mesh::PrimitiveTopology,
render_resource::{
AsBindGroup, PolygonMode, RenderPipelineDescriptor, ShaderRef,
SpecializedMeshPipelineError,
},
},
};

use crate::common::chunks::CHUNK_SIZE_F32;

#[derive(Debug, Default, Eq, PartialEq, Resource)]
pub struct ChunkBordersState {
pub show: bool,
Expand Down Expand Up @@ -42,7 +42,7 @@ impl From<LineList> for Mesh {
#[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)]
pub struct LineMaterial {
#[uniform(0)]
color: Color,
color: LinearRgba,
}

impl Material for LineMaterial {
Expand All @@ -53,7 +53,7 @@ impl Material for LineMaterial {
fn specialize(
_pipeline: &MaterialPipeline<Self>,
descriptor: &mut RenderPipelineDescriptor,
_layout: &MeshVertexBufferLayout,
_layout: &MeshVertexBufferLayoutRef,
_key: MaterialPipelineKey<Self>,
) -> Result<(), SpecializedMeshPipelineError> {
// This is the important part to tell bevy to render this material as a line between vertices
Expand Down Expand Up @@ -141,7 +141,7 @@ pub fn toggle(
mesh: meshes.add(mesh),
transform,
material: materials.add(LineMaterial {
color: Color::WHITE,
color: LinearRgba::WHITE,
}),
..default()
},
Expand Down
7 changes: 3 additions & 4 deletions src/lib/extras/worldgen/layered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,9 @@ impl WorldGen for Layered {
}

fn get(&mut self, pos: &ChunkPosition, zoom_level: ZoomLevel) -> Chunk {
if self.terrain_cache.get(&zoom_level).is_none() {
self.terrain_cache
.insert(zoom_level, LruCache::new(NonZeroUsize::new(1024).unwrap()));
}
self.terrain_cache
.entry(zoom_level)
.or_insert_with(|| LruCache::new(NonZeroUsize::new(1024).unwrap()));
let zoom_cache = self.terrain_cache.get_mut(&zoom_level).unwrap();
let zoom = zoom_level.as_f64();
let mut terrain = zoom_cache
Expand Down
8 changes: 4 additions & 4 deletions src/lib/extras/worldgen/mountain_islands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl WorldGen for MountainIslands {
chunk.insert(
&BlockPosition {
x,
y: (y + y_offset).min(BlockPosition::MAX_IDX).max(0),
y: (y + y_offset).clamp(0, BlockPosition::MAX_IDX),
z,
},
*self.block_mappings.get(WOOD_BLOCK_ID).unwrap(),
Expand All @@ -248,9 +248,9 @@ impl WorldGen for MountainIslands {
}
chunk.insert_if_free(
&BlockPosition {
x: (x + x_offset).min(BlockPosition::MAX_IDX).max(0),
y: (y + y_offset).min(BlockPosition::MAX_IDX).max(0),
z: (z + z_offset).min(BlockPosition::MAX_IDX).max(0),
x: (x + x_offset).clamp(0, BlockPosition::MAX_IDX),
y: (y + y_offset).clamp(0, BlockPosition::MAX_IDX),
z: (z + z_offset).clamp(0, BlockPosition::MAX_IDX),
},
*self.block_mappings.get(LEAVES_BLOCK_ID).unwrap(),
);
Expand Down
4 changes: 1 addition & 3 deletions src/lib/mesh/textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ impl TextureMap {
face: Face,
uvs: [[f32; 2]; 4],
) -> Option<FaceAppearanceTransformed> {
let Some(appearances) = self.appearance.get(id) else {
return None;
};
let appearances = self.appearance.get(id)?;
match appearances[face as usize] {
FaceAppearance::Texture { coords } => Some(FaceAppearanceTransformed::Texture {
coords: to_tex_coords_raw(uvs, coords, self.size),
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scene/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn setup(
.iter()
{
let handle = handle.clone_weak().typed();
let path = asset_server.get_path(handle.clone_weak());
let path = asset_server.get_path(handle.id());
if let Some(texture) = textures.get(&handle) {
tracing::info!(?path, "Texture found");
let path = path.unwrap();
Expand All @@ -173,7 +173,7 @@ pub fn setup(
panic!();
};
}
let (atlas_layout, texture_atlas) = block_tatlas_builder.finish().unwrap();
let (atlas_layout, texture_atlas) = block_tatlas_builder.build().unwrap();
tracing::info!(?atlas_layout.size, ?atlas_layout.textures, "Stitched texture atlas");
let texture_atlas = textures.add(texture_atlas);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod handle;
pub mod lights;
pub mod visible_chunks;

pub const SKY_COLOR: Color = Color::rgb(0.47, 0.66, 1.);
pub const SKY_COLOR: Color = Color::srgb(0.47, 0.66, 1.);

/// Holds details of the currently rendered scene.
#[derive(Debug, Resource)]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> ExitCode {
.set(LogPlugin {
filter: LOG_FILTER.into(),
level: bevy::log::Level::DEBUG,
update_subscriber: None,
custom_layer: |_| None,
})
.set(ImagePlugin::default_nearest())
.set(WindowPlugin {
Expand Down
Loading