Skip to content

Allow transformation trees to be subtrees of non-transformation trees #2402

Open

Description

@ISibboI

What problem does this solve or what need does it fill?

I'd like to organise my game level as a tree, with both non-geometrical entities and geometrical entities. For keeping order and easy unloading, it would be nice to be able to root transformation trees within another tree.

What solution would you like?

If an entity E that has both a GlobalTransform and a Transform has a parent that is missing at least one of those, then the entity should still be a valid root of a transformation tree. That is, the transformation system should update its global transformation in the same way as if E would not have any parent.

Currently, such an entity E is ignored by the transformation system, and is simply rendered at the coordinate root, independent of its transform.

What alternative(s) have you considered?

Have two or more separate trees for each level that are not related in any way by Parent or Child relationships. This is possible, but not very desirable as all the bookkeeping for these trees would need to be implemented by the game developer. Also, it prevents the game developer from representing the logical structure of their entities correctly.

Alternatively, the root of a level could get a default Transform and GlobalTransform. However this seems hacky, as the root is merely a logical dummy node and has no representation in the game world.

Additional context

A game level could for example be structured like this:

  • LevelRoot
    • EventTriggers
    • SoundTriggers
    • WorldSprites (with Transform and GlobalTransform)
    • PlayerSprites (with Transform and GlobalTransform)

Activity

  1. added
    C-FeatureA new feature, making something new possible
    S-Needs-TriageThis issue needs to be labelled
    on Jun 27, 2021
  2. added
    A-ECSEntities, components, systems, and events
    C-UsabilityA targeted quality-of-life change that makes Bevy easier to use
    and removed
    S-Needs-TriageThis issue needs to be labelled
    on Jul 8, 2021
  3. alice-i-cecile commented on Jul 8, 2021

    @alice-i-cecile
    Member

    This is part of the broader question of how we handle relations (#1627). Would you be content with specifying both ChildOf and TransformChildOf for each entity pair if relations were fully implemented?

    Check the RFC for a more complete explanation and example syntax.

  4. added
    S-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be merged
    on Dec 12, 2021
  5. added and removed
    A-ECSEntities, components, systems, and events
    on Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-FeatureA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to useS-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be merged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions