ncollide3d/transformation/to_trimesh/
heightfield_to_trimesh.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use super::ToTriMesh;
use crate::procedural::TriMesh;
use crate::shape;
use simba::scalar::RealField;

impl<N: RealField + Copy> ToTriMesh<N> for shape::HeightField<N> {
    type DiscretizationParameter = ();

    fn to_trimesh(&self, _: ()) -> TriMesh<N> {
        let mut vertices = Vec::new();

        for tri in self.triangles() {
            vertices.push(tri.a);
            vertices.push(tri.b);
            vertices.push(tri.c);
        }

        TriMesh::new(vertices, None, None, None)
    }
}