From f71de888d8c793d0315e0de780c558d5aba2fb4e Mon Sep 17 00:00:00 2001 From: AFKessen <33447178+AFKessen@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:17:12 +0000 Subject: [PATCH] fix line gizmo vertex buffer assignments --- crates/bevy_gizmos/src/lib.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 79bd3b84263d5..9d5f533d713cd 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -597,11 +597,16 @@ impl RenderCommand

for DrawLineGizmo { } let instances = if line_gizmo.strip { - pass.set_vertex_buffer(0, line_gizmo.position_buffer.slice(..)); - pass.set_vertex_buffer(1, line_gizmo.position_buffer.slice(..)); + let item_size = VertexFormat::Float32x3.size(); + let buffer_size = line_gizmo.position_buffer.size() - item_size; - pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..)); - pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(..)); + pass.set_vertex_buffer(0, line_gizmo.position_buffer.slice(..buffer_size)); + pass.set_vertex_buffer(1, line_gizmo.position_buffer.slice(item_size..)); + + let item_size = VertexFormat::Float32x4.size(); + let buffer_size = line_gizmo.color_buffer.size() - item_size; + pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..buffer_size)); + pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(item_size..)); u32::max(line_gizmo.vertex_count, 1) - 1 } else { @@ -699,13 +704,11 @@ fn line_gizmo_vertex_buffer_layouts(strip: bool) -> Vec { position_layout.clone(), { position_layout.attributes[0].shader_location = 1; - position_layout.attributes[0].offset = Float32x3.size(); position_layout }, color_layout.clone(), { color_layout.attributes[0].shader_location = 3; - color_layout.attributes[0].offset = Float32x4.size(); color_layout }, ]