Rust 3D with Fyrox - Highlight selected element


When units are selected in RTS, it has an indicator they are chosen. Sometimes they are brighter; sometimes, they have circles under the feet/wheels.

I decided to add circles since it is much easier to accomplish. In Fyrox, you can't just add a child to a node, it must be there, but it can be invisible.

In the editor, I created a cylinder with a minimal height, no collision detection and a blue rectangle image as a texture. Then I added this circle to a node which needed it with the name "SelectIndicator".

Now when I click on a node and find it Rigid Body (here you can learn how) I can scan children and find Indicator by name.

If I want to modify the graph in place, I need to make Engine mutable, make the graph mutable and split the code a little bit. I can't borrow parent and select_indicator mutable simultaneously.

So I need to wrap "looking for correct handle" in scope and modify it outside this scope when I find it.

// code omitted
let visibility_handle = parent
    .find(|handle| {
	if handle.is_none() {
	} else {
	    graph[**handle].is_mesh() &&
	        graph[**handle].name() == "SelectIndicator"
if let Some(handle) = visibility_handle {
    let node = &mut graph[handle];
    let node_mesh = node.as_mesh_mut();
    let visibility = node_mesh.visibility();