fixed compile time errors; still runtime error inside mesh.render
This commit is contained in:
@ -24,7 +24,7 @@ impl OctaSphere {
|
||||
pub fn render(&mut self, gl: &Context) {
|
||||
match self.mesh.as_mut() {
|
||||
None => {self.generate_sphere(); self.render(gl)},
|
||||
Some(mut mesh) => {mesh.render(gl)}
|
||||
Some(mesh) => {mesh.render(gl)}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ impl OctaSphereGenerator {
|
||||
vertices.extend_from_slice(&base_vertices);
|
||||
|
||||
// Create 12 edges, with n vertices added along them (n = numDivisions)
|
||||
let mut edges = Vec::<Edge>::with_capacity(12);
|
||||
let mut edges: [Edge; 12] = Default::default();
|
||||
for i in (0..vertex_pairs.len()).step_by(2) {
|
||||
let start_vertex = vertices[vertex_pairs[i]];
|
||||
let end_vertex = vertices[vertex_pairs[i + 1]];
|
||||
|
||||
let mut edge_vertex_indices = Vec::<u32>::with_capacity((num_divisions + 2) as usize);
|
||||
let mut edge_vertex_indices = vec![0;(num_divisions + 2) as usize];
|
||||
edge_vertex_indices[0] = vertex_pairs[i] as u32;
|
||||
|
||||
// Add vertices along edge
|
||||
@ -156,6 +156,7 @@ impl OctaSphereGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Edge {
|
||||
vertex_indices: Vec<u32>,
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ impl Mesh {
|
||||
Self {
|
||||
vertices,
|
||||
indices,
|
||||
normals: Vec::with_capacity(num_vertices),
|
||||
normals: vec![Vector3::default();num_vertices],
|
||||
vao: None,
|
||||
vbo: None,
|
||||
ebo: None,
|
||||
|
Reference in New Issue
Block a user