Switch to [u32; DIM] instead of Point<u32> for element indices.

This commit is contained in:
Crozet Sébastien
2021-01-20 15:40:00 +01:00
parent e2006599a8
commit 28b7866aee
9 changed files with 46 additions and 42 deletions

View File

@@ -21,7 +21,7 @@ impl Convex {
body: ColliderHandle,
delta: Isometry<f32>,
vertices: Vec<Point<f32>>,
#[cfg(feature = "dim3")] indices: Vec<Point<u32>>,
#[cfg(feature = "dim3")] indices: Vec<[u32; 3]>,
color: Point3<f32>,
window: &mut Window,
) -> Convex {
@@ -35,9 +35,9 @@ impl Convex {
let mut mesh_indices = Vec::new();
for idx in indices {
let i = mesh_vertices.len() as u16;
mesh_vertices.push(vertices[idx.x as usize]);
mesh_vertices.push(vertices[idx.y as usize]);
mesh_vertices.push(vertices[idx.z as usize]);
mesh_vertices.push(vertices[idx[0] as usize]);
mesh_vertices.push(vertices[idx[1] as usize]);
mesh_vertices.push(vertices[idx[2] as usize]);
mesh_indices.push(Point3::new(i, i + 1, i + 2));
}

View File

@@ -55,7 +55,10 @@ impl HeightField {
use std::rc::Rc;
let (vertices, indices) = heightfield.to_trimesh();
let indices = indices.into_iter().map(|i| na::convert(i)).collect();
let indices = indices
.into_iter()
.map(|idx| Point3::new(idx[0] as u16, idx[1] as u16, idx[2] as u16))
.collect();
let mesh = Mesh::new(vertices, indices, None, None, false);
let mut res = HeightField {

View File

@@ -17,12 +17,15 @@ impl Mesh {
pub fn new(
collider: ColliderHandle,
vertices: Vec<Point<f32>>,
indices: Vec<Point3<u32>>,
indices: Vec<[u32; 3]>,
color: Point3<f32>,
window: &mut window::Window,
) -> Mesh {
let vs = vertices;
let is = indices.into_iter().map(na::convert).collect();
let is = indices
.into_iter()
.map(|idx| Point3::new(idx[0] as u16, idx[1] as u16, idx[2] as u16))
.collect();
let mesh;
let gfx;