From ded663b9b9eae7eac435ecd581fec115f11ccd9b Mon Sep 17 00:00:00 2001 From: Lucas Franca Date: Fri, 4 Apr 2025 13:35:12 -0300 Subject: [PATCH] Add `PartialEq` and `Hash` reflections for `AnimationNodeIndex` (#18718) # Objective Fixes #18701 ## Solution Add reflection of `PartialEq` and `Hash` to `AnimationNodeIndex` ## Testing Added a new `#[test]` with the minimal reproduction posted on #18701. --- crates/bevy_animation/src/lib.rs | 11 +++++++++++ crates/bevy_reflect/src/impls/petgraph.rs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index b3ecc085c6..f15d21d10d 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -1533,6 +1533,8 @@ impl<'a> Iterator for TriggeredEventsIter<'a> { #[cfg(test)] mod tests { + use bevy_reflect::{DynamicMap, Map}; + use super::*; #[derive(Event, Reflect, Clone)] @@ -1664,4 +1666,13 @@ mod tests { active_animation.update(clip.duration, clip.duration); // 0.3 : 0.0 assert_triggered_events_with(&active_animation, &clip, [0.3, 0.2]); } + + #[test] + fn test_animation_node_index_as_key_of_dynamic_map() { + let mut map = DynamicMap::default(); + map.insert_boxed( + Box::new(AnimationNodeIndex::new(0)), + Box::new(ActiveAnimation::default()), + ); + } } diff --git a/crates/bevy_reflect/src/impls/petgraph.rs b/crates/bevy_reflect/src/impls/petgraph.rs index 1a1f3a34c4..ce2bf77e37 100644 --- a/crates/bevy_reflect/src/impls/petgraph.rs +++ b/crates/bevy_reflect/src/impls/petgraph.rs @@ -3,6 +3,8 @@ use crate::{impl_reflect_opaque, prelude::ReflectDefault, ReflectDeserialize, Re impl_reflect_opaque!(::petgraph::graph::NodeIndex( Clone, Default, + PartialEq, + Hash, Serialize, Deserialize ));