//! 2d line strip, 3d segment mesh, and nd subsimplex mesh. use std::mem; use std::sync::Arc; use na::{self, Point2}; use partitioning::BVT; use bounding_volume::AABB; use shape::{BaseMesh, CompositeShape, Segment, Shape}; use math::{Isometry, Point}; /// Shape commonly known as a 2d line strip or a 3d segment mesh. pub struct Polyline { mesh: BaseMesh, Segment

>, } impl Clone for Polyline

{ fn clone(&self) -> Polyline

{ Polyline { mesh: self.mesh.clone(), } } } impl Polyline

{ /// Builds a new mesh. pub fn new( vertices: Arc>, indices: Arc>>, uvs: Option>>>, normals: Option>>, ) -> Polyline

{ Polyline { mesh: BaseMesh::new(vertices, indices, uvs, normals), } } } impl Polyline

{ /// The base representation of this mesh. #[inline] pub fn base_mesh(&self) -> &BaseMesh, Segment

> { &self.mesh } /// The vertices of this mesh. #[inline] pub fn vertices(&self) -> &Arc> { self.mesh.vertices() } /// Bounding volumes of the subsimplices. #[inline] pub fn bounding_volumes(&self) -> &[AABB

] { self.mesh.bounding_volumes() } /// The indices of this mesh. #[inline] pub fn indices(&self) -> &Arc>> { unsafe { mem::transmute(self.mesh.indices()) } } /// The texture coordinates of this mesh. #[inline] pub fn uvs(&self) -> &Option>>> { self.mesh.uvs() } /// The normals of this mesh. #[inline] pub fn normals(&self) -> &Option>> { self.mesh.normals() } /// The acceleration structure used for efficient collision detection and ray casting. #[inline] pub fn bvt(&self) -> &BVT> { self.mesh.bvt() } } impl Polyline

{ /// Gets the i-th mesh element. #[inline] pub fn segment_at(&self, i: usize) -> Segment

{ self.mesh.element_at(i) } } impl> CompositeShape for Polyline

{ #[inline(always)] fn map_part_at(&self, i: usize, f: &mut FnMut(&M, &Shape)) { let one: M = na::one(); self.map_transformed_part_at(i, &one, f) } #[inline(always)] fn map_transformed_part_at(&self, i: usize, m: &M, f: &mut FnMut(&M, &Shape)) { let element = self.segment_at(i); f(m, &element) } #[inline] fn aabb_at(&self, i: usize) -> AABB

{ self.bounding_volumes()[i].clone() } #[inline] fn bvt(&self) -> &BVT> { self.bvt() } }