Skip to content

Migrate cameras to required components#15641

Merged
alice-i-cecile merged 14 commits into
bevyengine:mainfrom
Jondolf:camera-required-components
Oct 5, 2024
Merged

Migrate cameras to required components#15641
alice-i-cecile merged 14 commits into
bevyengine:mainfrom
Jondolf:camera-required-components

Conversation

@Jondolf

@Jondolf Jondolf commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

Objective

Yet another PR for migrating stuff to required components. This time, cameras!

Solution

As per the selected proposal, deprecate Camera2dBundle and Camera3dBundle in favor of Camera2d and Camera3d.

Adding a Camera without Camera2d or Camera3d now logs a warning, as suggested by Cart on Discord. I would personally like cameras to work a bit differently and be split into a few more components, to avoid some footguns and confusing semantics, but that is more controversial, and shouldn't block this core migration.

Testing

I ran a few 2D and 3D examples, and tried cameras with and without render graphs.


Migration Guide

Camera2dBundle and Camera3dBundle have been deprecated in favor of Camera2d and Camera3d. Inserting them will now also insert the other components required by them automatically.

@alice-i-cecile alice-i-cecile added the A-Rendering Drawing game state to the screen label Oct 4, 2024
@alice-i-cecile alice-i-cecile requested a review from cart October 4, 2024 01:29
@alice-i-cecile alice-i-cecile added X-Contentious There are nontrivial implications that should be thought through S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 4, 2024
@alice-i-cecile alice-i-cecile added this to the 0.15 milestone Oct 4, 2024
@Jondolf Jondolf added A-ECS Entities, components, systems, and events X-Contentious There are nontrivial implications that should be thought through and removed X-Contentious There are nontrivial implications that should be thought through labels Oct 4, 2024

@cart cart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment thread examples/picking/mesh_picking.rs Outdated
@Jondolf Jondolf added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 4, 2024
@Jondolf Jondolf added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Oct 4, 2024
@Jondolf Jondolf added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 4, 2024
Comment thread crates/bevy_core_pipeline/src/core_2d/camera_2d.rs
Comment thread crates/bevy_core_pipeline/src/core_3d/camera_3d.rs
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 5, 2024
Merged via the queue into bevyengine:main with commit 25bfa80 Oct 5, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Oct 11, 2024
# Objective

Since #15641, `loading_screen` panics.

```
called `Result::unwrap()` on an `Err` value: MultipleEntities("bevy_ecs::query::state::QueryState<&mut bevy_render::view::visibility::Visibility, bevy_ecs::query::filter::With<loading_screen::LoadingScreen>>")
```

Before that PR, the camera did not have a `Visibility` component. But
`Visibility` is now a required component of `Camera`. So the query
matches multiple entities.

## Solution

Minimal change to make the example behave like it used to.

Plus a tiny drive-by cleanup to remove a redundant unwrap.

## Testing

`cargo run --example loading_screen`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events A-Rendering Drawing game state to the screen S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Contentious There are nontrivial implications that should be thought through

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants