bevy
bevy copied to clipboard
Turn TargetCamera into an Enum
What problem does this solve or what need does it fill?
In the default ui API, if we want to figure out in which camera is the camera being rendered, we have to query an Option<&TargetCamera>, as that component may or may not be in the entity, that could probably be simplified.
What solution would you like?
We can turn the TargetCamera into an enum
enum TargetCamera {
// The camera entity
Camera(Entity),
// Default says that we have to use the Default ui camera
Default
}
And, in addition to that, insert the TargetCamera in all bundles that may require it.
What alternative(s) have you considered?
Another possibility that can simplify the API in this regard is store the Camera entity with something like ComputedCamera
, I think this can help in two ways:
First: We would have something like a "cache" of cameras and not search through entities with this component, as they are already "ready"
Second: This would allow for easy getting of the Camera, as the Default camera would be stored in the ComputedCamera
, so the root entities that don't have TargetCamera
will not have to always look into all the cameras when looking for this (In addition, we would have to track if the default camera has changed)
But, another possibility is always leaving it as it is now.