Skip to content

Commit

Permalink
fix bounds and normals
Browse files Browse the repository at this point in the history
  • Loading branch information
DotWith committed Aug 18, 2024
1 parent 6227164 commit ea796a2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bevy_rmesh/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ async fn load_rmesh<'a, 'b, 'c>(
.collect();
mesh.insert_attribute(Mesh::ATTRIBUTE_UV_1, lightmaps_uvs);

let normals = complex_mesh.calculate_normals();
mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals);

let indices = complex_mesh
.triangles
.iter()
.flat_map(|strip| strip.iter().rev().copied())
.collect();
mesh.insert_indices(Indices::U32(indices));

mesh.duplicate_vertices();
mesh.compute_flat_normals();

let mesh = load_context.add_labeled_asset(format!("Mesh{0}", i), mesh);

// TODO: double_sided and crap
Expand Down Expand Up @@ -177,12 +177,11 @@ async fn load_rmesh<'a, 'b, 'c>(
..Default::default()
});
let complex_mesh = &header.meshes[i];
if let Some((min, max)) = rmesh::calculate_bounds(&complex_mesh.vertices) {
mesh_entity.insert(Aabb::from_min_max(
Vec3::from_slice(&min),
Vec3::from_slice(&max),
));
}
let bounds = rmesh::bounding_box(&complex_mesh.vertices);
mesh_entity.insert(Aabb::from_min_max(
Vec3::from_slice(&bounds.min),
Vec3::from_slice(&bounds.max),
));
}
for entity in header.entities {
if let Some(entity_type) = entity.entity_type {
Expand Down

0 comments on commit ea796a2

Please sign in to comment.