Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for render layers on tilemaps #244

Merged
merged 1 commit into from
Sep 4, 2022

Conversation

Piefayth
Copy link
Contributor

@Piefayth Piefayth commented Sep 1, 2022

Context:

Given two cameras with bevy's builtin RenderLayer component:

    commands
        .spawn_bundle(Camera2dBundle::default())
        .insert(RenderLayers::layer(1));

    commands
        .spawn_bundle(Camera2dBundle {
            camera: Camera {
                priority: 1,
                ..Default::default()
            },
            ..Default::default()
        })
        .insert(RenderLayers::layer(2));

And a tilemap set to one of those render layers:

    commands
        .entity(tilemap_entity)
        .insert_bundle(TilemapBundle { /* ... */ })
        .insert(RenderLayers::layer(2))

The tilemap should render on ONLY the specified camera, but it will render on both. PR is to correct this behavior.

Impl:

Existing logic respects the value of ComputedVisibility for a visibility check, but my understanding is that ComputedVisibility is based on the entity's visibility to any Camera. Each camera maintains a VisibleEntities component, containing a list of entities visible to that particular camera. The change is to skip queuing chunks of tilemaps that are not visible to the iterated view.

Let me know if you think there is a more sensible or complete way to do this. Or if it is already addressed somewhere else that I've overlooked 😄

@alice-i-cecile alice-i-cecile added the enhancement New feature or request label Sep 3, 2022
@StarArawn StarArawn merged commit 291ae98 into StarArawn:main Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants