From bd23af7542da7e6c9c2b57bbaf235cdb757d6988 Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 26 Feb 2023 14:16:33 -0300 Subject: [PATCH] improved the lift to use wind --- init.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/init.lua b/init.lua index 6f5667b..028a210 100644 --- a/init.lua +++ b/init.lua @@ -235,6 +235,24 @@ end -- max_height: the max ceilling for the airplane -- wingspan: for ground effect calculation function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_pos, lift, max_height, wingspan) + --add wind to the lift calcs + local wind = airutils.get_wind(curr_pos, 2.0) + local accel_wind = vector.subtract(accel, wind) --why? because I need to fake more speed when against the wind to gain lift + local new_velocity = vector.add(vector.multiply(accel_wind, self.dtime),velocity) + --[[local hull_direction = airutils.rot_to_dir(self.object:get_rotation()) + local wind_yaw = minetest.dir_to_yaw(wind) + local orig_vel = vector.dot(velocity,hull_direction) + local new_vel = vector.dot(new_velocity,hull_direction) + if orig_vel > new_vel then + orig_vel = core.colorize('#00ff00', orig_vel) + new_vel = core.colorize('#ff0000', new_vel) + else + orig_vel = core.colorize('#ff0000', orig_vel) + new_vel = core.colorize('#00ff00', new_vel) + end + minetest.chat_send_all("velocity: "..orig_vel.." - new: "..new_vel.." - dir: "..math.deg(wind_yaw) )]]-- + + velocity = new_velocity if longit_speed == nil then longit_speed = 0 end wingspan = wingspan or 10 local ground_effect_extra_lift = airutils.get_ground_effect_lift(self, curr_pos, lift, wingspan)