From dfdcc3e4b7bb0eda9d263b1df2688ebc08bd744d Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Thu, 26 Jan 2023 03:39:39 +0100 Subject: [PATCH] change world generations, enable mi[mapping in sampler, unlink movement speed from fps --- src/fly_controller.rs | 11 ++++++----- src/settings.rs | 2 +- src/world/render.rs | 2 +- src/world/worldgen.rs | 9 ++++++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/fly_controller.rs b/src/fly_controller.rs index 1d11b80..4da9593 100644 --- a/src/fly_controller.rs +++ b/src/fly_controller.rs @@ -1,7 +1,7 @@ use glam::{Vec3, Mat4, Quat, EulerRot, Vec2}; use shipyard::{Component, View, ViewMut, IntoIter, UniqueView, Workload, IntoWorkload}; use std::f32::consts::PI; -use crate::{transform::Transform, input::Inputs, settings::GameSettings}; +use crate::{transform::Transform, input::Inputs, settings::GameSettings, DeltaTime}; #[derive(Component)] pub struct FlyController; @@ -19,7 +19,7 @@ fn update_look( controllers: View, mut transforms: ViewMut, inputs: UniqueView, - settings: UniqueView, + settings: UniqueView ) { let look = inputs.look * settings.mouse_sensitivity; if look == Vec2::ZERO { return } @@ -29,7 +29,7 @@ fn update_look( yaw -= look.x; pitch -= look.y; pitch = pitch.clamp(-MAX_PITCH, MAX_PITCH); - rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, 0.); + rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, 0.).normalize(); transform.0 = Mat4::from_scale_rotation_translation(scale, rotation, translation); } } @@ -37,9 +37,10 @@ fn update_look( fn update_movement( controllers: View, mut transforms: ViewMut, - inputs: UniqueView + inputs: UniqueView, + dt: UniqueView, ) { - let movement = inputs.movement; + let movement = inputs.movement * 30. * dt.0.as_secs_f32(); if movement == Vec2::ZERO { return } for (_, mut transform) in (&controllers, &mut transforms).iter() { let (scale, rotation, mut translation) = transform.0.to_scale_rotation_translation(); diff --git a/src/settings.rs b/src/settings.rs index e62bf97..0588cf8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -9,7 +9,7 @@ pub struct GameSettings { impl Default for GameSettings { fn default() -> Self { Self { - render_distance: 2, + render_distance: 5, mouse_sensitivity: 0.01, } } diff --git a/src/world/render.rs b/src/world/render.rs index 56499db..70e6132 100644 --- a/src/world/render.rs +++ b/src/world/render.rs @@ -60,7 +60,7 @@ pub fn draw_world( ..Default::default() }; let texture_sampler = Sampler(&texture.0, SamplerBehavior { - minify_filter: MinifySamplerFilter::Linear, + minify_filter: MinifySamplerFilter::LinearMipmapLinear, magnify_filter: MagnifySamplerFilter::Nearest, max_anisotropy: 8, wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp), diff --git a/src/world/worldgen.rs b/src/world/worldgen.rs index ba6c4e0..8c49489 100644 --- a/src/world/worldgen.rs +++ b/src/world/worldgen.rs @@ -4,13 +4,20 @@ use super::{ block::Block }; -pub fn generate_world(_position: IVec3, _seed: u32) -> BlockData { +pub fn generate_world(position: IVec3, _seed: u32) -> BlockData { let mut blocks = Box::new([[[Block::Air; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]); blocks[0][0][0] = Block::Stone; blocks[1][0][0] = Block::Stone; blocks[0][1][0] = Block::Stone; blocks[0][2][0] = Block::Stone; blocks[0][0][1] = Block::Stone; + if position.y == 0 { + for x in 0..CHUNK_SIZE { + for z in 0..CHUNK_SIZE { + blocks[x][0][z] = Block::Stone; + } + } + } //TODO actual world generation blocks }