Small Refactor

This commit is contained in:
Elias Stepanik 2025-06-07 18:48:40 +02:00
parent 2d258b02ed
commit 922e99f937
4 changed files with 9 additions and 10 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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);