mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Inline dir_to_pitch() and use correct formula for pitch
This commit is contained in:
parent
6abb3a2d36
commit
ca8570e639
1 changed files with 1 additions and 6 deletions
|
@ -7,11 +7,6 @@ local YAW_OFFSET = -math.pi/2
|
||||||
local GRAVITY = tonumber(minetest.settings:get("movement_gravity"))
|
local GRAVITY = tonumber(minetest.settings:get("movement_gravity"))
|
||||||
local enable_pvp = minetest.settings:get_bool("enable_pvp")
|
local enable_pvp = minetest.settings:get_bool("enable_pvp")
|
||||||
|
|
||||||
local function dir_to_pitch(dir)
|
|
||||||
local xz = math.abs(dir.x) + math.abs(dir.z)
|
|
||||||
return -math.atan2(-dir.y, xz)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mod.projectile_physics(obj, entity_def, v, a)
|
function mod.projectile_physics(obj, entity_def, v, a)
|
||||||
local le = obj:get_luaentity()
|
local le = obj:get_luaentity()
|
||||||
local entity_def = minetest.registered_entities[le.name]
|
local entity_def = minetest.registered_entities[le.name]
|
||||||
|
@ -54,7 +49,7 @@ function mod.projectile_physics(obj, entity_def, v, a)
|
||||||
-- Update projectile yaw to match velocity direction
|
-- Update projectile yaw to match velocity direction
|
||||||
if v and le and not le._stuck then
|
if v and le and not le._stuck then
|
||||||
local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET
|
local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET
|
||||||
local pitch = dir_to_pitch(v)
|
local pitch = math.asin(vector.normalize(dir).y)
|
||||||
obj:set_rotation(vector.new(0,yaw,pitch))
|
obj:set_rotation(vector.new(0,yaw,pitch))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue