Skip to content

Commit f9b5b04

Browse files
committed
typed handles for is_valid_handle
1 parent 0b2a55f commit f9b5b04

File tree

6 files changed

+9
-11
lines changed

6 files changed

+9
-11
lines changed

editor/src/scene/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,11 @@ impl GameScene {
475475
}
476476

477477
fn select_object(&mut self, handle: ErasedHandle, engine: &Engine) {
478-
if engine.scenes[self.scene]
479-
.graph
480-
.is_valid_handle(handle.into())
481-
{
478+
let handle = Handle::<Node>::from(handle);
479+
if engine.scenes[self.scene].graph.is_valid_handle(handle) {
482480
self.sender
483481
.do_command(ChangeSelectionCommand::new(Selection::new(
484-
GraphSelection::single_or_empty(handle.into()),
482+
GraphSelection::single_or_empty(handle),
485483
)))
486484
}
487485
}

editor/src/world/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl WorldViewerDataProvider for EditorSceneWrapper<'_> {
122122
}
123123

124124
fn is_valid_handle(&self, node: ErasedHandle) -> bool {
125-
self.scene.graph.is_valid_handle(node.into())
125+
self.scene.graph.is_valid_handle(Handle::<Node>::from(node))
126126
}
127127

128128
fn icon_of(&self, node: ErasedHandle) -> Option<TextureResource> {

fyrox-core/src/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ where
12331233
/// assert_eq!(pool.is_valid_handle(handle), true)
12341234
/// ```
12351235
#[inline]
1236-
pub fn is_valid_handle(&self, handle: Handle<T>) -> bool {
1236+
pub fn is_valid_handle(&self, handle: Handle<impl ObjectOrVariant<T>>) -> bool {
12371237
if let Ok(record) = self.records_get(handle.index) {
12381238
record.payload.is_some() && record.generation == handle.generation
12391239
} else {

fyrox-graph/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ pub trait SceneGraph: 'static {
705705
) -> Result<&mut Self::Node, PoolError>;
706706

707707
/// Checks whether the given node handle is valid or not.
708-
fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool;
708+
fn is_valid_handle(&self, handle: Handle<impl ObjectOrVariant<Self::Node>>) -> bool;
709709

710710
/// Adds a new node to the graph.
711711
fn add_node(&mut self, node: Self::Node) -> Handle<Self::Node>;
@@ -1809,7 +1809,7 @@ mod test {
18091809
self.root = root;
18101810
}
18111811

1812-
fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool {
1812+
fn is_valid_handle(&self, handle: Handle<impl ObjectOrVariant<Self::Node>>) -> bool {
18131813
self.nodes.is_valid_handle(handle)
18141814
}
18151815

fyrox-impl/src/scene/graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ impl SceneGraph for Graph {
19421942
}
19431943

19441944
#[inline]
1945-
fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool {
1945+
fn is_valid_handle(&self, handle: Handle<impl ObjectOrVariant<Self::Node>>) -> bool {
19461946
self.pool.is_valid_handle(handle)
19471947
}
19481948

fyrox-ui/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3546,7 +3546,7 @@ impl SceneGraph for UserInterface {
35463546
}
35473547

35483548
#[inline]
3549-
fn is_valid_handle(&self, handle: Handle<Self::Node>) -> bool {
3549+
fn is_valid_handle(&self, handle: Handle<impl ObjectOrVariant<Self::Node>>) -> bool {
35503550
self.nodes.is_valid_handle(handle)
35513551
}
35523552

0 commit comments

Comments
 (0)