Skip to content

Commit

Permalink
Merge pull request #22 from jameshiew/improv
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
jameshiew authored Nov 30, 2024
2 parents 66c369d + 28a4063 commit 7a6457a
Show file tree
Hide file tree
Showing 56 changed files with 139 additions and 137 deletions.
246 changes: 124 additions & 122 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ edition = "2021"
publish = false
rust-version = "1.80.1"

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

[dependencies]
bevy = { version = "0.14.2" }
bevy_common_assets = { version = "0.11.0", features = ["ron"] }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ This is a demo for Minecraft-like procedural generation using the [Bevy game eng
- chunks along all axes (X, Y and Z)
- adjustable zoom level for viewing a world at different levels of detail

![Main screenshot](screenshots/main.png "Screenshot")
![Zoomed out screenshot](screenshots/zoomed_out.png "Zoomed out")
![Main screenshot](screenshots/main.webp "Screenshot")
![Zoomed out screenshot](screenshots/zoomed_out.webp "Zoomed out")

## Quickstart

Expand Down
3 changes: 2 additions & 1 deletion assets/shaders/line_material.wgsl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// From lines example of Bevy - https://github.com/bevyengine/bevy/blob/release-0.14.2/assets/shaders/line_material.wgsl
#import bevy_pbr::forward_io::VertexOutput

struct LineMaterial {
color: vec4<f32>,
};

@group(1) @binding(0) var<uniform> material: LineMaterial;
@group(2) @binding(0) var<uniform> material: LineMaterial;

@fragment
fn fragment(
Expand Down
Binary file removed screenshots/main.png
Binary file not shown.
Binary file added screenshots/main.webp
Binary file not shown.
Binary file removed screenshots/zoomed_out.png
Binary file not shown.
Binary file added screenshots/zoomed_out.webp
Binary file not shown.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/lib/camera/settings.rs → src/camera/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn setup(mut commands: Commands, config: Res<Config>) {
transform.rotation.y = config.rotation_y;
transform.rotation.z = config.rotation_z;
transform.rotation.w = config.rotation_w;
transform.rotation = transform.rotation.normalize();
dbg!(transform.rotation);
commands
.spawn((
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 7 additions & 5 deletions src/lib/debug/chunk_borders.rs → src/debug/chunk_borders.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Adapted from lines example of Bevy - https://github.com/bevyengine/bevy/blob/release-0.14.2/examples/3d/lines.rs
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::*,
Expand Down Expand Up @@ -31,11 +31,13 @@ pub struct LineList {

impl From<LineList> for Mesh {
fn from(line: LineList) -> Self {
let mut mesh = Mesh::new(PrimitiveTopology::LineList, RenderAssetUsages::default());

let vertices: Vec<_> = line.lines.into_iter().flat_map(|(a, b)| [a, b]).collect();
mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, vertices);
mesh
let count = vertices.len();

Mesh::new(PrimitiveTopology::LineList, RenderAssetUsages::RENDER_WORLD)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, vertices)
// arbitrary normal
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, vec![Vec3::Y; count])
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/debug/info.rs → src/debug/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ pub fn display_debug_info(
let (camera_wpos, mut camera) = camera.single_mut();
egui::Window::new("Performance").show(egui.ctx_mut(), |ui| {
ui.label(format!(
"FPS: {:.02}",
"FPS: {:.0}",
diagnostics
.get(&FrameTimeDiagnosticsPlugin::FPS)
.unwrap()
.average()
.unwrap_or_default()
));
ui.label(format!(
"Entities: {}",
"Entities: {:.0}",
diagnostics
.get(&EntityCountDiagnosticsPlugin::ENTITY_COUNT)
.unwrap()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::ExitCode;
use bevy::{
log::LogPlugin,
prelude::*,
window::{Window, WindowPlugin, WindowResolution},
window::{Window, WindowPlugin},
DefaultPlugins,
};
use config::Config;
Expand Down Expand Up @@ -46,7 +46,6 @@ fn main() -> ExitCode {
.set(ImagePlugin::default_nearest())
.set(WindowPlugin {
primary_window: Some(Window {
resolution: WindowResolution::new(1920., 1080.),
title: APP_NAME.into(),
..default()
}),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7a6457a

Please sign in to comment.