use crate::client::render::voxel::VoxelColor; use bevy_ecs::{bundle::Bundle, component::Component}; use ndarray::{Array3, ArrayBase, Dim, SliceArg}; use std::ops::Range; use super::{Orientation, Pos}; pub type VoxelGrid = TrackedGrid; pub type GridRegion = (Range, Range, Range); #[derive(Debug, Clone, Component)] pub struct TrackedGrid { data: Array3, changes: Vec, } impl TrackedGrid { pub fn new(data: Array3) -> Self { Self { data, changes: Vec::new(), } } pub fn view_slice_mut>>( &mut self, slice: I, ) -> ArrayBase, >>::OutDim> { self.data.slice_mut(slice) } pub fn take_changes(&mut self) -> Vec { std::mem::take(&mut self.changes) } } impl std::ops::Deref for TrackedGrid { type Target = Array3; fn deref(&self) -> &Self::Target { &self.data } } #[derive(Bundle, Clone)] pub struct VoxelGridBundle { pub pos: Pos, pub orientation: Orientation, pub grid: VoxelGrid, }