Skip to content

Commit

Permalink
fmt: group module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshiew committed Dec 6, 2024
1 parent 70241ef commit a882217
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 62 deletions.
6 changes: 2 additions & 4 deletions crates/common/src/extras/worldgen/experiment1.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use noise::{Fbm, MultiFractal, NoiseFn, Perlin};
use rustc_hash::FxHashMap;

use crate::chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F64, CHUNK_USIZE};
use crate::extras::block_ids::{GRASS_BLOCK_ID, GRAVEL_BLOCK_ID, SAND_BLOCK_ID, WATER_BLOCK_ID};
use crate::world::{BlockId, BlockPosition, ChunkBlockId, ChunkPosition, WorldGen, WorldPosition};
use crate::zoom::ZoomLevel;
use crate::{
chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F64, CHUNK_USIZE},
world::{BlockId, BlockPosition, ChunkBlockId, ChunkPosition, WorldGen, WorldPosition},
};

pub struct Experiment1 {
pub block_mappings: FxHashMap<BlockId, ChunkBlockId>,
Expand Down
6 changes: 2 additions & 4 deletions crates/common/src/extras/worldgen/mountain_islands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ use noise::{Fbm, MultiFractal, NoiseFn, Perlin};
use rustc_hash::FxHashMap;
use splines::{Interpolation, Key, Spline};

use crate::chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F64, CHUNK_USIZE};
use crate::extras::block_ids::{
DIRT_BLOCK_ID, GRASS_BLOCK_ID, GRAVEL_BLOCK_ID, SAND_BLOCK_ID, SNOW_BLOCK_ID, STONE_BLOCK_ID,
WATER_BLOCK_ID,
};
use crate::world::{BlockId, BlockPosition, ChunkBlockId, ChunkPosition, WorldGen, WorldPosition};
use crate::zoom::ZoomLevel;
use crate::{
chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F64, CHUNK_USIZE},
world::{BlockId, BlockPosition, ChunkBlockId, ChunkPosition, WorldGen, WorldPosition},
};

pub struct MountainIslands {
pub block_mappings: FxHashMap<BlockId, ChunkBlockId>,
Expand Down
5 changes: 3 additions & 2 deletions crates/common/src/mesh/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! This module is concerned with meshing chunks, and not with rendering.
use block_mesh::ndshape::ConstShape;
use block_mesh::{
greedy_quads, ndshape::ConstShape, visible_block_faces, GreedyQuadsBuffer, UnitQuadBuffer,
greedy_quads, visible_block_faces, GreedyQuadsBuffer, UnitQuadBuffer, UnorientedQuad, Voxel,
VoxelVisibility,
};
use block_mesh::{UnorientedQuad, Voxel, VoxelVisibility};
use faces::RHS_FACES;
use rand::Rng;
use shapes::{PaddedChunk, PaddedChunkShape, PADDED_CHUNK_MAX_INDEX};
Expand Down
4 changes: 3 additions & 1 deletion crates/infinigen/src/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use infinigen_common::mesh::textures::{Face, FaceAppearance, TextureMap};
use rustc_hash::FxHashMap;
use strum::IntoEnumIterator;

use crate::{settings::Config, world::World, AppState};
use crate::settings::Config;
use crate::world::World;
use crate::AppState;

pub mod blocks;
pub struct Plugin;
Expand Down
11 changes: 6 additions & 5 deletions crates/infinigen/src/camera/settings.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use bevy::{
core_pipeline::experimental::taa::TemporalAntiAliasing, pbr::ScreenSpaceAmbientOcclusion,
prelude::*, utils::default,
};
use bevy::core_pipeline::experimental::taa::TemporalAntiAliasing;
use bevy::pbr::ScreenSpaceAmbientOcclusion;
use bevy::prelude::*;
use bevy::utils::default;

use crate::{scene::FAR, settings::Config};
use crate::scene::FAR;
use crate::settings::Config;

#[derive(Component)]
pub struct Settings {
Expand Down
4 changes: 2 additions & 2 deletions crates/infinigen/src/chunks/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use bevy::core::Name;
use bevy::prelude::{Commands, Component, Entity, Event, EventReader, Query, Res, ResMut};
use bevy::tasks::{AsyncComputeTaskPool, Task};
use futures_lite::future;
use infinigen_common::world::WorldGen;
use infinigen_common::chunks::Chunk;
use infinigen_common::world::{ChunkPosition, WorldGen};
use infinigen_common::zoom::ZoomLevel;
use infinigen_common::{chunks::Chunk, world::ChunkPosition};

use super::registry::{get_neighbour_cposes, ChunkRegistry, ChunkStatus};
use crate::assets;
Expand Down
18 changes: 6 additions & 12 deletions crates/infinigen/src/debug/chunk_borders.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use bevy::render::mesh::MeshVertexBufferLayoutRef;
use bevy::pbr::{MaterialPipeline, MaterialPipelineKey};
use bevy::prelude::*;
use bevy::reflect::TypePath;
use bevy::render::mesh::{MeshVertexBufferLayoutRef, PrimitiveTopology};
use bevy::render::render_asset::RenderAssetUsages;
use bevy::{
pbr::{MaterialPipeline, MaterialPipelineKey},
prelude::*,
reflect::TypePath,
render::{
mesh::PrimitiveTopology,
render_resource::{
AsBindGroup, PolygonMode, RenderPipelineDescriptor, ShaderRef,
SpecializedMeshPipelineError,
},
},
use bevy::render::render_resource::{
AsBindGroup, PolygonMode, RenderPipelineDescriptor, ShaderRef, SpecializedMeshPipelineError,
};
/// Adapted from lines example of Bevy - https://github.com/bevyengine/bevy/blob/release-0.14.2/examples/3d/lines.rs
use infinigen_common::chunks::CHUNK_SIZE_F32;
Expand Down
6 changes: 2 additions & 4 deletions crates/infinigen/src/debug/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use bevy::diagnostic::{
DiagnosticsStore, EntityCountDiagnosticsPlugin, FrameTimeDiagnosticsPlugin,
};
use bevy::prelude::*;
use bevy_egui::{
egui::{self, Slider},
EguiContexts,
};
use bevy_egui::egui::{self, Slider};
use bevy_egui::EguiContexts;
use infinigen_common::chunks::CHUNK_SIZE_F32;

use crate::scene::{self, LoadedChunk};
Expand Down
3 changes: 2 additions & 1 deletion crates/infinigen/src/debug/wireframe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::{pbr::wireframe::WireframeConfig, prelude::*};
use bevy::pbr::wireframe::WireframeConfig;
use bevy::prelude::*;

pub fn toggle(keys: Res<ButtonInput<KeyCode>>, mut wireframe_cfg: ResMut<WireframeConfig>) {
for key in keys.get_just_pressed() {
Expand Down
10 changes: 4 additions & 6 deletions crates/infinigen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use anyhow::{Context, Result};
use bevy::{
log::LogPlugin,
prelude::*,
window::{Window, WindowPlugin},
DefaultPlugins,
};
use bevy::log::LogPlugin;
use bevy::prelude::*;
use bevy::window::{Window, WindowPlugin};
use bevy::DefaultPlugins;
use config::Config;
use infinigen::AppPlugin;

Expand Down
23 changes: 8 additions & 15 deletions crates/infinigen/src/scene/handle.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
use bevy::prelude::*;
use infinigen_common::{
chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F32},
world::{BlockPosition, BlockVisibility, ChunkBlockId, WorldPosition},
};

use super::LoadedChunk;
use super::UnloadChunkOpEvent;
use crate::assets::blocks::BlockRegistry;
use crate::assets::blocks::MaterialType;
use crate::chunks::registry::ChunkRegistry;
use crate::chunks::registry::ChunkStatus;
use infinigen_common::chunks::{Chunk, UnpackedChunk, CHUNK_SIZE, CHUNK_SIZE_F32};
use infinigen_common::world::{BlockPosition, BlockVisibility, ChunkBlockId, WorldPosition};

use super::{LoadedChunk, UnloadChunkOpEvent};
use crate::assets::blocks::{BlockRegistry, MaterialType};
use crate::chunks::registry::{ChunkRegistry, ChunkStatus};
use crate::chunks::tasks::RequestChunkEvent;
use crate::scene::RequestChunkOp;
use crate::{
utils::mesh::{bevy_mesh_greedy_quads, bevy_mesh_visible_block_faces},
world::World,
};
use crate::utils::mesh::{bevy_mesh_greedy_quads, bevy_mesh_visible_block_faces};
use crate::world::World;

// bigger chunks means go slower to prevent lag/stutter
const CHUNK_OP_RATE: usize = (16. * (32. / CHUNK_SIZE_F32)) as usize;
Expand Down
3 changes: 2 additions & 1 deletion crates/infinigen/src/scene/lights.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::f32::consts::PI;

use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*};
use bevy::pbr::CascadeShadowConfigBuilder;
use bevy::prelude::*;
use infinigen_common::chunks::CHUNK_SIZE_F32;

use super::FAR;
Expand Down
3 changes: 1 addition & 2 deletions crates/infinigen/src/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::f32::consts::PI;
use bevy::prelude::*;
use infinigen_common::chunks::CHUNK_SIZE_F32;
use infinigen_common::world::{ChunkPosition, WorldPosition};
use nalgebra::{Matrix4, Vector3};
use nalgebra::{Perspective3, Quaternion, UnitQuaternion};
use nalgebra::{Matrix4, Perspective3, Quaternion, UnitQuaternion, Vector3};
use rustc_hash::FxHashSet;

use crate::settings::{Config, DEFAULT_HORIZONTAL_VIEW_DISTANCE, DEFAULT_VERTICAL_VIEW_DISTANCE};
Expand Down
5 changes: 2 additions & 3 deletions crates/infinigen/src/utils/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use bevy::render::render_resource::PrimitiveTopology;
use infinigen_common::chunks::UnpackedChunk;
use infinigen_common::mesh::faces::prepare_padded_chunk;
use infinigen_common::mesh::shapes::ChunkFace;
use infinigen_common::mesh::{
mesh_chunk_greedy_quads, mesh_chunk_visible_block_faces, textures::TextureMap, MeshInfo,
};
use infinigen_common::mesh::textures::TextureMap;
use infinigen_common::mesh::{mesh_chunk_greedy_quads, mesh_chunk_visible_block_faces, MeshInfo};

use crate::assets::blocks::BlockMappings;

Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"

0 comments on commit a882217

Please sign in to comment.