Skip to content

Commit e503a31

Browse files
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")]`.
1 parent aced6af commit e503a31

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

crates/bevy_gltf/src/loader.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use anyhow::Result;
2-
#[cfg(feature = "bevy_animation")]
3-
use bevy_animation::{AnimationClip, AnimationPlayer, EntityPath, Keyframes, VariableCurve};
42
use bevy_asset::{
53
AssetIoError, AssetLoader, AssetPath, BoxedFuture, Handle, LoadContext, LoadedAsset,
64
};
75
use bevy_core::Name;
86
use bevy_ecs::{entity::Entity, prelude::FromWorld, world::World};
97
use bevy_hierarchy::{BuildWorldChildren, WorldChildBuilder};
108
use bevy_log::warn;
11-
use bevy_math::{Mat4, Quat, Vec3};
9+
use bevy_math::{Mat4, Vec3};
1210
use bevy_pbr::{
1311
AlphaMode, DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle,
1412
StandardMaterial,
@@ -150,7 +148,7 @@ async fn load_gltf<'a, 'b>(
150148
let mut named_animations = HashMap::default();
151149
let mut animation_roots = HashSet::default();
152150
for animation in gltf.animations() {
153-
let mut animation_clip = AnimationClip::default();
151+
let mut animation_clip = bevy_animation::AnimationClip::default();
154152
for channel in animation.channels() {
155153
match channel.sampler().interpolation() {
156154
gltf::animation::Interpolation::Linear => (),
@@ -177,13 +175,15 @@ async fn load_gltf<'a, 'b>(
177175
let keyframes = if let Some(outputs) = reader.read_outputs() {
178176
match outputs {
179177
gltf::animation::util::ReadOutputs::Translations(tr) => {
180-
Keyframes::Translation(tr.map(Vec3::from).collect())
178+
bevy_animation::Keyframes::Translation(tr.map(Vec3::from).collect())
181179
}
182180
gltf::animation::util::ReadOutputs::Rotations(rots) => {
183-
Keyframes::Rotation(rots.into_f32().map(Quat::from_array).collect())
181+
bevy_animation::Keyframes::Rotation(
182+
rots.into_f32().map(bevy_math::Quat::from_array).collect(),
183+
)
184184
}
185185
gltf::animation::util::ReadOutputs::Scales(scale) => {
186-
Keyframes::Scale(scale.map(Vec3::from).collect())
186+
bevy_animation::Keyframes::Scale(scale.map(Vec3::from).collect())
187187
}
188188
gltf::animation::util::ReadOutputs::MorphTargetWeights(_) => {
189189
warn!("Morph animation property not yet supported");
@@ -198,10 +198,10 @@ async fn load_gltf<'a, 'b>(
198198
if let Some((root_index, path)) = paths.get(&node.index()) {
199199
animation_roots.insert(root_index);
200200
animation_clip.add_curve_to_path(
201-
EntityPath {
201+
bevy_animation::EntityPath {
202202
parts: path.clone(),
203203
},
204-
VariableCurve {
204+
bevy_animation::VariableCurve {
205205
keyframe_timestamps,
206206
keyframes,
207207
},
@@ -481,7 +481,7 @@ async fn load_gltf<'a, 'b>(
481481
if animation_roots.contains(&node.index()) {
482482
world
483483
.entity_mut(*node_index_to_entity_map.get(&node.index()).unwrap())
484-
.insert(AnimationPlayer::default());
484+
.insert(bevy_animation::AnimationPlayer::default());
485485
}
486486
}
487487
}
@@ -539,6 +539,7 @@ fn node_name(node: &Node) -> Name {
539539
Name::new(name)
540540
}
541541

542+
#[cfg(feature = "bevy_animation")]
542543
fn paths_recur(
543544
node: Node,
544545
current_path: &[Name],

0 commit comments

Comments
 (0)