|
entttree 0.1.0
Hierarchical entity management for EnTT
|
A system for maintaining local affine transforms layered on a hierarchy. More...
#include <transform_hierarchy.h>
Public Types | |
| using | xfn = AffineTransform< T, N > |
| using | LT = LocalTransform< HTag, T, N, XTag > |
Public Member Functions | |
| TransformSystem (entt::registry ®, HierarchySystem< HTag > &hierarchy) | |
| TransformSystem (const TransformSystem &)=delete | |
| TransformSystem & | operator= (const TransformSystem &)=delete |
| HierarchySystem< HTag > & | hierarchy () |
| const HierarchySystem< HTag > & | hierarchy () const |
| void | set_transform (entt::entity eid, xfn xf) |
| Set the local (child-to-parent) transform for an entity. | |
| std::optional< xfn > | get_transform (entt::entity eid) const |
Get the local transform for an entity, or std::nullopt if none is set. | |
| std::optional< LT > | remove_transform (entt::entity eid) |
| Remove the local transform for an entity. Returns the old component if it existed. | |
| xfn | object_to_world (entt::entity node) const |
Compute the cumulative transform that positions node in the space of the root. | |
| xfn | xf_between (entt::entity from_node, entt::entity to_node) const |
Compute the transform from from_node's space to to_node's space. | |
| auto | traverse (entt::entity root, SiblingOrder order) const |
Create a traversal which yields TransformedNode<NodeEntry,T,N>. | |
| template<AnyTraversalConcept Traversal, typename GetId > | |
| auto | augment_with_transforms (Traversal &&t, GetId &&get_id) const |
Convert a traversal of Node to a traversal of TransformedNode<Node,T,N>. | |
Public Attributes | |
| entt::sigh< void(entt::entity, xfn)> | on_transform_set |
| Emitted when a transform is first set on an entity. Args: (entity, new_xf). | |
| entt::sigh< void(entt::entity, xfn)> | on_transform_removed |
| Emitted when a transform is removed from an entity. Args: (entity, old_xf). | |
| entt::sigh< void(entt::entity, xfn, xfn)> | on_transform_changed |
| Emitted when an existing transform changes. Args: (entity, old_xf, new_xf). | |
A system for maintaining local affine transforms layered on a hierarchy.
Each entity may optionally have a LocalTransform component representing the transform from the entity's local space to its parent's space. Entities without an explicit transform are assumed to have the identity.
Emits typed signals when transforms are set, changed, or removed.
| HTag | Hierarchy tag type. |
| T | Scalar type (e.g. double). |
| N | Spatial dimension (e.g. 2 or 3). |
| XTag | Optional transform-layer tag. Defaults to HTag. |
Definition at line 30 of file transform_hierarchy.h.
Definition at line 33 of file transform_hierarchy.h.
| using entttree::TransformSystem< HTag, T, N, XTag >::xfn = AffineTransform<T,N> |
Definition at line 32 of file transform_hierarchy.h.
|
inline |
Definition at line 50 of file transform_hierarchy.h.
|
inline |
Convert a traversal of Node to a traversal of TransformedNode<Node,T,N>.
GetId is a callable which takes a Node& and returns the entt::entity of the node, used to look up the LocalTransform component.
The transform for each node is relative to the traversal root.
Definition at line 178 of file transform_hierarchy.h.
References entttree::make_traversal().
Referenced by entttree::TransformSystem< HTag, T, N, XTag >::traverse().
|
inline |
Get the local transform for an entity, or std::nullopt if none is set.
Definition at line 79 of file transform_hierarchy.h.
|
inline |
Definition at line 56 of file transform_hierarchy.h.
|
inline |
Definition at line 57 of file transform_hierarchy.h.
|
inline |
Compute the cumulative transform that positions node in the space of the root.
Definition at line 100 of file transform_hierarchy.h.
References entttree::HierarchySystem< HTag >::parent_of().
|
inline |
Remove the local transform for an entity. Returns the old component if it existed.
Definition at line 86 of file transform_hierarchy.h.
References entttree::TransformSystem< HTag, T, N, XTag >::on_transform_removed.
|
inline |
Set the local (child-to-parent) transform for an entity.
Definition at line 64 of file transform_hierarchy.h.
References entttree::TransformSystem< HTag, T, N, XTag >::on_transform_changed, and entttree::TransformSystem< HTag, T, N, XTag >::on_transform_set.
|
inline |
Create a traversal which yields TransformedNode<NodeEntry,T,N>.
Each node carries a node_to_root transform accumulated from the traversal root. The traversal includes the root itself with identity transform.
Definition at line 161 of file transform_hierarchy.h.
References entttree::TransformSystem< HTag, T, N, XTag >::augment_with_transforms(), and entttree::HierarchySystem< HTag >::traverse().
|
inline |
Compute the transform from from_node's space to to_node's space.
Both nodes must be in the same tree. The transform is computed via their deepest common ancestor.
Definition at line 120 of file transform_hierarchy.h.
References entttree::HierarchySystem< HTag >::path(), and entttree::HierarchySystem< HTag >::size().
| entt::sigh<void(entt::entity, xfn, xfn)> entttree::TransformSystem< HTag, T, N, XTag >::on_transform_changed |
Emitted when an existing transform changes. Args: (entity, old_xf, new_xf).
Definition at line 44 of file transform_hierarchy.h.
Referenced by entttree::TransformSystem< HTag, T, N, XTag >::set_transform().
| entt::sigh<void(entt::entity, xfn)> entttree::TransformSystem< HTag, T, N, XTag >::on_transform_removed |
Emitted when a transform is removed from an entity. Args: (entity, old_xf).
Definition at line 42 of file transform_hierarchy.h.
Referenced by entttree::TransformSystem< HTag, T, N, XTag >::remove_transform().
Emitted when a transform is first set on an entity. Args: (entity, new_xf).
Definition at line 40 of file transform_hierarchy.h.
Referenced by entttree::TransformSystem< HTag, T, N, XTag >::set_transform().