Compare commits
2 commits
1979caf360
...
f687405dbb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f687405dbb | ||
|
|
dd7255cf98 |
1 changed files with 11 additions and 25 deletions
|
|
@ -200,15 +200,13 @@ class TrailSystem is ModifierSystem {
|
|||
}
|
||||
|
||||
tick(delta) {
|
||||
|
||||
//System.print("positions")
|
||||
record_positions(delta)
|
||||
//System.print("buffers")
|
||||
update_buffers()
|
||||
//System.print("debug")
|
||||
debug_draw()
|
||||
//debug_draw()
|
||||
//System.print("end")
|
||||
|
||||
} //tick
|
||||
|
||||
record_positions(delta: Num){
|
||||
|
|
@ -218,7 +216,7 @@ class TrailSystem is ModifierSystem {
|
|||
var instance_data: TrailData = _instance_data[entity]
|
||||
|
||||
var pos = Transform.get_pos_world(entity)
|
||||
var up = Transform.local_dir_to_world(entity, 0, 1, 0)
|
||||
var up = Transform.local_dir_to_world(entity, 0, data.edge_length * 0.5, 0)
|
||||
var prev_pos = instance_data.previous_pos || pos
|
||||
var prev_up = instance_data.previous_up || up
|
||||
|
||||
|
|
@ -252,8 +250,6 @@ class TrailSystem is ModifierSystem {
|
|||
dist = dist + diff
|
||||
var step = data.length / data.subdivisions_length
|
||||
while(dist > step){
|
||||
//interpolate between points
|
||||
//todo: extrapolate curve instead of linear
|
||||
dist = dist - step
|
||||
var t = 1 - dist / diff
|
||||
var point = Point.new([
|
||||
|
|
@ -266,7 +262,6 @@ class TrailSystem is ModifierSystem {
|
|||
Math.lerp(prev_up.z, up.z, t)
|
||||
])
|
||||
Math.normalize(point.up)
|
||||
//System.print(point.up)
|
||||
if(instance_data.points.count >= data.subdivisions_length - 1) instance_data.points.dequeue()
|
||||
instance_data.points.enqueue(point)
|
||||
}
|
||||
|
|
@ -307,29 +302,19 @@ class TrailSystem is ModifierSystem {
|
|||
var step = data.length / data.subdivisions_length
|
||||
|
||||
var point_index = -1
|
||||
System.print("------------")
|
||||
while(true){
|
||||
point_index = point_index + 1
|
||||
if(point_index >= instance_data.points.count) break
|
||||
i = i + 1
|
||||
var p:Point = instance_data.points[point_index]
|
||||
|
||||
var from: Vec
|
||||
var from_up: Vec
|
||||
if(point_index == 0){
|
||||
from = Transform.get_pos_world(entity)
|
||||
from_up = Transform.local_dir_to_world(entity, 0, 1, 0)
|
||||
} else {
|
||||
var prev: Point = instance_data.points[point_index-1]
|
||||
from = prev.pos
|
||||
from_up = prev.up
|
||||
}
|
||||
|
||||
System.print(from_up)
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -339,6 +324,7 @@ class TrailSystem is ModifierSystem {
|
|||
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
|
||||
|
|
@ -349,10 +335,10 @@ class TrailSystem is ModifierSystem {
|
|||
|
||||
var x = instance_data.points.count + 1 - i
|
||||
for(y in 0...data.subdivisions_width){
|
||||
var t = 1 - 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)
|
||||
var t = y / (data.subdivisions_width-1)
|
||||
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