-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PointCulling Trait and Iterator cleanup #278
Conversation
@@ -276,19 +301,43 @@ impl<S: BaseFloat> Obb<S> { | |||
} | |||
} | |||
|
|||
impl<S> PointCulling<S> for Obb<S> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Why was this moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the methods have been moved to implement the trait - I hope to understand the question
src/octree/batch_iterator.rs
Outdated
pub enum PointCulling { | ||
Any(), | ||
#[derive(Debug, Clone)] | ||
pub enum GeoFence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be clearer if we name this PointLocation, and what's currently called PointLocation can become PointQuery. GeoFence has a specific meaning: https://en.wikipedia.org/wiki/Geo-fence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, I was running short on names!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
src/octree/batch_iterator.rs
Outdated
}; | ||
iterator.try_for_each(|point: Point| point_stream.push_point_and_callback(point))?; | ||
point_stream.callback() | ||
//todo (catevita) mutable function parallelization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand and/or we need this. In the end, the user calls try_for_each_batch. Are you proposing the callbacks should happen on several threads in parallel? I suspect that's not super useful, since it requires synchronization on the user side again, and I'd prefer to (as a user) e.g. request points in non-overlapping boxes from several threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As told offline, this PR only takes care of implementing the trait, the parallelization follows up next
} | ||
|
||
pub fn points_in_frustum<'a>( | ||
/// Returns the ids of all nodes that cut or are fully contained in 'aabb'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's be consistent with two vs three slashes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was meant to be a minimal doc comment for the method points_in_node, do we use doc comment at all?
S: BaseFloat + Sync + Send, | ||
{ | ||
fn contains(&self, point: &Point3<S>) -> bool; | ||
fn intersects(&self, aabb: &Aabb3<S>) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a TODO here to return Relation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Our formatting convention for TODOs is:
// TODO(username): Do something.
Can you please adjust it everywhere in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supernit: Still not in the format
// TODO(username): Do something.
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I just paid attention to the caps! now it should be finally fixed!
{ | ||
fn contains(&self, point: &Point3<S>) -> bool; | ||
fn intersects(&self, aabb: &Aabb3<S>) -> bool; | ||
fn transform(&self, isometry: &Isometry3<S>) -> Box<PointCulling<S>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably be impl PointCulling, I'd think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this does not work inside a trait, from rfcs
"impl Trait may only be written within the return type of a freestanding or inherent-impl function, not in trait definitions or any non-return type position. "
src/octree/mod.rs
Outdated
|
||
#[derive(Debug, Clone)] | ||
pub struct Frustum<S: BaseFloat> { | ||
pub matrix: Matrix4<S>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remind me why this contains the second matrix? I forgot. Also, the fields probably do not need to be public and I'd have expected this to be in math.rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i moved it in math, the matrix is used by the contains function
// TODO(ksavinash9) update after https://github.com/rustgd/collision-rs/issues/101 is resolved.
pub fn contains<S: BaseFloat>(projection_matrix: &Matrix4<S>, point: &Point3<S>) -> bool {
the issue in collision is not resolved yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove the file .DS_Store
?
Did you actually check the runtime performance with all the new changes?
S: BaseFloat + Sync + Send, | ||
{ | ||
fn contains(&self, point: &Point3<S>) -> bool; | ||
fn intersects(&self, aabb: &Aabb3<S>) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Our formatting convention for TODOs is:
// TODO(username): Do something.
Can you please adjust it everywhere in this PR?
@@ -54,8 +53,8 @@ fn main() { | |||
let num_points = args.num_points; | |||
let point_cloud_client = PointCloudClient::new(&args.locations, OctreeFactory::new()) | |||
.expect("Couldn't create octree client."); | |||
let point_location = PointLocation { | |||
culling: PointCulling::Aabb(Aabb3::new(args.min, args.max)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason to remove the min/max restriction?
Then the whole point of having min/max arguments goes away...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it also was a copy-paste error
global_from_local: None, | ||
}; | ||
let mut batch_iterator = BatchIterator::new(&octree, &all_points, 1_000_000); | ||
let mut num_batches = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: How about having a const variable BATCH_SIZE
, removing num_batches
, and just working on counter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
location: octree::PointLocation::Frustum(frustum_matrix), | ||
global_from_local: None, | ||
}; | ||
self.stream_points_back_to_sink(point_location, &req.octree_id, &ctx, resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems global_from_local
is None
whenever calling self.stream_points_back_to_sink
. How about just passing a location
and constructing the PointQuery
inside stream_points_back_to_sink
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is ok for you i'd like to leave this pieces of code as is, as the grpc server is not intensively used, so if we have to support query with local/global transforms the PointQuery struct is already prepared to support that.
point_viewer_grpc/src/service.rs
Outdated
.iter() | ||
.map(|p| { | ||
let mut v = point_viewer::proto::Color::new(); | ||
v.set_red(f32::from(p.x) / 255.); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using Color::to_f32
to perform the conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it, it adds some lines but the performance seems not to be affected from that
src/math.rs
Outdated
fn transform(&self, isometry: &Isometry3<S>) -> Box<PointCulling<S>>; | ||
} | ||
|
||
// PointCulling for Aabb3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove comment, this is clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/math.rs
Outdated
@@ -150,22 +199,6 @@ impl<'a, S: BaseFloat> Mul<&'a Vector3<S>> for &'a Isometry3<S> { | |||
} | |||
} | |||
|
|||
impl<S: BaseFloat> Into<Decomposed<Vector3<S>, Quaternion<S>>> for Isometry3<S> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why the generics were removed here and instead having an f64
implementation only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this there is indeed some automatic or manual merging gone wrong! I am restoring them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer to move them back exactly where they were before, so they don't show up as diff...
src/math.rs
Outdated
let corner_from = |x, y| { | ||
isometry | ||
.rotation | ||
.rotate_point(Point3::new(x, y, S::from(0.0).unwrap())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Use S::zero()
instead of S:from(0.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/math.rs
Outdated
} | ||
|
||
fn transform(&self, isometry: &Isometry3<S>) -> Box<PointCulling<S>> { | ||
let matrix = Matrix4::from(Decomposed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could nicely make use of the conversion methods between Decomposed
and Isometry3
, which were deleted above...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/octree/batch_iterator.rs
Outdated
for node_id in node_id_iterator { | ||
let point_iterator = self.octree.points_in_node(self.point_location, node_id); | ||
for point in point_iterator { | ||
if let Err(err) = point_stream.push_point_and_callback(point) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just do point_stream.push_point_and_callback(point)?;
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
I did some benchmarking running new: old |
Can you please remove the |
|
||
impl<S> PointCulling<S> for Aabb3<S> | ||
where | ||
S: 'static + BaseFloat + Sync + Send, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we 'static
need for?
S: BaseFloat + Sync + Send, | ||
{ | ||
fn contains(&self, point: &Point3<S>) -> bool; | ||
fn intersects(&self, aabb: &Aabb3<S>) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supernit: Still not in the format
// TODO(username): Do something.
everywhere.
src/math.rs
Outdated
@@ -150,22 +199,6 @@ impl<'a, S: BaseFloat> Mul<&'a Vector3<S>> for &'a Isometry3<S> { | |||
} | |||
} | |||
|
|||
impl<S: BaseFloat> Into<Decomposed<Vector3<S>, Quaternion<S>>> for Isometry3<S> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be clearer to move them back exactly where they were before, so they don't show up as diff...
Indeed it shows up in the list, but it as removed file |
Ah, I see, thanks, I overlooked this... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
|
6e01dbd
to
897ebfd
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@wally-the-cartographer merge |
@gaschler sorry to bother you, Wally seems to be down again, could you help me merging this branch or pointing to the right person that mantains Wally? |
thanks! |
The iterator are splitted on
-iterator that retrieve nodes
-iterator that scan points on a single node
The PointLocation in which the Points that have to be retrieved has been streamlined,
the methods contains and intersects are part of the trait PointCulling.
This works for an Aabb3, Obb, OrientedBeam and Frustum