aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-10-06 11:21:39 +0200
committerCrozet Sébastien <developer@crozet.re>2020-10-06 11:21:39 +0200
commitcf86ee40a199dc84f7b8dd045e57b3a15bca79fb (patch)
tree495bc0d3f6864afdac62384ca609a839911f621d /src
parent8e432b298bd71df7d1b776b77c15713d9bea280e (diff)
downloadrapier-cf86ee40a199dc84f7b8dd045e57b3a15bca79fb.tar.gz
rapier-cf86ee40a199dc84f7b8dd045e57b3a15bca79fb.tar.bz2
rapier-cf86ee40a199dc84f7b8dd045e57b3a15bca79fb.zip
Use the WQuadtree for the exhaustive ray-cast too.
Diffstat (limited to 'src')
-rw-r--r--src/geometry/wquadtree.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/geometry/wquadtree.rs b/src/geometry/wquadtree.rs
index 627ad9a..fe1ba2a 100644
--- a/src/geometry/wquadtree.rs
+++ b/src/geometry/wquadtree.rs
@@ -309,11 +309,9 @@ impl<T: IndexedData> WQuadtree<T> {
// FIXME: implement a visitor pattern to merge intersect_aabb
// and intersect_ray into a single method.
- pub fn intersect_aabb(&self, aabb: &AABB) -> Vec<T> {
- let mut res = Vec::new();
-
+ pub fn intersect_aabb(&self, aabb: &AABB, out: &mut Vec<T>) {
if self.nodes.is_empty() {
- return res;
+ return;
}
// Special case for the root.
@@ -330,7 +328,7 @@ impl<T: IndexedData> WQuadtree<T> {
// We found a leaf!
// Unfortunately, invalid AABBs return a intersection as well.
if let Some(proxy) = self.proxies.get(node.children[ii] as usize) {
- res.push(proxy.data);
+ out.push(proxy.data);
}
} else {
// Internal node, visit the child.
@@ -343,15 +341,11 @@ impl<T: IndexedData> WQuadtree<T> {
}
}
}
-
- res
}
- pub fn cast_ray(&self, ray: &Ray, max_toi: f32) -> Vec<T> {
- let mut res = Vec::new();
-
+ pub fn cast_ray(&self, ray: &Ray, max_toi: f32, out: &mut Vec<T>) {
if self.nodes.is_empty() {
- return res;
+ return;
}
// Special case for the root.
@@ -369,7 +363,7 @@ impl<T: IndexedData> WQuadtree<T> {
// We found a leaf!
// Unfortunately, invalid AABBs return a hit as well.
if let Some(proxy) = self.proxies.get(node.children[ii] as usize) {
- res.push(proxy.data);
+ out.push(proxy.data);
}
} else {
// Internal node, visit the child.
@@ -382,8 +376,6 @@ impl<T: IndexedData> WQuadtree<T> {
}
}
}
-
- res
}
}