@@ -73,8 +73,9 @@ pub const MAX_LINES: usize = MAX_POINTS / 2;
73
73
pub const MAX_POINTS : usize = MAX_POINTS_PER_MESH * DEBUG_LINES_MESH_COUNT ;
74
74
75
75
fn spawn_debug_lines_mesh ( meshes : & mut Assets < Mesh > , retain : DebugLinesMesh ) -> impl Bundle {
76
+ let is_immediate = matches ! ( retain, DebugLinesMesh :: Immediate ( _) ) ;
76
77
(
77
- meshes. add ( debug_lines_mesh ( ) ) ,
78
+ meshes. add ( debug_lines_mesh ( is_immediate ) ) ,
78
79
Transform :: default ( ) ,
79
80
GlobalTransform :: default ( ) ,
80
81
Visibility :: default ( ) ,
@@ -111,7 +112,7 @@ fn update_debug_lines_mesh(
111
112
}
112
113
113
114
/// Initialize [`DebugLinesMesh`]'s [`Mesh`].
114
- fn debug_lines_mesh ( ) -> Mesh {
115
+ fn debug_lines_mesh ( is_immediate : bool ) -> Mesh {
115
116
let mut mesh = Mesh :: new ( PrimitiveTopology :: LineList ) ;
116
117
mesh. set_attribute (
117
118
Mesh :: ATTRIBUTE_POSITION ,
@@ -121,7 +122,9 @@ fn debug_lines_mesh() -> Mesh {
121
122
Mesh :: ATTRIBUTE_COLOR ,
122
123
VertexAttributeValues :: Float32x4 ( Vec :: with_capacity ( 256 ) ) ,
123
124
) ;
124
- mesh. set_indices ( Some ( Indices :: U16 ( Vec :: with_capacity ( 256 ) ) ) ) ;
125
+ if !is_immediate {
126
+ mesh. set_indices ( Some ( Indices :: U16 ( Vec :: with_capacity ( 256 ) ) ) ) ;
127
+ }
125
128
mesh
126
129
}
127
130
@@ -194,23 +197,6 @@ impl ImmLinesStorage {
194
197
}
195
198
}
196
199
197
- fn fill_indices ( & self , buffer : & mut Vec < u16 > , mesh : usize ) {
198
- buffer. clear ( ) ;
199
- let start = mesh << 16 ;
200
- let end = ( mesh + 1 ) << 16 ;
201
- let buffer_size = self . positions . len ( ) ;
202
- let indices = if start < buffer_size && buffer_size >= end {
203
- // Because MAX_POINTS_PER_MESH == 2^16
204
- 0xFFFF_u16
205
- } else if start < buffer_size && buffer_size < end {
206
- ( buffer_size - start) as u16
207
- } else {
208
- 0
209
- } ;
210
- // Because MAX_POINTS_PER_MESH == 2^16, this needs to be inclusive
211
- buffer. extend ( 0 ..=indices) ;
212
- }
213
-
214
200
fn mark_expired ( & mut self ) {
215
201
self . positions . clear ( ) ;
216
202
self . colors . clear ( ) ;
@@ -232,9 +218,6 @@ impl ImmLinesStorage {
232
218
233
219
fn fill_attributes ( & self , mesh : & mut Mesh , mesh_index : usize ) {
234
220
use VertexAttributeValues :: { Float32x3 , Float32x4 } ;
235
- if let Some ( Indices :: U16 ( indices) ) = mesh. indices_mut ( ) {
236
- self . fill_indices ( indices, mesh_index) ;
237
- }
238
221
if let Some ( Float32x3 ( vbuffer) ) = mesh. attribute_mut ( Mesh :: ATTRIBUTE_POSITION ) {
239
222
self . fill_vertexes ( vbuffer, mesh_index) ;
240
223
}
@@ -458,7 +441,7 @@ impl SpecializedPipeline for DebugLinePipeline {
458
441
descriptor. fragment . as_mut ( ) . unwrap ( ) . shader = self . shader . clone_weak ( ) ;
459
442
descriptor. primitive . topology = PrimitiveTopology :: LineList ;
460
443
descriptor. primitive . cull_mode = None ;
461
- // TODO: set this to None to remove depth check
444
+ // TODO: set this to a large value to remove depth check
462
445
descriptor. depth_stencil . as_mut ( ) . unwrap ( ) . bias . slope_scale = 1.0 ;
463
446
descriptor
464
447
}
0 commit comments