#specs #scenegraph #hierarchy

specs-hierarchy

Scene graph type hierarchy abstraction for use with specs

10 releases

0.2.1 Aug 16, 2018
0.2.0 Jul 11, 2018
0.1.0 May 13, 2018
0.1.0-alpha5 Apr 30, 2018

#7 in Game engines

Download history 355/week @ 2018-05-26 547/week @ 2018-06-02 753/week @ 2018-06-09 568/week @ 2018-06-16 222/week @ 2018-06-23 400/week @ 2018-06-30 329/week @ 2018-07-07 424/week @ 2018-07-14 248/week @ 2018-07-21 246/week @ 2018-07-28 461/week @ 2018-08-04 801/week @ 2018-08-11 611/week @ 2018-08-18

1,988 downloads per month
Used in 14 crates (1 directly)

MIT/Apache

28KB
517 lines

specs-hierarchy

Build Status Crates.io Gitter MIT/Apache Docs.rs LoC

Scene graph type hierarchy abstraction for use with specs.

Builds up a Hierarchy resource, by querying a user supplied Parent component. Requires the component to be Tracked.

Will send modification events on an internal EventChannel. Note that Removed events does not mean the Parent component was removed from the component storage, just that the Entity will no longer be considered to be a part of the Hierarchy. This is because the user may wish to either remove only the component, the complete Entity, or something completely different. When an Entity that is a parent gets removed from the hierarchy, the full tree of children below it will also be removed from the hierarchy.

Usage

# Cargo.toml
[dependencies]
specs-hierarchy = "0.2.1"

Example

use specs::prelude::{Component, DenseVecStorage, Entity, FlaggedStorage};
use specs_hierarchy::{Hierarchy, Parent as HParent};

/// Component for defining a parent entity.
///
/// The entity with this component *has* a parent, rather than *is* a parent.
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct Parent {
    /// The parent entity
    pub entity: Entity,
}

impl Component for Parent {
    type Storage = FlaggedStorage<Self, DenseVecStorage<Self>>;
}

impl HParent for Parent {
    fn parent_entity(&self) -> Entity {
        self.entity
    }
}

License

Licensed under either of

at your option.

Contribution

We are a community project that welcomes contribution from anyone. If you're interested in helping out, you can contact us either through GitHub, or via gitter.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~4.5MB
~79K SLoC