Skip to content

Commit 6ee4a6e

Browse files
committed
Remove Mesh methods that panic
1 parent ec6affc commit 6ee4a6e

File tree

21 files changed

+233
-1080
lines changed

21 files changed

+233
-1080
lines changed

crates/bevy_gltf/src/loader/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use async_lock::RwLock;
66
#[cfg(feature = "bevy_animation")]
77
use bevy_animation::{prelude::*, AnimatedBy, AnimationTargetId};
88
use bevy_asset::{
9-
io::Reader, AssetLoadError, AssetLoader, AssetPath, Handle, LoadContext, ParseAssetPathError,
10-
ReadAssetBytesError, RenderAssetUsages,
9+
io::Reader, AssetLoadError, AssetLoader, AssetPath, ExtractableAsset, Handle, LoadContext,
10+
ParseAssetPathError, ReadAssetBytesError, RenderAssetUsages,
1111
};
1212
use bevy_camera::{
1313
primitives::Aabb, visibility::Visibility, Camera, Camera3d, OrthographicProjection,
@@ -691,8 +691,8 @@ impl GltfLoader {
691691
};
692692
let primitive_topology = primitive_topology(primitive.mode())?;
693693

694-
let mut mesh = Mesh::new(primitive_topology, settings.load_meshes);
695-
694+
let mut mesh_asset = Mesh::new(primitive_topology, settings.load_meshes);
695+
let mesh = mesh_asset.extractable_data_mut().unwrap();
696696
// Read vertex attributes
697697
for (semantic, accessor) in primitive.attributes() {
698698
if [Semantic::Joints(0), Semantic::Weights(0)].contains(&semantic) {
@@ -801,7 +801,8 @@ impl GltfLoader {
801801
});
802802
}
803803

804-
let mesh_handle = load_context.add_labeled_asset(primitive_label.to_string(), mesh);
804+
let mesh_handle =
805+
load_context.add_labeled_asset(primitive_label.to_string(), mesh_asset);
805806
primitives.push(super::GltfPrimitive::new(
806807
&gltf_mesh,
807808
&primitive,

0 commit comments

Comments
 (0)