Skip to content

0.4

Compare
Choose a tag to compare
@iiYese iiYese released this 09 Oct 17:02
· 37 commits to main since this release
82d79fb
  • New filters for relations: Abstains, Branch, Leaf.
  • Internals completely reworked for better performance & memory footprint (SmallVecs like bevy_hierarchy now).
  • New Track API to track the last seen item from a query when traversing an edge.
    fn sys(
        mut foos: Query<&mut Foo>,
        tree: Query<(Option<&Bar>, Relations<R>)>,
        roots: Query<Entity, Root<R>>
    ) {
        tree.traverse::<R>(roots.iter()).track(&mut foos).for_each(|foo, bar, _| {
            // ..
        });
    }
  • Derive macro can handle generic types now.
  • Fold breadth API for multi pass algorithms.
    fn sys(
        tree: Query<(Foo, Relations<R>)>,
        roots: Query<Entity, Root<R>>
    ) {
        tree.traverse::<R>(roots.iter())
            .track_self()
            .fold_breadth(|foo, _| /*init*/, |accum, foo, _| /*fold*/)
            .for_each(|accum, parent_foo,  _, child_foo, _| {
                // ..
            });
    }

Breaking:

  • Yeet cursed option hack for relation commands + scope APIs.
  • Completely reworked Scope API to be more declarative. Not all previous functionality will be possible.
    world.spawn(bundle).scope::<ChildOf>(|scope| {
        // x, y, z are implicitly `ChildOf` the last spawned entity 
        scope.add(x)
             .add(y)
             .add(z)
             .scope::<ChildOf>(|scope| {
                  // a, b are implicitly `ChildOf` the last spawned entity (z) 
                 scope.add(a)
                      .add(b);
             });
    });
  • Improved macro hygiene. All property overrides are done through the aery attribute.
    • Available attributes: Counted, Recursive, Total, Poly (previously multi), Symmetric.
    #[derive(Relation)]
    #[aery(Recursive)]
    struct R;
  • Edge direction changes for all operations is now done through the Up modifier. All opereations use hosts by default. To use targets use Up.
    fn sys(foos: Query<(&Foo, Relation<R>)>, starts: Query<Entity, Root<R>>) {
        // descent
        foos.traverse::<R>(starts.iter()).for_each(|foo, _| {
            // ..
        });
        
        // ascent
        foos.traverse::<Up<R>>(starts.iter()).for_each(|foo, _| {
            // ..
        });
    }
  • Traversal are reworked to make sense with new operations. By default traversal visits each node & to get the old 2 arity ancestor descendant permutations use .track_self().
  • Rework how Joins work for consistent defaults + better composability:
    • Join on hosts not targets by default which is more common and makes for a consistent edge default direction. Use Up for targets.
    • Separate Joins from Traversals. Joins must be done through the Relations<R> world query Item. This adds some rightward drift but significantly reduces API complexity & allows joins to work on tracked query items.
    • Split ControlFlow into JCF and TCF.