fix "unused" warnings when compiling with render
feature but without animation
(#4714)
# Objective When running `cargo check --no-default-features --features render` I get ```rust warning: unused import: `Quat` --> crates/bevy_gltf/src/loader.rs:11:23 | 11 | use bevy_math::{Mat4, Quat, Vec3}; | ^^^^ | = note: `#[warn(unused_imports)]` on by default warning: function is never used: `paths_recur` --> crates/bevy_gltf/src/loader.rs:542:4 | 542 | fn paths_recur( | ^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default ``` ## Solution Put these items behind `#[cfg(feature = "animation")]`.
This commit is contained in:
parent
aced6aff04
commit
e503a31048
@ -1,6 +1,4 @@
|
||||
use anyhow::Result;
|
||||
#[cfg(feature = "bevy_animation")]
|
||||
use bevy_animation::{AnimationClip, AnimationPlayer, EntityPath, Keyframes, VariableCurve};
|
||||
use bevy_asset::{
|
||||
AssetIoError, AssetLoader, AssetPath, BoxedFuture, Handle, LoadContext, LoadedAsset,
|
||||
};
|
||||
@ -8,7 +6,7 @@ use bevy_core::Name;
|
||||
use bevy_ecs::{entity::Entity, prelude::FromWorld, world::World};
|
||||
use bevy_hierarchy::{BuildWorldChildren, WorldChildBuilder};
|
||||
use bevy_log::warn;
|
||||
use bevy_math::{Mat4, Quat, Vec3};
|
||||
use bevy_math::{Mat4, Vec3};
|
||||
use bevy_pbr::{
|
||||
AlphaMode, DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle,
|
||||
StandardMaterial,
|
||||
@ -150,7 +148,7 @@ async fn load_gltf<'a, 'b>(
|
||||
let mut named_animations = HashMap::default();
|
||||
let mut animation_roots = HashSet::default();
|
||||
for animation in gltf.animations() {
|
||||
let mut animation_clip = AnimationClip::default();
|
||||
let mut animation_clip = bevy_animation::AnimationClip::default();
|
||||
for channel in animation.channels() {
|
||||
match channel.sampler().interpolation() {
|
||||
gltf::animation::Interpolation::Linear => (),
|
||||
@ -177,13 +175,15 @@ async fn load_gltf<'a, 'b>(
|
||||
let keyframes = if let Some(outputs) = reader.read_outputs() {
|
||||
match outputs {
|
||||
gltf::animation::util::ReadOutputs::Translations(tr) => {
|
||||
Keyframes::Translation(tr.map(Vec3::from).collect())
|
||||
bevy_animation::Keyframes::Translation(tr.map(Vec3::from).collect())
|
||||
}
|
||||
gltf::animation::util::ReadOutputs::Rotations(rots) => {
|
||||
Keyframes::Rotation(rots.into_f32().map(Quat::from_array).collect())
|
||||
bevy_animation::Keyframes::Rotation(
|
||||
rots.into_f32().map(bevy_math::Quat::from_array).collect(),
|
||||
)
|
||||
}
|
||||
gltf::animation::util::ReadOutputs::Scales(scale) => {
|
||||
Keyframes::Scale(scale.map(Vec3::from).collect())
|
||||
bevy_animation::Keyframes::Scale(scale.map(Vec3::from).collect())
|
||||
}
|
||||
gltf::animation::util::ReadOutputs::MorphTargetWeights(_) => {
|
||||
warn!("Morph animation property not yet supported");
|
||||
@ -198,10 +198,10 @@ async fn load_gltf<'a, 'b>(
|
||||
if let Some((root_index, path)) = paths.get(&node.index()) {
|
||||
animation_roots.insert(root_index);
|
||||
animation_clip.add_curve_to_path(
|
||||
EntityPath {
|
||||
bevy_animation::EntityPath {
|
||||
parts: path.clone(),
|
||||
},
|
||||
VariableCurve {
|
||||
bevy_animation::VariableCurve {
|
||||
keyframe_timestamps,
|
||||
keyframes,
|
||||
},
|
||||
@ -481,7 +481,7 @@ async fn load_gltf<'a, 'b>(
|
||||
if animation_roots.contains(&node.index()) {
|
||||
world
|
||||
.entity_mut(*node_index_to_entity_map.get(&node.index()).unwrap())
|
||||
.insert(AnimationPlayer::default());
|
||||
.insert(bevy_animation::AnimationPlayer::default());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -539,6 +539,7 @@ fn node_name(node: &Node) -> Name {
|
||||
Name::new(name)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bevy_animation")]
|
||||
fn paths_recur(
|
||||
node: Node,
|
||||
current_path: &[Name],
|
||||
|
Loading…
Reference in New Issue
Block a user