From 3fd2c8d8216cbbaf30f62e14950d1440b70317f8 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 21 Feb 2021 21:30:02 +1030 Subject: [PATCH] Reverse slide draw order so loops and sharp bends look nicer --- scripts/NoteHandler.gd | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index 903077d..2981526 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -197,15 +197,16 @@ func make_slide_trail_mesh(note) -> ArrayMesh: uvs.resize(3*trail_length) colors.resize(3*trail_length) for i in trail_length: + var idx = (trail_length-i-1)*3 # We want the earliest ones to be drawn last so that loops/sharp bends will have the first pass on top var u = GameTheme.UV_ARRAY_SLIDE_ARROW if i%3 else GameTheme.UV_ARRAY_SLIDE_ARROW2 for j in 3: - uvs[i*3+j] = u[j] - colors[i*3+j] = Color(color.r, color.g, color.b, (1.0+float(i))/float(trail_length)) + uvs[idx+j] = u[j] + colors[idx+j] = Color(color.r, color.g, color.b, (1.0+float(i))/float(trail_length)) var angle : float = angles[i] var offset : Vector2 = positions[i] * GameTheme.receptor_ring_radius - vertices[i*3] = offset - vertices[i*3+1] = offset + polar2cartesian(size, angle+PI*0.75) - vertices[i*3+2] = offset + polar2cartesian(size, angle-PI*0.75) + vertices[idx] = offset + vertices[idx+1] = offset + polar2cartesian(size, angle+PI*0.75) + vertices[idx+2] = offset + polar2cartesian(size, angle-PI*0.75) arrays[Mesh.ARRAY_VERTEX] = vertices arrays[Mesh.ARRAY_TEX_UV] = uvs