mirror of
https://github.com/eliasstepanik/voxel-simulation.git
synced 2026-01-10 21:38:29 +00:00
Small Refactor
This commit is contained in:
parent
2d258b02ed
commit
922e99f937
@ -2,13 +2,6 @@ use bevy::prelude::*;
|
||||
use crate::plugins::environment::systems::voxels::structure::{ChunkKey, SparseVoxelOctree, Voxel, CHUNK_POW, CHUNK_SIZE};
|
||||
|
||||
/// Component attached to the entity that owns the mesh of one chunk.
|
||||
#[derive(Component)]
|
||||
pub struct Chunk {
|
||||
pub key: ChunkKey,
|
||||
pub voxels: Vec<(IVec3, Voxel)>, // local coords 0‥15
|
||||
pub dirty: bool,
|
||||
}
|
||||
|
||||
|
||||
impl SparseVoxelOctree {
|
||||
pub fn chunk_has_any_voxel(&self, key: ChunkKey) -> bool {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use bevy::prelude::*;
|
||||
use crate::plugins::environment::systems::voxels::chunk::Chunk;
|
||||
use crate::plugins::environment::systems::voxels::helper::world_to_chunk;
|
||||
use crate::plugins::environment::systems::voxels::structure::{ChunkCullingCfg, ChunkKey, SparseVoxelOctree, SpawnedChunks, CHUNK_SIZE};
|
||||
use crate::plugins::environment::systems::voxels::structure::*;
|
||||
|
||||
|
||||
/// despawn (or hide) every chunk entity whose centre is farther away than the
|
||||
|
||||
@ -5,7 +5,6 @@ use bevy::render::mesh::Mesh;
|
||||
use big_space::prelude::GridCell;
|
||||
use itertools::Itertools;
|
||||
use crate::plugins::big_space::big_space_plugin::RootGrid;
|
||||
use crate::plugins::environment::systems::voxels::chunk::Chunk;
|
||||
use crate::plugins::environment::systems::voxels::meshing::mesh_chunk;
|
||||
use crate::plugins::environment::systems::voxels::structure::*;
|
||||
/// rebuilds meshes only for chunks flagged dirty by the octree
|
||||
|
||||
@ -88,6 +88,14 @@ pub struct AABB {
|
||||
pub const CHUNK_SIZE: i32 = 16; // 16×16×16 voxels
|
||||
pub const CHUNK_POW : u32 = 4;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Chunk {
|
||||
pub key: ChunkKey,
|
||||
pub voxels: Vec<(IVec3, Voxel)>, // local coords 0‥15
|
||||
pub dirty: bool,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||
pub struct ChunkKey(pub i32, pub i32, pub i32);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user