Code Monkey home page Code Monkey logo

Comments (10)

StarArawn avatar StarArawn commented on August 16, 2024

Thanks for the report! I think we likely will want a map.despawn(commands, map_entity); api for this. I can't have tiles be children of chunks for various reasons.

from bevy_ecs_tilemap.

forbjok avatar forbjok commented on August 16, 2024

They don't necessarily need to be children of chunks, do they?
Both chunks and tiles could all just be children of the Map entity itself.

from bevy_ecs_tilemap.

StarArawn avatar StarArawn commented on August 16, 2024

Part of the issue with having tiles be a child of the map entity or the chunk entity is that tiles don't have standard transforms, and bevy currently complains about that. We could give them standard transforms, but then its just a lot of extra data that is not needed and people might assume that changing a tile transform would change where a tile is located which isn't supported and isn't easy to support.

from bevy_ecs_tilemap.

forbjok avatar forbjok commented on August 16, 2024

tiles don't have standard transforms, and bevy currently complains about that

If that's the case, maybe we should suggest fixing it in Bevy. I don't see any reason why entities should be forced to have a Transform in order to be part of a hierarchy. Parent-child relationships are useful for a lot of things not related to positioning, such as in this case, for organizational purposes to make it easier to despawn all sub-entities when despawning the container entity.

from bevy_ecs_tilemap.

StarArawn avatar StarArawn commented on August 16, 2024

tiles don't have standard transforms, and bevy currently complains about that

If that's the case, maybe we should suggest fixing it in Bevy. I don't see any reason why entities should be forced to have a Transform in order to be part of a hierarchy.

Bevy relations RFC would fix this issue. :)

See:
bevyengine/rfcs#18

from bevy_ecs_tilemap.

forbjok avatar forbjok commented on August 16, 2024

tiles don't have standard transforms, and bevy currently complains about that

If that's the case, maybe we should suggest fixing it in Bevy. I don't see any reason why entities should be forced to have a Transform in order to be part of a hierarchy.

Bevy relations RFC would fix this issue. :)

See:
bevyengine/rfcs#18

Yeah, this would probably allow it, assuming you can have the ECS enforce the deletion of certain relation types when their container entity is despawned.
This seems like a much more complex change though, and way overkill if the goal is simply to ensure sub-entities are despawned.

from bevy_ecs_tilemap.

StarArawn avatar StarArawn commented on August 16, 2024

@forbjok I ran some tests with this, and I discovered a performance drop almost in half due to having a parent per child. If I instead have a map_query.despawn_layer(layer_id) would that be acceptable?

from bevy_ecs_tilemap.

forbjok avatar forbjok commented on August 16, 2024

Interesting. I wonder why that would affect performance when tiles don't have transforms that would need to be propagated. Have you looked into why it's affecting performance?

from bevy_ecs_tilemap.

StarArawn avatar StarArawn commented on August 16, 2024

The performance is mainly lost due to how bevy_transform propagates the transform information for parents/children. It always iterates over the children regardless of whether they have transforms or not.

from bevy_ecs_tilemap.

StarArawn avatar StarArawn commented on August 16, 2024

You can now use map_query.depsawn_map to despawn an entire map including tiles. Optionally you can despawn layers with depsawn_layer or tiles with: despawn_layer_tiles.

from bevy_ecs_tilemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.