wde_gizmos/lib.rs
1//! WaterDropEngine's `wde-gizmos` crate renders lightweight debug gizmos (lines/boxes) on top of the main scene.
2//!
3//! WIP.
4
5// //! WaterDropEngine's `wde-gizmos` crate renders lightweight debug gizmos (lines/boxes) on top of
6// //! the main scene. It adds a dedicated render pass, a simple line-list pipeline, and a minimal
7// //! material model for per-gizmo color.
8// //!
9// //! # Architecture
10// //! - **Assets**: [`CubeGizmoMesh`](crate::assets::cube_gizmo::CubeGizmoMesh) builds a line-list cube mesh;
11// //! [`assets::gizmo_material::GizmoMaterialAsset`](crate::assets::gizmo_material::GizmoMaterialAsset) defines a single-color gizmo material with
12// //! a tiny uniform buffer.
13// //! - **SSBO**: `passes::gizmo_ssbo::GizmoSsbo` allocates CPU/GPU buffers for per-instance
14// //! `TransformUniform` data and exposes a storage bind group (set 1).
15// //! - **Pipeline**: `passes::gizmo_pipeline::GizmoRenderPipelineAsset` compiles the WGSL gizmo
16// //! shaders (`gizmo/vert.wgsl`, `gizmo/frag.wgsl`), wiring camera (set 0), transforms (set 1),
17// //! and material (set 2) layouts into a cached render pipeline.
18// //! - **Render pass**: `passes::gizmo_renderpass::GizmoRenderPass` batches gizmos by
19// //! (mesh, material), uploads transforms, and draws after the main scene (pass index 1000).
20// //! - **Plugin wiring**: [`GizmosPlugin`](crate::GizmosPlugin) registers materials, SSBO, pipeline assets, and the
21// //! render pass so gizmos always render last.
22// //!
23// //! # Quickstart (draw a debug box)
24// //! ```rust,no_run
25// //! use bevy::prelude::*;
26// //! use wde_renderer::prelude::*;
27// //! use wde_camera::prelude::*;
28// //! use wde_gizmos::prelude::*;
29// //!
30// //! fn main() {
31// //! App::new()
32// //! .add_plugins(DefaultPlugins)
33// //! .add_plugins(RenderPlugin)
34// //! .add_plugins(CameraPlugin)
35// //! .add_plugins(GizmosPlugin)
36// //! .add_systems(Startup, spawn_gizmo)
37// //! .run();
38// //! }
39// //!
40// //! fn spawn_gizmo(mut commands: Commands, assets: Res<AssetServer>) {
41// //! // Create material and mesh
42// //! let mat: Handle<GizmoMaterialAsset> = assets.add(GizmoMaterialAsset {
43// //! color: [1.0, 0.2, 0.2, 1.0],
44// //! ..Default::default()
45// //! });
46// //! let mesh = assets.add(CubeGizmoMesh::from("gizmo-cube", Vec3::splat(1.0)));
47// //!
48// //! commands.spawn((
49// //! Mesh(mesh),
50// //! GizmoMaterial(mat),
51// //! Transform::from_xyz(0.0, 1.0, 0.0),
52// //! ));
53// //! }
54// //! ```
55// //!
56// //! # Core usage patterns
57// //! - Reuse `CubeGizmoMesh` for AABBs; author custom line meshes by supplying `MeshAsset` with
58// //! `RenderTopology::LineList` indices.
59// //! - Materials are per-entity; a single color uniform feeds all instances in the batch.
60// //! - Gizmos rely on the camera bind group from `wde-camera`; keep an active camera present.
61// //! - SSBO capacity defaults to 100k instances; adjust in code if you stream more gizmos.
62// //!
63// //! # Modules
64// //! - [`assets`]: gizmo mesh helper, color-only material asset + uniform packing.
65// //! - [`passes`]: SSBO creation, pipeline compilation, batching, and render pass submission.
66// //!
67// //! # Examples and further reading
68// //! - To visualize bounds, spawn multiple meshes sharing the same `GizmoMaterialAsset` so they
69// //! batch together.
70// //! - Extend the WGSL in `res/gizmo` to add per-vertex coloring while keeping the same bind
71// //! group layout.
72use bevy::prelude::*;
73
74#[doc(hidden)]
75pub mod prelude {
76 // pub use crate::GizmosPlugin;
77 // pub use crate::assets::{cube_gizmo::CubeGizmoMesh, gizmo_material::{GizmoMaterial, GizmoMaterialAsset}};
78}
79
80// pub mod assets;
81// pub mod passes;
82
83pub struct GizmosPlugin;
84impl Plugin for GizmosPlugin {
85 fn build(&self, _app: &mut App) {
86 // app
87 // .add_plugins(GizmoMaterialPlugin)
88 // .add_plugins(GizmoFeaturesPlugin);
89 }
90}