bevyengine / bevy Public
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
use marker components for cameras instead of name strings #3635
base: main
Are you sure you want to change the base?
use marker components for cameras instead of name strings #3635
Conversation
| .get_or_spawn(entity) | ||
| .insert(RenderPhase::<Transparent2d>::default()); | ||
| } | ||
| for entity in query_camera_2d.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh interesting: will this enable multiple cameras more easily?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the multiple_windows example needs no additional setup for tue second camera anymore.
|
We should think about how to coordinate this with #3412. @HackerFoo, do you have a preference? |
|
|
||
| /// Component bundle for camera entities with perspective projection | ||
| /// | ||
| /// Use this for 3D rendering. | ||
| #[derive(Bundle)] | ||
| pub struct PerspectiveCameraBundle { | ||
| pub struct PerspectiveCameraBundle<M: Component> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this style of API; I've used it before in my games and it's great.
| pub fn new_3d() -> Self { | ||
| Default::default() | ||
| PerspectiveCameraBundle::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit weird to me? Why not just use PerspectiveCameraBundle<Camera3d>::default() instead? And then specialize the default impls based on which generic is passed in.
I'd like #3412 and #3568 to be considered, because they make it useful to run the I also have an idea for specifying the pass order in |
Rebasing one on top of the other once it is merged shouldnt be too hard, the changes are in similar code paths but are mostly unrelated. |
|
This is looking much cleaner. I'm really happy to see this finally get cleaned up. Just a few nits :) |
And here’s another instance of the same question. I’ve seen this 4 times in the past two days. :) @mockersf suggested adding enable/disable for lights while I was doing some other things but it’s not trivial imo because of the question of whether to have something like a ZST for the less likely case (i.e. an empty |
I'm in favor of this: being able to standardize the ecosystem around this pattern is super useful.
So, IMO archetype fragmentation is less important performance-wise than the requirement to constantly check values. I'd prefer a marker component: if we use sparse-set storage it'll be faster to add and remove too. I would be fine with either Overall I think a |
|
How about Similar mechanisms are used for physics (e.g. in Rapier.) |
I suppose this could be done with some other component if needed. |
Problem
RenderPhase<T>componentsCameraPlugin::CAMERA_3dSolution
Camera3d,Camera2dandCameraUi->
Query<&mut Transform, With<Camera3d>>worksPerspectiveCameraBundle::new_3d()andPerspectiveCameraBundle::<Camera3d>::default()contain theCamera3dmarkerOrthographicCameraBundle::new_3d()hasCamera3d,OrthographicCameraBundle::new_2d()hasCamera2dActiveCameras,ExtractedCameraNames-> no custom setup for multiple windows example needed
Open questions
ActiveCameras? What about a componentActiveCamera { is_active: bool }similar toVisibility?The text was updated successfully, but these errors were encountered: