Migrate fog volumes to required components (#15568)

# Objective

Another part of the migration to required components: fog volumes!

## Solution

Deprecate `FogVolumeBundle` and make `FogVolume` require `Transform` and
`Visibility`, as per the [chosen
proposal](https://hackmd.io/@bevy/required_components/%2FcO7JPSAQR5G0J_j5wNwtOQ).

---

## Migration Guide

Replace all insertions of `FogVolumeBundle` with the `Visibility`
component. The other components required by it will now be inserted
automatically.
This commit is contained in:
Joona Aalto 2024-10-01 22:51:22 +03:00 committed by GitHub
parent 40e88dceff
commit 0fe17b8b30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -29,6 +29,8 @@
//! //!
//! [Henyey-Greenstein phase function]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction //! [Henyey-Greenstein phase function]: https://www.pbr-book.org/4ed/Volume_Scattering/Phase_Functions#TheHenyeyndashGreensteinPhaseFunction
#![expect(deprecated)]
use bevy_app::{App, Plugin}; use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, Assets, Handle}; use bevy_asset::{load_internal_asset, Assets, Handle};
use bevy_color::Color; use bevy_color::Color;
@ -121,6 +123,10 @@ pub type VolumetricFogSettings = VolumetricFog;
/// A convenient [`Bundle`] that contains all components necessary to generate a /// A convenient [`Bundle`] that contains all components necessary to generate a
/// fog volume. /// fog volume.
#[derive(Bundle, Clone, Debug, Default)] #[derive(Bundle, Clone, Debug, Default)]
#[deprecated(
since = "0.15.0",
note = "Use the `FogVolume` component instead. Inserting it will now also insert the other components required by it automatically."
)]
pub struct FogVolumeBundle { pub struct FogVolumeBundle {
/// The actual fog volume. /// The actual fog volume.
pub fog_volume: FogVolume, pub fog_volume: FogVolume,
@ -139,6 +145,7 @@ pub struct FogVolumeBundle {
#[derive(Clone, Component, Debug, Reflect)] #[derive(Clone, Component, Debug, Reflect)]
#[reflect(Component, Default, Debug)] #[reflect(Component, Default, Debug)]
#[require(Transform, Visibility)]
pub struct FogVolume { pub struct FogVolume {
/// The color of the fog. /// The color of the fog.
/// ///

View File

@ -4,7 +4,7 @@ use bevy::{
color::palettes::css::RED, color::palettes::css::RED,
core_pipeline::{bloom::Bloom, tonemapping::Tonemapping, Skybox}, core_pipeline::{bloom::Bloom, tonemapping::Tonemapping, Skybox},
math::vec3, math::vec3,
pbr::{FogVolumeBundle, VolumetricFog, VolumetricLight}, pbr::{FogVolume, VolumetricFog, VolumetricLight},
prelude::*, prelude::*,
}; };
@ -122,10 +122,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
)); ));
// Add the fog volume. // Add the fog volume.
commands.spawn(FogVolumeBundle { commands.spawn((
transform: Transform::from_scale(Vec3::splat(35.0)), FogVolume::default(),
..default() Transform::from_scale(Vec3::splat(35.0)),
}); ));
// Add the help text. // Add the help text.
commands.spawn( commands.spawn(