-
-
Notifications
You must be signed in to change notification settings - Fork 581
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
Cascade ordering doesn't seem to be working with a relationship pair
To Reproduce
use flecs_ecs::prelude::*;
#[derive(Component, Debug)]
struct MyData {
data: u32,
}
fn main() {
let mut world = World::new();
let e1 = world.entity_named("e1").set(MyData { data: 1 });
let e3 = world.entity_named("e3").set(MyData { data: 3 });
let e2 = world.entity_named("e2").set(MyData { data: 2 }).child_of_id(e1);
let e4 = world.entity_named("e4").set(MyData { data: 4 }).child_of_id(e3);
e3.child_of_id(e2);
// e1 -> e2 -> e3 -> e4
let q = world
.query::<()>()
.with::<&MyData>()
.with::<&flecs::ChildOf>()
.set_second_name("$loc")
.src()
.cascade()
.desc()
.self_()
.optional()
.set_cached()
.build();
println!("{}", q.to_string());
println!("{}", q.plan());
q.each_iter(|e, index, ()| unsafe {
println!("[{index}] = {} parent {}", e.entity(index).name(), e.get_var_by_name("loc").name());
});
}Actual output
[in] ecs_tests.MyData($this), [in] ?ChildOf($this|self|cascade|desc ChildOf,$loc)
0. [-1, 1] setids
1. [ 0, 2] cachepop
2. [ 1, 4] option
3. [ 2, 4] selfup $[this] (ChildOf, $loc)
4. [ 2, 5] end $[this] (ChildOf, $loc)
5. [ 4, 6] yield
[0] = e1 parent *
[0] = e2 parent e1
[0] = e4 parent e3
[0] = e3 parent e2
Seems like no sorting is done and it matches physical/insertion order.
Expected behavior
I expected to see a descending cascade with this output:
[0] = e4 parent e3
[0] = e3 parent e2
[0] = e2 parent e1
[0] = e1 parent *
Additional context
I want to pull more than one component out of the traversal target. Cascade queries require caching, which only supports a single cascade traversal. Is this not a good alternative? I wanted to do ?OtherData($loc), ?SomethingElse($loc) once I got this working
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request