Skip to content

Commit fb61977

Browse files
committed
Revert "Avoid spawning gizmo meshes when no gizmos are being drawn (bevyengine#8180)"
This reverts commit e54057c.
1 parent 09df19b commit fb61977

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

crates/bevy_gizmos/src/gizmos.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub(crate) struct GizmoStorage {
2020
pub list_colors: Vec<ColorItem>,
2121
pub strip_positions: Vec<PositionItem>,
2222
pub strip_colors: Vec<ColorItem>,
23-
pub in_use: bool,
2423
}
2524

2625
/// A [`SystemParam`](bevy_ecs::system::SystemParam) for drawing gizmos.

crates/bevy_gizmos/src/lib.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,42 +151,31 @@ fn update_gizmo_meshes(
151151
) {
152152
let list_mesh = meshes.get_mut(&handles.list).unwrap();
153153

154-
storage.in_use = false;
154+
let positions = mem::take(&mut storage.list_positions);
155+
list_mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);
155156

156-
if !storage.list_positions.is_empty() {
157-
storage.in_use = true;
157+
let colors = mem::take(&mut storage.list_colors);
158+
list_mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, colors);
158159

159-
let positions = mem::take(&mut storage.list_positions);
160-
list_mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);
160+
let strip_mesh = meshes.get_mut(&handles.strip).unwrap();
161161

162-
let colors = mem::take(&mut storage.list_colors);
163-
list_mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, colors);
164-
}
165-
166-
if !storage.strip_positions.is_empty() {
167-
storage.in_use = true;
168-
169-
let strip_mesh = meshes.get_mut(&handles.strip).unwrap();
162+
let positions = mem::take(&mut storage.strip_positions);
163+
strip_mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);
170164

171-
let positions = mem::take(&mut storage.strip_positions);
172-
strip_mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);
173-
174-
let colors = mem::take(&mut storage.strip_colors);
175-
strip_mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, colors);
176-
}
165+
let colors = mem::take(&mut storage.strip_colors);
166+
strip_mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, colors);
177167
}
178168

179169
fn extract_gizmo_data(
180170
mut commands: Commands,
181171
handles: Extract<Res<MeshHandles>>,
182172
config: Extract<Res<GizmoConfig>>,
183-
storage: Extract<Res<GizmoStorage>>,
184173
) {
185174
if config.is_changed() {
186175
commands.insert_resource(**config);
187176
}
188177

189-
if !config.enabled || !storage.in_use {
178+
if !config.enabled {
190179
return;
191180
}
192181

@@ -197,7 +186,7 @@ fn extract_gizmo_data(
197186
GizmoMesh,
198187
#[cfg(feature = "bevy_pbr")]
199188
(
200-
handle.clone_weak(),
189+
handle.clone(),
201190
MeshUniform {
202191
flags: 0,
203192
transform,
@@ -207,7 +196,7 @@ fn extract_gizmo_data(
207196
),
208197
#[cfg(feature = "bevy_sprite")]
209198
(
210-
Mesh2dHandle(handle.clone_weak()),
199+
Mesh2dHandle(handle.clone()),
211200
Mesh2dUniform {
212201
flags: 0,
213202
transform,

0 commit comments

Comments
 (0)