Skip to content

Commit f2f0344

Browse files
atlv24alice-i-cecilemockersf
authored andcommitted
bevy_gizmos_render (bevyengine#21536)
# Objective - make gizmos render agnostic ## Solution - split crate ## Testing - ci and a few examples --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: François Mockers <francois.mockers@vleue.com>
1 parent a9c37cc commit f2f0344

File tree

21 files changed

+944
-688
lines changed

21 files changed

+944
-688
lines changed

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ common_api = [
229229
"bevy_core_pipeline",
230230
"bevy_post_process",
231231
"bevy_sprite_render",
232+
"bevy_gizmos_render",
232233
]
233234

234235
# COLLECTION: Features used to build 3D Bevy apps (does not include a render backend). You generally don't need to worry about this unless you are using a custom renderer.
@@ -249,6 +250,7 @@ common_api = [
249250
"3d_api",
250251
"bevy_render",
251252
"bevy_core_pipeline",
253+
"bevy_gizmos_render",
252254
"bevy_anti_alias",
253255
"bevy_gltf",
254256
"bevy_pbr",
@@ -369,9 +371,12 @@ bevy_light = ["bevy_internal/bevy_light"]
369371
# Provides shaders usable through asset handles.
370372
bevy_shader = ["bevy_internal/bevy_shader"]
371373

372-
# Adds support for rendering gizmos
374+
# Adds support for gizmos
373375
bevy_gizmos = ["bevy_internal/bevy_gizmos"]
374376

377+
# Adds support for rendering gizmos
378+
bevy_gizmos_render = ["bevy_internal/bevy_gizmos_render"]
379+
375380
# Provides a collection of developer tools
376381
bevy_dev_tools = ["bevy_internal/bevy_dev_tools"]
377382

crates/bevy_gizmos/Cargo.toml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,21 @@ repository = "https://github.com/bevyengine/bevy"
88
license = "MIT OR Apache-2.0"
99
keywords = ["bevy"]
1010

11-
[features]
12-
webgl = []
13-
webgpu = []
14-
bevy_render = ["dep:bevy_render", "bevy_core_pipeline"]
15-
1611
[dependencies]
1712
# Bevy
18-
bevy_pbr = { path = "../bevy_pbr", version = "0.18.0-dev", optional = true }
19-
bevy_sprite_render = { path = "../bevy_sprite_render", version = "0.18.0-dev", optional = true }
2013
bevy_app = { path = "../bevy_app", version = "0.18.0-dev" }
2114
bevy_camera = { path = "../bevy_camera", version = "0.18.0-dev" }
22-
bevy_light = { path = "../bevy_light", version = "0.18.0-dev" }
15+
bevy_light = { path = "../bevy_light", version = "0.18.0-dev", optional = true }
2316
bevy_color = { path = "../bevy_color", version = "0.18.0-dev" }
2417
bevy_ecs = { path = "../bevy_ecs", version = "0.18.0-dev" }
25-
bevy_image = { path = "../bevy_image", version = "0.18.0-dev" }
26-
bevy_mesh = { path = "../bevy_mesh", version = "0.18.0-dev" }
2718
bevy_math = { path = "../bevy_math", version = "0.18.0-dev" }
2819
bevy_asset = { path = "../bevy_asset", version = "0.18.0-dev" }
29-
bevy_shader = { path = "../bevy_shader", version = "0.18.0-dev" }
30-
bevy_render = { path = "../bevy_render", version = "0.18.0-dev", optional = true }
3120
bevy_utils = { path = "../bevy_utils", version = "0.18.0-dev" }
3221
bevy_reflect = { path = "../bevy_reflect", version = "0.18.0-dev" }
33-
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.18.0-dev", optional = true }
3422
bevy_transform = { path = "../bevy_transform", version = "0.18.0-dev" }
3523
bevy_gizmos_macros = { path = "macros", version = "0.18.0-dev" }
3624
bevy_time = { path = "../bevy_time", version = "0.18.0-dev" }
3725

38-
# other
39-
bytemuck = "1.0"
40-
tracing = { version = "0.1", default-features = false, features = ["std"] }
41-
4226
[lints]
4327
workspace = true
4428

crates/bevy_gizmos/src/config.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
//! A module for the [`GizmoConfig<T>`] [`Resource`].
22
3+
use bevy_camera::visibility::RenderLayers;
34
pub use bevy_gizmos_macros::GizmoConfigGroup;
45

5-
#[cfg(all(
6-
feature = "bevy_render",
7-
any(feature = "bevy_pbr", feature = "bevy_sprite_render")
8-
))]
96
use {crate::GizmoAsset, bevy_asset::Handle, bevy_ecs::component::Component};
107

118
use bevy_ecs::{reflect::ReflectResource, resource::Resource};
@@ -195,8 +192,7 @@ pub struct GizmoConfig {
195192
/// Describes which rendering layers gizmos will be rendered to.
196193
///
197194
/// Gizmos will only be rendered to cameras with intersecting layers.
198-
#[cfg(feature = "bevy_render")]
199-
pub render_layers: bevy_camera::visibility::RenderLayers,
195+
pub render_layers: RenderLayers,
200196
}
201197

202198
impl Default for GizmoConfig {
@@ -205,7 +201,6 @@ impl Default for GizmoConfig {
205201
enabled: true,
206202
line: Default::default(),
207203
depth_bias: 0.,
208-
#[cfg(feature = "bevy_render")]
209204
render_layers: Default::default(),
210205
}
211206
}
@@ -244,15 +239,23 @@ impl Default for GizmoLineConfig {
244239
}
245240
}
246241

247-
#[cfg(all(
248-
feature = "bevy_render",
249-
any(feature = "bevy_pbr", feature = "bevy_sprite_render")
250-
))]
242+
/// Configuration for gizmo meshes.
251243
#[derive(Component)]
252-
pub(crate) struct GizmoMeshConfig {
244+
pub struct GizmoMeshConfig {
245+
/// Apply perspective to gizmo lines.
246+
///
247+
/// This setting only affects 3D, non-orthographic cameras.
248+
///
249+
/// Defaults to `false`.
253250
pub line_perspective: bool,
251+
/// Determine the style of gizmo lines.
254252
pub line_style: GizmoLineStyle,
253+
/// Describe how lines should join.
255254
pub line_joints: GizmoLineJoint,
256-
pub render_layers: bevy_camera::visibility::RenderLayers,
255+
/// Describes which rendering layers gizmos will be rendered to.
256+
///
257+
/// Gizmos will only be rendered to cameras with intersecting layers.
258+
pub render_layers: RenderLayers,
259+
/// Handle of the gizmo asset.
257260
pub handle: Handle<GizmoAsset>,
258261
}

crates/bevy_gizmos/src/gizmos.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,14 @@ where
290290
Clear: 'static + Send + Sync,
291291
{
292292
pub(crate) enabled: bool,
293-
pub(crate) list_positions: Vec<Vec3>,
294-
pub(crate) list_colors: Vec<LinearRgba>,
295-
pub(crate) strip_positions: Vec<Vec3>,
296-
pub(crate) strip_colors: Vec<LinearRgba>,
293+
/// The positions of line segment endpoints.
294+
pub list_positions: Vec<Vec3>,
295+
/// The colors of line segment endpoints.
296+
pub list_colors: Vec<LinearRgba>,
297+
/// The positions of line strip vertices.
298+
pub strip_positions: Vec<Vec3>,
299+
/// The colors of line strip vertices.
300+
pub strip_colors: Vec<LinearRgba>,
297301
#[reflect(ignore, clone)]
298302
pub(crate) marker: PhantomData<(Config, Clear)>,
299303
}

0 commit comments

Comments
 (0)