Skip to main content

Island

Struct Island 

Source
pub struct Island {
    pub voxels: Vec<(IVec3, VoxColor)>,
    pub bbox: (IVec3, IVec3),
}
Expand description

One detached voxel region: everything a caller needs to extract it from the grid and hand it to a debris system.

Fields§

§voxels: Vec<(IVec3, VoxColor)>

Every solid voxel of the component, grid-local coordinates plus the colour it had at detection time (untextured interior cells inherit the nearest colour above them in the column).

§bbox: (IVec3, IVec3)

Inclusive grid-local bounds of voxels.

Implementations§

Source§

impl Island

Source

pub fn extract(&self, grid: &mut Grid, bake: BakeMode)

DT.1 — carve this island’s voxels out of grid, then re-bake the touched region so lighting on the newly exposed faces is correct: one Grid::set_rect carve per contiguous column segment (the voxel list is stored run-major, so coalescing is a single pass) and one Grid::bake_bbox over the island bbox (its internal padding relights the surroundings; the edits and the bake bump the touched chunk versions). After extraction, a re-run of detect_islands over the same region finds nothing.

Mip ladders are NOT regenerated — the same contract as every edit primitive (Grid::bake_bbox documents it too): a caller rendering distant chunks must remip the touched columns (Vxl::remip_bbox) exactly as it already does for its carves, or mip-N keeps drawing the extracted island beyond mip_scan_dist while its sprite twin falls next to it.

Source

pub fn to_kv6(&self) -> Kv6

DT.1 — build the island’s KV6 sprite model: dims are the inclusive bbox extent, voxels sit at bbox-relative positions, and colours are the detected ones with the high byte normalised to 0x80 (full-bright — the sprite paths do their own lighting, and a baked brightness byte would double-darken). Surface-only (Kv6::from_fn): the interior is invisible in flight, and a shatter samples Self::voxels, not the model. The model pivot is the bbox centre (from_fn’s convention) — pose it with Self::world_pivot.

Source

pub fn world_origin(&self, transform: &GridTransform) -> DVec3

DT.1 — the world-space position of the island’s minimum corner (bbox.0, voxel corner), through the grid transform with voxel_world_size honoured (SC).

Source

pub fn world_pivot(&self, transform: &GridTransform) -> DVec3

DT.1 — the world-space position of the island’s bbox centre — where Self::to_kv6’s pivot sits, i.e. the position a debris system spawns the sprite instance at so the model lands exactly over the voxels it replaced.

Source§

impl Island

Source

pub fn split(&self, pattern: FracturePattern, seed: u64) -> Vec<Island>

DT.5 — partition this island into fragments per pattern: a disjoint cover of the original voxels (colours ride along), each fragment with a recomputed bbox, deterministic in (island, pattern, seed). FracturePattern::Whole returns the island unsplit; degenerate cases (an island smaller than a cell, all sites in one plate) collapse gracefully to fewer fragments. A fragment may be internally disconnected (a Voronoi cell straddling a concave gap) — it falls as one piece (accepted v1 simplification).

Trait Implementations§

Source§

impl Clone for Island

Source§

fn clone(&self) -> Island

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Island

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.