use na::{Transform, Identity}; use na; use point::PointQuery; use entities::shape::{BaseMesh, BaseMeshElement, TriMesh, Polyline}; use entities::bounding_volume::AABB; use entities::partitioning::{BVTCostFn, BVTVisitor}; use math::{Point, Vector}; impl
PointQuery
for BaseMesh
where P: Point, M: Transform
, E: BaseMeshElement + PointQuery
{
#[inline]
fn project_point(&self, m: &M, point: &P, _: bool) -> P {
let ls_pt = m.inverse_transform(point);
let mut cost_fn = BaseMeshPointProjCostFn { mesh: self, point: &ls_pt };
m.transform(&self.bvt().best_first_search(&mut cost_fn).unwrap().1)
}
#[inline]
fn distance_to_point(&self, m: &M, point: &P) -> ,
point: &'a P
}
impl<'a, P, I, E> BVTCostFn< > for BaseMeshPointProjCostFn<'a, P, I, E>
where P: Point,
E: BaseMeshElement + PointQuery {
type UserData = P;
#[inline]
fn compute_bv_cost(&mut self, aabb: &AABB ) -> Option< ,
point: &'a P,
found: bool
}
impl<'a, P, I, E> BVTVisitor {
#[inline]
fn visit_internal(&mut self, bv: &AABB ) -> bool {
!self.found && bv.contains_point(&Identity::new(), self.point)
}
#[inline]
fn visit_leaf(&mut self, b: &usize, bv: &AABB ) {
if !self.found &&
bv.contains_point(&Identity::new(), self.point) &&
self.mesh.element_at(*b).contains_point(&Identity::new(), self.point) {
self.found = true;
}
}
}
/*
* fwd impls to exact meshes.
*/
impl PointQuery for TriMesh
where P: Point,
M: Transform {
#[inline]
fn project_point(&self, m: &M, point: &P, solid: bool) -> P {
self.base_mesh().project_point(m, point, solid)
}
#[inline]
fn distance_to_point(&self, m: &M, point: &P) -> PointQuery for Polyline
where P: Point,
M: Transform {
#[inline]
fn project_point(&self, m: &M, point: &P, solid: bool) -> P {
self.base_mesh().project_point(m, point, solid)
}
#[inline]
fn distance_to_point(&self, m: &M, point: &P) ->