wip: prep for interpolation
This commit is contained in:
parent
dd7255cf98
commit
f687405dbb
1 changed files with 32 additions and 6 deletions
|
|
@ -307,15 +307,41 @@ class TrailSystem is ModifierSystem {
|
|||
if(point_index >= instance_data.points.count) break
|
||||
i = i + 1
|
||||
var p:Point = instance_data.points[point_index]
|
||||
|
||||
|
||||
var to = p.pos
|
||||
var to_up = p.up
|
||||
|
||||
var from = to
|
||||
var from_up = to_up
|
||||
|
||||
var t = instance_data.progress_since_last_point / step
|
||||
var pos_x = Math.lerp(from.x, to.x, t)
|
||||
var pos_y = Math.lerp(from.y, to.y, t)
|
||||
var pos_z = Math.lerp(from.z, to.z, t)
|
||||
|
||||
var up_x = Math.lerp(from_up.x, to_up.x, t)
|
||||
var up_y = Math.lerp(from_up.y, to_up.y, t)
|
||||
var up_z = Math.lerp(from_up.z, to_up.z, t)
|
||||
|
||||
|
||||
pos_x = to.x
|
||||
pos_y = to.y
|
||||
pos_z = to.z
|
||||
|
||||
up_x = to_up.x
|
||||
up_y = to_up.y
|
||||
up_z = to_up.z
|
||||
|
||||
var x = instance_data.points.count + 1 - i
|
||||
for(y in 0...data.subdivisions_width){
|
||||
var t = y / (data.subdivisions_width-1)
|
||||
var offset_x = Math.lerp(-p.up.x, p.up.x, t)
|
||||
var offset_y = Math.lerp(-p.up.y, p.up.y, t)
|
||||
var offset_z = Math.lerp(-p.up.z, p.up.z, t)
|
||||
positions[x*4*data.subdivisions_width + y*4 + 0] = p.pos.x + offset_x * data.edge_length * 0.5
|
||||
positions[x*4*data.subdivisions_width + y*4 + 1] = p.pos.y + offset_y * data.edge_length * 0.5
|
||||
positions[x*4*data.subdivisions_width + y*4 + 2] = p.pos.z + offset_z * data.edge_length * 0.5
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue