type safe enough
This commit is contained in:
@@ -206,9 +206,9 @@ impl GraphicsState{
|
||||
if (u32::MAX as usize)<vertices.len(){
|
||||
panic!("Model has too many vertices!");
|
||||
}else if (u16::MAX as usize)<vertices.len(){
|
||||
Indices::new(device,&$indices.into_iter().map(|vertex_idx|vertex_idx as u32).collect(),wgpu::IndexFormat::Uint32)
|
||||
Indices::new(device,&$indices.into_iter().map(|vertex_idx|vertex_idx.get() as u32).collect(),wgpu::IndexFormat::Uint32)
|
||||
}else{
|
||||
Indices::new(device,&$indices.into_iter().map(|vertex_idx|vertex_idx as u16).collect(),wgpu::IndexFormat::Uint16)
|
||||
Indices::new(device,&$indices.into_iter().map(|vertex_idx|vertex_idx.get() as u16).collect(),wgpu::IndexFormat::Uint16)
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -236,7 +236,7 @@ impl GraphicsState{
|
||||
};
|
||||
|
||||
DebugGraphicsMesh{
|
||||
verts:indices!(0..vertices.len()),
|
||||
verts:indices!((0..vertices.len() as u32).map(strafesnet_physics::model::MeshVertId::new)),
|
||||
submeshes,
|
||||
vertex_buf,
|
||||
}
|
||||
|
||||
@@ -448,16 +448,16 @@ impl PhysicsMeshView<'_>{
|
||||
pub fn verts(&self)->&[MeshVertId]{
|
||||
&self.topology.verts
|
||||
}
|
||||
pub fn edge_vert_ids_iter(&self)->impl Iterator<Item=[u32;2]>+'_{
|
||||
pub fn edge_vert_ids_iter(&self)->impl Iterator<Item=[MeshVertId;2]>+'_{
|
||||
self.topology.edge_topology.iter().map(|edge|{
|
||||
edge.verts.map(|vert_id|self.topology.verts[vert_id.get() as usize].get())
|
||||
edge.verts.map(|vert_id|self.topology.verts[vert_id.get() as usize])
|
||||
})
|
||||
}
|
||||
pub fn face_vert_ids_iter(&self)->impl Iterator<Item=impl Iterator<Item=u32>>+'_{
|
||||
pub fn face_vert_ids_iter(&self)->impl Iterator<Item=impl Iterator<Item=MeshVertId>>+'_{
|
||||
self.topology.face_topology.iter().map(|face|{
|
||||
face.edges.iter().map(|edge_id|{
|
||||
let vert_id=self.topology.edge_topology[edge_id.as_undirected().get() as usize].verts[edge_id.parity() as usize];
|
||||
self.topology.verts[vert_id.get() as usize].get()
|
||||
self.topology.verts[vert_id.get() as usize]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user