pub struct DynamicNavmeshState { /* private fields */ }Expand description
Mutable availability overlay on a validated base Navmesh.
The base geometry is immutable. Disabled cells and portals form a subtractive
overlay: Self::materialize emits a static Navmesh containing only enabled
cells and portals (with remapped indices). This is not mesh carving or
in-place prepared repair.
§Prepared staleness
Every successful Self::apply_update sets Self::prepared_stale. Callers that
hold a PreparedNavmesh built from a prior snapshot must discard it and rebuild
from a fresh materialization. Staleness clears only when a rebuild-backed helper
(for example DynamicPreparedNavmeshQuery::run) marks the state rebuilt—not
merely from calling Self::materialize.
Implementations§
Sourcepub fn new(base: Navmesh) -> Result<DynamicNavmeshState, DynamicNavmeshError>
pub fn new(base: Navmesh) -> Result<DynamicNavmeshState, DynamicNavmeshError>
Validates base (non-empty, passes Navmesh::validate) with all cells/portals enabled.
§Errors
Returns DynamicNavmeshError when the base is empty or invalid.
Sourcepub fn with_disabled_availability(
base: Navmesh,
disabled_cells: impl IntoIterator<Item = String>,
disabled_portals: impl IntoIterator<Item = DynamicNavmeshPortalKey>,
) -> Result<DynamicNavmeshState, DynamicNavmeshError>
pub fn with_disabled_availability( base: Navmesh, disabled_cells: impl IntoIterator<Item = String>, disabled_portals: impl IntoIterator<Item = DynamicNavmeshPortalKey>, ) -> Result<DynamicNavmeshState, DynamicNavmeshError>
Like Self::new, then seeds the disabled cell and portal sets without marking stale.
Use for fixture restore and cold start. Subsequent Self::apply_update calls still
mark prepared data stale as usual.
§Errors
Returns DynamicNavmeshError when the base is invalid or a disabled id is unknown.
Sourcepub fn base(&self) -> &Navmesh
pub fn base(&self) -> &Navmesh
Immutable base geometry (full cell/portal set, ignoring availability).
Sourcepub fn disabled_cells(&self) -> &BTreeSet<String>
pub fn disabled_cells(&self) -> &BTreeSet<String>
Stable cell ids currently excluded from materialization.
Sourcepub fn disabled_portals(&self) -> &BTreeSet<DynamicNavmeshPortalKey>
pub fn disabled_portals(&self) -> &BTreeSet<DynamicNavmeshPortalKey>
Portal keys currently excluded from materialization.
Sourcepub fn prepared_stale(&self) -> bool
pub fn prepared_stale(&self) -> bool
Whether any availability change has not yet been followed by a prepared rebuild.
When true, any prepared snapshot derived before the last update must not be trusted.
Sourcepub fn apply_update(
&mut self,
update: &DynamicNavmeshUpdate,
) -> Result<(), DynamicNavmeshError>
pub fn apply_update( &mut self, update: &DynamicNavmeshUpdate, ) -> Result<(), DynamicNavmeshError>
Applies one cell or portal availability change and marks prepared data stale.
Disabling a cell drops it from the next materialization. Disabling a portal drops connectivity between the two cell ids while leaving both cells present when enabled.
§Errors
Returns DynamicNavmeshError when an update references an unknown cell
or portal.
Sourcepub fn materialize(&self) -> Result<Navmesh, DynamicNavmeshError>
pub fn materialize(&self) -> Result<Navmesh, DynamicNavmeshError>
Builds a static Navmesh snapshot of currently enabled cells and portals.
Survivor cells keep their geometry and stable cell_ids but receive new dense
indices. Portals between two surviving enabled cells are remapped; portals that
touch a disabled cell or sit in the disabled-portal set are dropped. Does not
clear Self::prepared_stale—callers must rebuild prepared structures separately.
If every cell is disabled, the snapshot is empty and queries return
NavmeshQueryResult::InvalidStart.
§Errors
Returns DynamicNavmeshError if the enabled subset does not form a
valid navmesh.
Trait Implementations§
Source§fn clone(&self) -> DynamicNavmeshState
fn clone(&self) -> DynamicNavmeshState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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