Skip to content

Commit

Permalink
Tweak inline and visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Oom committed Jul 12, 2024
1 parent c230961 commit 2f93f8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions kdtree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl KdNode {
Box::new(Self::Node { plane, left, right })
}

#[inline]
pub fn is_empty(&self) -> bool {
match self {
Self::Leaf(indices) => indices.is_empty(),
Expand Down Expand Up @@ -165,19 +166,22 @@ pub struct KdTree {
}

impl KdTree {
#[inline]
pub fn iter_nodes(&self) -> KdTreeNodeIter<'_> {
KdTreeNodeIter {
stack: vec![(1, &self.root)],
}
}

#[inline]
pub fn iter_leafs(&self) -> impl Iterator<Item = (usize, &Vec<u32>)> {
self.iter_nodes().filter_map(|(depth, node)| match node {
KdNode::Leaf(indices) => Some((depth, indices)),
_ => None,
})
}

#[inline]
pub fn intersect(
&self,
ray: &Ray,
Expand Down
10 changes: 7 additions & 3 deletions kdtree/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn clip_geometries(geometries: &[Geometry], cell: &KdCell) -> Vec<(u3
.collect::<Vec<_>>()
}

pub fn partition_triangles(
pub(crate) fn partition_triangles(
clipped_triangles: &[(u32, Aabb)],
plane: &Aap,
) -> (Vec<u32>, Vec<u32>, Vec<u32>) {
Expand All @@ -42,15 +42,19 @@ pub fn partition_triangles(
(left_triangles, middle_triangles, right_triangles)
}

pub struct SplitPartitioning {
pub(crate) struct SplitPartitioning {
pub left_aabb: Aabb,
pub right_aabb: Aabb,
pub left_indices: Vec<u32>,
pub middle_indices: Vec<u32>,
pub right_indices: Vec<u32>,
}

pub fn split_and_partition(clipped: &[(u32, Aabb)], aabb: &Aabb, plane: Aap) -> SplitPartitioning {
pub(crate) fn split_and_partition(
clipped: &[(u32, Aabb)],
aabb: &Aabb,
plane: Aap,
) -> SplitPartitioning {
let (left_aabb, right_aabb) = aabb.split(&plane);
let (left_indices, middle_indices, right_indices) = partition_triangles(clipped, &plane);
SplitPartitioning {
Expand Down

0 comments on commit 2f93f8d

Please sign in to comment.