fixed compile time errors; still runtime error inside mesh.render

This commit is contained in:
2025-08-28 20:50:24 +02:00
parent b24be88bdc
commit db4a38ec03
2 changed files with 5 additions and 4 deletions

View File

@ -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>,
}

View File

@ -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,