mirror of https://codeberg.org/topola/topola.git
chore(planar-incr-embed): provide `remove_path` also for plain `edge_paths`
This commit is contained in:
parent
573f49f56f
commit
792f9b56ea
|
|
@ -222,6 +222,23 @@ pub(crate) fn resolve_edge_data<PNI: Ord, EP>(
|
||||||
Some((data, ret))
|
Some((data, ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Removes a path (weak or normal) with the given label from the navmesh
|
||||||
|
pub fn remove_path<EP, GC>(edge_paths: &mut [EdgePaths<EP, GC>], label: &RelaxedPath<EP, GC>)
|
||||||
|
where
|
||||||
|
EP: Clone + Eq,
|
||||||
|
GC: Clone + PartialEq,
|
||||||
|
{
|
||||||
|
let mut updated_indices = Vec::new();
|
||||||
|
for i in edge_paths {
|
||||||
|
updated_indices.clear();
|
||||||
|
updated_indices.extend(i[..].iter().filter(|&j| j != label).cloned());
|
||||||
|
|
||||||
|
if updated_indices.len() != i.len() {
|
||||||
|
*i = take(&mut updated_indices).into_boxed_slice().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, B: NavmeshBase + 'a> NavmeshRefMut<'a, B> {
|
impl<'a, B: NavmeshBase + 'a> NavmeshRefMut<'a, B> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn as_ref(&'a self) -> NavmeshRef<'a, B> {
|
pub fn as_ref(&'a self) -> NavmeshRef<'a, B> {
|
||||||
|
|
@ -264,15 +281,7 @@ impl<'a, B: NavmeshBase + 'a> NavmeshRefMut<'a, B> {
|
||||||
where
|
where
|
||||||
B::GapComment: PartialEq,
|
B::GapComment: PartialEq,
|
||||||
{
|
{
|
||||||
let mut updated_indices = Vec::new();
|
remove_path(&mut self.edge_paths[..], label);
|
||||||
for i in &mut *self.edge_paths {
|
|
||||||
updated_indices.clear();
|
|
||||||
updated_indices.extend(i[..].iter().filter(|&j| j != label).cloned());
|
|
||||||
|
|
||||||
if updated_indices.len() != i.len() {
|
|
||||||
*i = take(&mut updated_indices).into_boxed_slice().into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue