From c6a01f42081bf738dcde1e94a5afee1bebf78380 Mon Sep 17 00:00:00 2001 From: TheRawMeatball Date: Tue, 20 Feb 2024 14:28:07 +0300 Subject: [PATCH] fix clippy + embedded_asset macro failing on crates.io --- Cargo.toml | 2 +- examples/nbody.rs | 2 +- examples/perspective.rs | 2 +- src/lib.rs | 14 +++++++++----- src/polyline.rs | 3 +-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8ac3fa6..b3e0074 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "bevy_polyline" -version = "0.8.0" +version = "0.8.1" description = "Polyline Rendering for Bevy" license = "MIT OR Apache-2.0" repository = "https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline" diff --git a/examples/nbody.rs b/examples/nbody.rs index 8d1d89d..0f2e198 100644 --- a/examples/nbody.rs +++ b/examples/nbody.rs @@ -30,7 +30,7 @@ fn main() { Update, ((nbody_system, update_trails).chain(), rotator_system), ) - .add_plugins(FrameTimeDiagnosticsPlugin::default()) + .add_plugins(FrameTimeDiagnosticsPlugin) .add_plugins(LogDiagnosticsPlugin::default()) .run(); } diff --git a/examples/perspective.rs b/examples/perspective.rs index 0cb1b8d..3fc4509 100644 --- a/examples/perspective.rs +++ b/examples/perspective.rs @@ -73,7 +73,7 @@ fn toggle_perspective( mut polyline_materials: ResMut>, keyboard_input: Res>, ) { - for (_, mut mat) in polyline_materials.iter_mut() { + for (_, mat) in polyline_materials.iter_mut() { if keyboard_input.just_pressed(KeyCode::X) { mat.perspective = !mat.perspective; } diff --git a/src/lib.rs b/src/lib.rs index 16619fe..932217d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] -use bevy::{asset::embedded_asset, prelude::*}; +use bevy::{asset::load_internal_asset, prelude::*}; use material::PolylineMaterialPlugin; use polyline::{PolylineBasePlugin, PolylineRenderPlugin}; @@ -15,12 +15,16 @@ pub mod prelude { } pub struct PolylinePlugin; +pub const SHADER_HANDLE: Handle = Handle::weak_from_u128(12823766040132746065); + impl Plugin for PolylinePlugin { fn build(&self, app: &mut bevy::prelude::App) { - #[cfg(target_family = "windows")] - embedded_asset!(app, "src\\", "shaders\\polyline.wgsl"); - #[cfg(not(target_family = "windows"))] - embedded_asset!(app, "src/", "shaders/polyline.wgsl"); + load_internal_asset!( + app, + SHADER_HANDLE, + "shaders/polyline.wgsl", + Shader::from_wgsl + ); app.add_plugins(( PolylineBasePlugin, diff --git a/src/polyline.rs b/src/polyline.rs index 5d886ef..71520bb 100644 --- a/src/polyline.rs +++ b/src/polyline.rs @@ -190,11 +190,10 @@ impl FromWorld for PolylinePipeline { label: Some("polyline_layout"), }); - let assets = world.resource_mut::(); PolylinePipeline { view_layout, polyline_layout, - shader: assets.load("embedded://bevy_polyline/shaders/polyline.wgsl"), + shader: crate::SHADER_HANDLE, } } }