aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2022-02-24 22:04:39 +0100
committerorwell96 <orwell@bleipb.de>2022-02-24 22:04:39 +0100
commit8beacdc5085c0a88e0fe8a1983b5f7f9874183a0 (patch)
tree042554e5a779e63d17e13d64cf54eea21debca4b
parent3cb21a80dc8219136136fb1df8afca154d58f58c (diff)
downloadadvtrains-8beacdc5085c0a88e0fe8a1983b5f7f9874183a0.tar.gz
advtrains-8beacdc5085c0a88e0fe8a1983b5f7f9874183a0.tar.bz2
advtrains-8beacdc5085c0a88e0fe8a1983b5f7f9874183a0.zip
Fix new wagon positioning when wheel positions are asymmetric, and remove leftover train.debug
-rw-r--r--advtrains/wagons.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index d353d53..fe1a0f8 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -427,7 +427,9 @@ function wagon:on_step(dtime)
local pos2 = advtrains.path_get_interpolated(train, index2)
npos = advtrains.path_get(train, atfloor(index)) -- need npos just for node loaded check
-- calculate center of 2 positions and vdir vector
- pos = advtrains.pos_median(pos1, pos2)
+ -- if wheel positions are asymmetric, needs to weight by the difference!
+ local fact = self.wheel_positions[1] / (self.wheel_positions[1]-self.wheel_positions[2])
+ pos = {x=pos1.x-(pos1.x-pos2.x)*fact, y=pos1.y-(pos1.y-pos2.y)*fact, z=pos1.z-(pos1.z-pos2.z)*fact}
if data.wagon_flipped then
vdir = vector.normalize(vector.subtract(pos2, pos1))
else
@@ -520,7 +522,6 @@ function wagon:on_step(dtime)
if data.wagon_flipped then
oyaw = yaw + math.pi
end
- train.debug = "yaw "..yaw.." oyaw "..oyaw.." flip "..(data.wagon_flipped and "yes" or "no")
--FIX: use index of the wagon, not of the train.
local velocity = train.velocity * advtrains.global_slowdown