Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ use bevy_app::prelude::*;
use bevy_asset::AssetApp;
use bevy_ecs::prelude::Resource;
use bevy_image::{CompressedImageFormatSupport, CompressedImageFormats, ImageSamplerDescriptor};
use bevy_mesh::{MeshAttributeCompressionFlags, MeshVertexAttribute};
use bevy_mesh::{MeshCompressionArgs, MeshVertexAttribute};

/// The glTF prelude.
///
Expand Down Expand Up @@ -235,11 +235,8 @@ pub struct GltfPlugin {
/// [`GltfLoaderSettings::skinned_mesh_bounds_policy`].
pub skinned_mesh_bounds_policy: GltfSkinnedMeshBoundsPolicy,

/// Mesh attribute compression flags for the loaded meshes.
pub mesh_attribute_compression: MeshAttributeCompressionFlags,

/// Whether to convert mesh indices to u16 if vertex count <= 65535 and indices are u32.
pub mesh_index_compression: bool,
/// Mesh attribute compression arguments applied when loading meshes.
pub mesh_compression: MeshCompressionArgs,
}

impl Default for GltfPlugin {
Expand All @@ -249,8 +246,7 @@ impl Default for GltfPlugin {
custom_vertex_attributes: HashMap::default(),
convert_coordinates: GltfConvertCoordinates::default(),
skinned_mesh_bounds_policy: Default::default(),
mesh_attribute_compression: MeshAttributeCompressionFlags::empty(),
mesh_index_compression: false,
mesh_compression: MeshCompressionArgs::none(),
}
}
}
Expand Down Expand Up @@ -307,8 +303,7 @@ impl Plugin for GltfPlugin {
default_convert_coordinates: self.convert_coordinates,
extensions: extensions.0.clone(),
default_skinned_mesh_bounds_policy: self.skinned_mesh_bounds_policy,
default_mesh_attribute_compression: self.mesh_attribute_compression,
default_mesh_index_compression: self.mesh_index_compression,
default_mesh_compression: self.mesh_compression.clone(),
});
}
}
26 changes: 9 additions & 17 deletions crates/bevy_gltf/src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use bevy_mesh::UvChannel;
use bevy_mesh::{
morph::{MeshMorphWeights, MorphAttributes, MorphWeights},
skinning::{SkinnedMesh, SkinnedMeshInverseBindposes},
Indices, Mesh, Mesh3d, MeshAttributeCompressionFlags, MeshVertexAttribute, PrimitiveTopology,
Indices, Mesh, Mesh3d, MeshCompressionArgs, MeshVertexAttribute, PrimitiveTopology,
};
use bevy_platform::collections::{HashMap, HashSet};
use bevy_reflect::TypePath;
Expand Down Expand Up @@ -162,10 +162,8 @@ pub struct GltfLoader {
/// The default policy for skinned mesh bounds. Can be overridden by
/// [`GltfLoaderSettings::skinned_mesh_bounds_policy`].
pub default_skinned_mesh_bounds_policy: GltfSkinnedMeshBoundsPolicy,
/// Default Mesh attribute compression flags for the loaded meshes.
pub default_mesh_attribute_compression: MeshAttributeCompressionFlags,
/// Whether to convert mesh indices to u16 if vertex count <= 65535 and indices are u32.
pub default_mesh_index_compression: bool,
/// Default mesh compression arguments for the loaded meshes.
pub default_mesh_compression: MeshCompressionArgs,
}

/// Specifies optional settings for processing gltfs at load time. By default, all recognized contents of
Expand Down Expand Up @@ -220,11 +218,8 @@ pub struct GltfLoaderSettings {
/// Optionally overrides [`GltfPlugin::skinned_mesh_bounds_policy`](crate::GltfPlugin).
pub skinned_mesh_bounds_policy: Option<GltfSkinnedMeshBoundsPolicy>,
/// Mesh attribute compression flags for the loaded meshes.
/// If `None`, uses the global default set by [`GltfPlugin::mesh_attribute_compression`](crate::GltfPlugin::mesh_attribute_compression).
pub mesh_attribute_compression: Option<MeshAttributeCompressionFlags>,
/// Whether to convert mesh indices to u16 if vertex count <= 65535 and indices are u32.
/// If `None`, uses the global default set by [`GltfPlugin::mesh_index_compression`](crate::GltfPlugin::mesh_index_compression).
pub mesh_index_compression: Option<bool>,
/// If `None`, uses the global default set by [`GltfPlugin::mesh_compression`](crate::GltfPlugin::mesh_compression).
pub mesh_compression: Option<MeshCompressionArgs>,
}

impl Default for GltfLoaderSettings {
Expand All @@ -241,8 +236,7 @@ impl Default for GltfLoaderSettings {
validate: true,
convert_coordinates: None,
skinned_mesh_bounds_policy: None,
mesh_attribute_compression: None,
mesh_index_compression: None,
mesh_compression: None,
}
}
}
Expand Down Expand Up @@ -878,11 +872,9 @@ impl GltfLoader {
primitive_label.to_string(),
mesh.compressed_mesh(
settings
.mesh_attribute_compression
.unwrap_or(loader.default_mesh_attribute_compression),
settings
.mesh_index_compression
.unwrap_or(loader.default_mesh_index_compression),
.mesh_compression
.clone()
.unwrap_or(loader.default_mesh_compression.clone()),
),
);
primitives.push(super::GltfPrimitive::new(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mesh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bevy_platform = { path = "../bevy_platform", version = "0.19.0-dev", default-fea

# other
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5" }
bytemuck = { version = "1.5", features = ["must_cast"] }
Comment thread
beicause marked this conversation as resolved.
wgpu-types = { version = "29.0.3", default-features = false }
serde = { version = "1", default-features = false, features = [
"derive",
Expand Down
Loading
Loading