From 6368847a4db75f3e1101811d48a8dac0ca24a87b Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Thu, 6 Mar 2025 21:40:48 +0300 Subject: [PATCH] fixed mapping of inheriable derived handles --- fyrox-graph/src/lib.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fyrox-graph/src/lib.rs b/fyrox-graph/src/lib.rs index 05293d049..72e2fb79c 100644 --- a/fyrox-graph/src/lib.rs +++ b/fyrox-graph/src/lib.rs @@ -371,6 +371,31 @@ where return; } + // Handle derived entities handles. + entity.as_handle_mut(&mut |handle| { + if let Some(handle) = handle { + if do_map + && handle + .query_derived_entity_list() + .contains(&TypeId::of::()) + && handle.reflect_is_some() + && !self.try_map_reflect(handle) + { + Log::warn(format!( + "Failed to remap handle {}:{} of node {}!", + handle.reflect_index(), + handle.reflect_generation(), + node_name + )); + } + mapped = true; + } + }); + + if mapped { + return; + } + entity.as_array_mut(&mut |result| { if let Some(array) = result { // Look in every array item. @@ -665,6 +690,9 @@ pub trait BaseSceneGraph: AbstractSceneGraph { /// Returns actual type id of the node. fn actual_type_id(&self, handle: Handle) -> Option; + /// Returns a list of derived type ids of the node. + fn derived_type_ids(&self, handle: Handle) -> Option>; + /// Returns a handle of the root node of the graph. fn root(&self) -> Handle; @@ -1816,6 +1844,16 @@ mod test { .try_borrow(handle) .map(|n| Downcast::as_any(n.0.deref()).type_id()) } + + fn derived_type_ids(&self, handle: Handle) -> Option> { + self.nodes.try_borrow(handle).map(|n| { + n.0.deref() + .query_derived_entity_list() + .iter() + .cloned() + .collect::>() + }) + } } impl SceneGraph for Graph {