diff --git a/modifiers/trail/trail.wren b/modifiers/trail/trail.wren index 3ed209d..a81e106 100644 --- a/modifiers/trail/trail.wren +++ b/modifiers/trail/trail.wren @@ -301,15 +301,12 @@ class TrailSystem is ModifierSystem { var step = data.length / data.subdivisions_length - System.print(1 - instance_data.progress_since_last_point / step) - - var point_index = -1 + var point_index = instance_data.points.count - 1 while(true){ - point_index = point_index + 1 - if(point_index >= instance_data.points.count - 1) break + point_index = point_index - 1 + if(point_index < 0) break i = i + 1 - var x = instance_data.points.count - i var p:Point = instance_data.points[point_index] var next:Point = instance_data.points[point_index + 1] @@ -335,7 +332,6 @@ class TrailSystem is ModifierSystem { Math.normalize(up) - //pos_x = to.x //pos_y = to.y //pos_z = to.z @@ -349,9 +345,9 @@ class TrailSystem is ModifierSystem { var offset_x = Math.lerp(-up.x, up.x, t) var offset_y = Math.lerp(-up.y, up.y, t) var offset_z = Math.lerp(-up.z, up.z, t) - positions[x*4*data.subdivisions_width + y*4 + 0] = pos.x + offset_x * data.edge_length * 0.5 - positions[x*4*data.subdivisions_width + y*4 + 1] = pos.y + offset_y * data.edge_length * 0.5 - positions[x*4*data.subdivisions_width + y*4 + 2] = pos.z + offset_z * data.edge_length * 0.5 + positions[i*4*data.subdivisions_width + y*4 + 0] = pos.x + offset_x * data.edge_length * 0.5 + positions[i*4*data.subdivisions_width + y*4 + 1] = pos.y + offset_y * data.edge_length * 0.5 + positions[i*4*data.subdivisions_width + y*4 + 2] = pos.z + offset_z * data.edge_length * 0.5 } }