Skip to content

Commit

Permalink
Reduced unnecessary bevy dependencies in transform-gizmo-bevy
Browse files Browse the repository at this point in the history
  • Loading branch information
urholaukkarinen committed Jun 5, 2024
1 parent b3a182a commit 1c56a6c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 30 deletions.
16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@ enum_dispatch = "0.3.12"
ahash = "0.8.7"
enumset = "1.1.3"
bevy = "0.13"
bevy_math = { version = "0.13", features = ["mint"] }

bevy_app = { version = "0.13", default-features = false }
bevy_core = { version = "0.13", default-features = false }
bevy_core_pipeline = { version = "0.13", default-features = false }
bevy_reflect = { version = "0.13", default-features = false }
bevy_math = { version = "0.13", features = ["mint"], default-features = false }
bevy_render = { version = "0.13", default-features = false }
bevy_input = { version = "0.13", default-features = false }
bevy_asset = { version = "0.13", default-features = false }
bevy_utils = { version = "0.13", default-features = false }
bevy_pbr = { version = "0.13", default-features = false }
bevy_ecs = { version = "0.13", default-features = false }
bevy_log = { version = "0.13", default-features = false }
bevy_window = { version = "0.13", default-features = false }
bevy_transform = { version = "0.13", default-features = false }

[profile.release]
opt-level = "s"
Expand Down
17 changes: 15 additions & 2 deletions crates/transform-gizmo-bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,21 @@ include = [

[dependencies]
transform-gizmo.workspace = true
bevy.workspace = true

bevy_app.workspace = true
bevy_core.workspace = true
bevy_core_pipeline.workspace = true
bevy_reflect.workspace = true
bevy_math.workspace = true
bevy_render.workspace = true
bevy_input.workspace = true
bevy_asset.workspace = true
bevy_utils.workspace = true
bevy_pbr.workspace = true
bevy_ecs.workspace = true
bevy_log.workspace = true
bevy_window.workspace = true
bevy_transform.workspace = true

[lints]
workspace = true
workspace = true
23 changes: 14 additions & 9 deletions crates/transform-gizmo-bevy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@
//!
//! You can either set it up with [`App::insert_resource`] when creating your App, or at any point in a system with [`ResMut<GizmoOptions>`].
use bevy::prelude::*;
use bevy::utils::{HashMap, Uuid};
use bevy::window::PrimaryWindow;
use bevy_math::{DQuat, DVec3};
use bevy_app::prelude::*;
use bevy_asset::{AssetApp, Assets};
use bevy_ecs::prelude::*;
use bevy_input::prelude::*;
use bevy_math::{DQuat, DVec3, Vec2};
use bevy_render::prelude::*;
use bevy_transform::prelude::*;
use bevy_utils::{HashMap, Uuid};
use bevy_window::{PrimaryWindow, Window};

use render::{DrawDataHandles, TransformGizmoRenderPlugin};
use transform_gizmo::config::{
GizmoModeKind, TransformPivotPoint, DEFAULT_SNAP_ANGLE, DEFAULT_SNAP_DISTANCE,
DEFAULT_SNAP_SCALE,
};

pub use transform_gizmo::{
math::{Pos2, Rect},
GizmoConfig, *,
Expand Down Expand Up @@ -384,7 +389,7 @@ fn update_gizmos(
}
if active_camera.is_some() {
// multiple active cameras found, warn and skip
bevy::log::warn!("Only one camera with a GizmoCamera component is supported.");
bevy_log::warn!("Only one camera with a GizmoCamera component is supported.");
return;
}
active_camera = Some(camera);
Expand Down Expand Up @@ -482,7 +487,7 @@ fn update_gizmos(

let gizmo_result = gizmo.update(
gizmo_interaction,
&[transform_gizmo::math::Transform {
&[math::Transform {
translation: target_transform.translation.as_dvec3().into(),
rotation: target_transform.rotation.as_dquat().into(),
scale: target_transform.scale.as_dvec3().into(),
Expand All @@ -496,7 +501,7 @@ fn update_gizmos(

if let Some((_, updated_targets)) = &gizmo_result {
let Some(result_transform) = updated_targets.first() else {
bevy::log::warn!("No transform found in GizmoResult!");
bevy_log::warn!("No transform found in GizmoResult!");
continue;
};

Expand Down Expand Up @@ -533,7 +538,7 @@ fn update_gizmos(

if let Some((_, updated_targets)) = &gizmo_result {
let Some(result_transform) = updated_targets.get(i) else {
bevy::log::warn!("No transform {i} found in GizmoResult!");
bevy_log::warn!("No transform {i} found in GizmoResult!");
continue;
};

Expand Down
40 changes: 22 additions & 18 deletions crates/transform-gizmo-bevy/src/render.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
use bevy::asset::load_internal_asset;
use bevy::core::cast_slice;
use bevy::core_pipeline::core_3d::{Transparent3d, CORE_3D_DEPTH_FORMAT};
use bevy::core_pipeline::prepass::{
use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, Asset, Handle};
use bevy_core::cast_slice;
use bevy_core_pipeline::core_3d::{Transparent3d, CORE_3D_DEPTH_FORMAT};
use bevy_core_pipeline::prepass::{
DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass,
};
use bevy::ecs::query::ROQueryItem;
use bevy::ecs::system::lifetimeless::{Read, SRes};
use bevy::ecs::system::SystemParamItem;
use bevy::pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup};
use bevy::prelude::*;
use bevy::render::mesh::PrimitiveTopology;
use bevy::render::render_asset::{
use bevy_ecs::prelude::*;
use bevy_ecs::query::ROQueryItem;
use bevy_ecs::system::lifetimeless::{Read, SRes};
use bevy_ecs::system::SystemParamItem;
use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup};
use bevy_reflect::TypePath;
use bevy_render::mesh::PrimitiveTopology;
use bevy_render::prelude::*;
use bevy_render::render_asset::{
prepare_assets, PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssetUsages,
RenderAssets,
};
use bevy::render::render_phase::{
use bevy_render::render_phase::{
AddRenderCommand, DrawFunctions, PhaseItem, RenderCommand, RenderCommandResult, RenderPhase,
SetItemPipeline, TrackedRenderPass,
};
use bevy::render::render_resource::{
use bevy_render::render_resource::{
BlendState, Buffer, BufferInitDescriptor, BufferUsages, ColorTargetState, ColorWrites,
CompareFunction, DepthBiasState, DepthStencilState, FragmentState, IndexFormat,
MultisampleState, PipelineCache, PrimitiveState, RenderPipelineDescriptor,
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilState, TextureFormat,
VertexAttribute, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
};
use bevy::render::renderer::RenderDevice;
use bevy::render::texture::BevyDefault;
use bevy::render::view::{ExtractedView, RenderLayers, ViewTarget};
use bevy::render::{Extract, Render, RenderApp, RenderSet};
use bevy::utils::{HashMap, HashSet, Uuid};
use bevy_render::renderer::RenderDevice;
use bevy_render::texture::BevyDefault;
use bevy_render::view::{ExtractedView, RenderLayers, ViewTarget};
use bevy_render::{Extract, Render, RenderApp, RenderSet};
use bevy_utils::{HashMap, HashSet, Uuid};

const GIZMO_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(7414812681337026784);

Expand Down Expand Up @@ -139,6 +142,7 @@ impl RenderAsset for GizmoDrawData {
}

struct DrawTransformGizmo;

impl<P: PhaseItem> RenderCommand<P> for DrawTransformGizmo {
type ViewQuery = ();
type ItemQuery = Read<Handle<GizmoDrawData>>;
Expand Down

0 comments on commit 1c56a6c

Please sign in to comment.