Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cs50victor committed Jan 26, 2024
1 parent 5842009 commit bd2444a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions crates/bevy_headless/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod plugin;
mod utils;

pub use plugin::{
GpuImageExportSource, ImageExportBundle, ImageExportPlugin, ImageExportSettings,
ImageExportSource, ImageExportSystems, CurrImageContainer
CurrImageContainer, GpuImageExportSource, ImageExportBundle, ImageExportPlugin,
ImageExportSettings, ImageExportSource, ImageExportSystems,
};

pub use utils::{setup_render_target,SceneInfo};
pub use utils::{setup_render_target, SceneInfo};
22 changes: 13 additions & 9 deletions crates/bevy_headless/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ use std::sync::Arc;

use crate::{
node::{ImageExportNode, NODE_NAME},
utils::{CurrImage},
utils::CurrImage,
};
use bevy::{
app::{App, Plugin, PluginGroup, PostUpdate},
asset::{Asset, AssetApp, Handle},
ecs::{
bundle::Bundle, component::Component, entity::Entity, query::{QueryItem, With, Without}, schedule::{apply_deferred, IntoSystemConfigs, IntoSystemSetConfigs, SystemSet}, system::{lifetimeless::SRes, Commands, Local, Query, Res, ResMut, Resource, SystemParamItem}, world::Mut
bundle::Bundle,
component::Component,
entity::Entity,
query::{QueryItem, With, Without},
schedule::{apply_deferred, IntoSystemConfigs, IntoSystemSetConfigs, SystemSet},
system::{
lifetimeless::SRes, Commands, Local, Query, Res, ResMut, Resource, SystemParamItem,
},
},
log::LogPlugin,
reflect::{Reflect, TypeUuid},
Expand Down Expand Up @@ -237,7 +244,6 @@ fn capture_img_bytes<P: Pixel + PixelWithColorType>(
// }else{
// log::info!("Curr Image Resource still doesn't exist");
// }

},
None => {
log::error!("Failed creating image buffer for frame - '{frame_id}'");
Expand Down Expand Up @@ -268,11 +274,11 @@ impl Plugin for ImageExportPlugin {
.disable::<LogPlugin>(),
);

// TODO:
// TODO:
let curr_image_container = CurrImageContainer::default();

app.insert_resource(curr_image_container.clone());

app.configure_sets(
PostUpdate,
(SetupImageExport, SetupImageExportFlush).chain().before(CameraUpdateSystem),
Expand All @@ -293,7 +299,7 @@ impl Plugin for ImageExportPlugin {
);

let render_app = app.sub_app_mut(RenderApp);

render_app.insert_resource(curr_image_container);

render_app.add_systems(
Expand All @@ -305,10 +311,8 @@ impl Plugin for ImageExportPlugin {

graph.add_node(NODE_NAME, ImageExportNode);
graph.add_node_edge(CAMERA_DRIVER, NODE_NAME);


}
}

#[derive(Clone, Default, Resource)]
pub struct CurrImageContainer(pub Arc<Mutex<CurrImage>>);
pub struct CurrImageContainer(pub Arc<Mutex<CurrImage>>);
6 changes: 2 additions & 4 deletions crates/bevy_headless/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ use bevy::{
texture::Image,
},
};
use std::{default, io::Cursor, ops::Deref};
use std::{io::Cursor, ops::Deref};

use base64::{engine::general_purpose, Engine};
use image::{EncodableLayout, ImageBuffer, ImageOutputFormat, Pixel, Rgba, RgbaImage};

use crate::{ImageExportBundle, ImageExportSource};


#[derive(Default,Resource)]
#[derive(Default, Resource)]
pub struct CurrImage {
pub img_buffer: ImageBuffer<Rgba<u8>, Vec<u8>>,
pub frame_id: u64,
Expand Down Expand Up @@ -60,7 +59,6 @@ impl CurrImage {
pub fn to_web_base64(&self) -> anyhow::Result<String> {
base64_browser_img(&self.img_buffer)
}

}

#[derive(Debug, Default, Resource, Event)]
Expand Down
3 changes: 1 addition & 2 deletions examples/new_media/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use server::{receive_message, start_ws};
fn setup_gaussian_cloud(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut gaussian_assets: ResMut<Assets<GaussianCloud>>,
_gaussian_assets: ResMut<Assets<GaussianCloud>>,
mut scene_controller: ResMut<bevy_headless::SceneInfo>,
mut images: ResMut<Assets<Image>>,
export_sources: ResMut<Assets<ImageExportSource>>,
Expand Down Expand Up @@ -107,4 +107,3 @@ fn move_camera(mut camera: Query<&mut Transform, With<Camera>>) {
transform.translation.z += speed;
}
}

0 comments on commit bd2444a

Please sign in to comment.