Skip to content

Commit

Permalink
Always use trace since Bevy already enables it for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Dec 7, 2024
1 parent a161aab commit ffcbe8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
10 changes: 1 addition & 9 deletions examples/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((
Camera3d::default(),
AtmosphereCamera::default(),
Spectator,
));
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
}

// Change the resolution when the user presses a number key
Expand All @@ -30,8 +26,6 @@ fn change_resolution(
keys: Res<ButtonInput<KeyCode>>,
) {
if keys.just_pressed(KeyCode::Space) {
#[cfg(feature = "bevy/trace")]
// enabling "bevy/trace" (via "bevy/trace_chrome" or "bevy/trace_tracy") allows you to debug bevy_atmosphere
let _change_dithering_executed_span =
info_span!("executed", name = "settings::change_dithering").entered();
if let Some(mut settings) = settings {
Expand Down Expand Up @@ -69,8 +63,6 @@ fn change_resolution(

// A separate `change` fn makes it easier to debug in tracy.
fn change(mut commands: Commands, settings: Option<ResMut<AtmosphereSettings>>, resolution: u32) {
#[cfg(feature = "bevy/trace")]
// enabling "bevy/trace" (via "bevy/trace_chrome" or "bevy/trace_tracy") allows you to debug bevy_atmosphere
let _change_resolution_executed_span =
info_span!("executed", name = "settings::change_resolution").entered();
if let Some(mut settings) = settings {
Expand Down
29 changes: 10 additions & 19 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ fn atmosphere_settings_changed(
) {
if let Some(settings) = settings {
if settings.is_changed() {
#[cfg(feature = "bevy/trace")]
let _atmosphere_settings_changed_executed_span = info_span!(
"executed",
name = "bevy_atmosphere::pipeline::atmosphere_settings_changed"
Expand All @@ -186,14 +185,12 @@ fn atmosphere_settings_changed(
skybox_material.dithering = settings.dithering;
}
atmosphere_image.array_view = None; // drop the previous texture view
#[cfg(feature = "bevy/trace")]
trace!("Resized image to {:?}", size);
}
}
*settings_existed = true;
} else {
if *settings_existed {
#[cfg(feature = "bevy/trace")]
let _atmosphere_settings_changed_executed_span = info_span!(
"executed",
name = "bevy_atmosphere::pipeline::atmosphere_settings_changed"
Expand All @@ -212,7 +209,6 @@ fn atmosphere_settings_changed(
image.resize(size);
let _ = material_assets.get_mut(&material.0); // `get_mut` tells the material to update
atmosphere_image.array_view = None; // drop the previous texture view
#[cfg(feature = "bevy/trace")]
trace!("Resized image to {:?}", size);
}
}
Expand Down Expand Up @@ -330,7 +326,6 @@ fn prepare_atmosphere_resources(
let mut update = || update_events.send(AtmosphereUpdateEvent);

if atmosphere_image.array_view.is_none() {
#[cfg(feature = "bevy/trace")]
let _prepare_atmosphere_assets_executed_span = info_span!(
"executed",
name = "bevy_atmosphere::pipeline::prepare_atmosphere_assets"
Expand All @@ -340,21 +335,17 @@ fn prepare_atmosphere_resources(
let view = texture.create_view(&ATMOSPHERE_ARRAY_TEXTURE_VIEW_DESCRIPTOR);
atmosphere_image.array_view = Some(view);
update();
#[cfg(feature = "bevy/trace")]
{
if let Some(image) = gpu_images.get(&atmosphere_image.handle) {
trace!(
"Created new 2D array texture view from atmosphere texture of size {:?}",
image.size
);
} else {
trace!(
"Failed to find gpu_image for {:?}",
&atmosphere_image.handle
);
}
if let Some(image) = gpu_images.get(&atmosphere_image.handle) {
trace!(
"Created new 2D array texture view from atmosphere texture of size {:?}",
image.size
);
} else {
trace!(
"Failed to find gpu_image for {:?}",
&atmosphere_image.handle
);
}

}

if atmosphere.is_changed() {
Expand Down
3 changes: 0 additions & 3 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ fn atmosphere_insert(
atmosphere_cameras: Query<(Entity, &Projection, &AtmosphereCamera), Added<AtmosphereCamera>>,
) {
for (camera, projection, atmosphere_camera) in &atmosphere_cameras {
#[cfg(feature = "bevy/trace")]
trace!("Adding skybox to camera entity (ID:{:?})", camera);
commands
.entity(camera)
Expand Down Expand Up @@ -138,7 +137,6 @@ fn atmosphere_remove(
mut atmosphere_cameras: RemovedComponents<AtmosphereCamera>,
) {
for camera in &mut atmosphere_cameras.read() {
#[cfg(feature = "bevy/trace")]
trace!("Removing skybox from camera entity (ID:{:?})", camera);
let Ok(children) = parents.get(camera) else {
error!("Failed to get skybox children entities from camera entity.");
Expand All @@ -147,7 +145,6 @@ fn atmosphere_remove(

for child in children {
let Ok(skybox_entity) = atmosphere_skyboxes.get(*child) else {
#[cfg(feature = "bevy/trace")]
trace!("Child wasn't found in skybox entities.");
continue;
};
Expand Down

0 comments on commit ffcbe8d

Please sign in to comment.