rustgd / specs-hierarchy

A generic scene graph extension for Specs
Apache License 2.0
36 stars 15 forks source link

Problem with all_children_iter #12

Open eldyer opened 5 years ago

eldyer commented 5 years ago

The following test fails:

#[test]
fn test() {
        let mut world = World::new();
        world.register::<Parent>();
        let mut system = HierarchySystem::<Parent>::new();
        System::setup(&mut system, &mut world.res);

        let e3 = world.create_entity().build();
        let e1 = world.create_entity().build();
        let e2 = world.create_entity().build();
        let e0 = world.create_entity().build();

        world.write_storage::<Parent>().insert(e2, Parent {entity: e1 });
        world.write_storage::<Parent>().insert(e1, Parent {entity: e0 });
        world.write_storage::<Parent>().insert(e3, Parent {entity: e2 });

        system.run_now(&mut world.res);
        world.maintain();

        let hierarchy = world.read_resource::<Hierarchy<Parent>>();
        assert!(hierarchy.all_children_iter(e0).eq([e1, e2, e3].iter().cloned()));
    }

However, it works if I change the order of the entity creation into e.g.:

        let e0 = world.create_entity().build();
        let e1 = world.create_entity().build();
        let e2 = world.create_entity().build();
        let e3 = world.create_entity().build();
jaynus commented 5 years ago

Probably related to amethyst/amethyst#1549