@@ -151,31 +151,42 @@ fn update_gizmo_meshes(
151
151
) {
152
152
let list_mesh = meshes. get_mut ( & handles. list ) . unwrap ( ) ;
153
153
154
- let positions = mem:: take ( & mut storage. list_positions ) ;
155
- list_mesh. insert_attribute ( Mesh :: ATTRIBUTE_POSITION , positions) ;
154
+ storage. in_use = false ;
156
155
157
- let colors = mem :: take ( & mut storage. list_colors ) ;
158
- list_mesh . insert_attribute ( Mesh :: ATTRIBUTE_COLOR , colors ) ;
156
+ if ! storage. list_positions . is_empty ( ) {
157
+ storage . in_use = true ;
159
158
160
- let strip_mesh = meshes. get_mut ( & handles. strip ) . unwrap ( ) ;
159
+ let positions = mem:: take ( & mut storage. list_positions ) ;
160
+ list_mesh. insert_attribute ( Mesh :: ATTRIBUTE_POSITION , positions) ;
161
161
162
- let positions = mem:: take ( & mut storage. strip_positions ) ;
163
- strip_mesh. insert_attribute ( Mesh :: ATTRIBUTE_POSITION , positions) ;
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 ( ) ;
164
170
165
- let colors = mem:: take ( & mut storage. strip_colors ) ;
166
- strip_mesh. insert_attribute ( Mesh :: ATTRIBUTE_COLOR , colors) ;
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
+ }
167
177
}
168
178
169
179
fn extract_gizmo_data (
170
180
mut commands : Commands ,
171
181
handles : Extract < Res < MeshHandles > > ,
172
182
config : Extract < Res < GizmoConfig > > ,
183
+ storage : Extract < Res < GizmoStorage > > ,
173
184
) {
174
185
if config. is_changed ( ) {
175
186
commands. insert_resource ( * * config) ;
176
187
}
177
188
178
- if !config. enabled {
189
+ if !config. enabled || !storage . in_use {
179
190
return ;
180
191
}
181
192
@@ -186,7 +197,7 @@ fn extract_gizmo_data(
186
197
GizmoMesh ,
187
198
#[ cfg ( feature = "bevy_pbr" ) ]
188
199
(
189
- handle. clone ( ) ,
200
+ handle. clone_weak ( ) ,
190
201
MeshUniform {
191
202
flags : 0 ,
192
203
transform,
@@ -196,7 +207,7 @@ fn extract_gizmo_data(
196
207
) ,
197
208
#[ cfg ( feature = "bevy_sprite" ) ]
198
209
(
199
- Mesh2dHandle ( handle. clone ( ) ) ,
210
+ Mesh2dHandle ( handle. clone_weak ( ) ) ,
200
211
Mesh2dUniform {
201
212
flags : 0 ,
202
213
transform,
0 commit comments