simplify yaw clamping
This commit is contained in:
parent
4bdd8eaa5f
commit
6cce24f04e
18
api.lua
18
api.lua
@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
|
||||
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20230423",
|
||||
version = "20230425",
|
||||
intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||
}
|
||||
@ -383,17 +383,11 @@ function mob_class:set_yaw(yaw, delay)
|
||||
|
||||
delay = mob_smooth_rotate and (delay or 0) or 0
|
||||
|
||||
-- clamp yaw to a 360 range
|
||||
if deg(self.object:get_yaw()) > 360 then
|
||||
self.object:set_yaw(rad(0))
|
||||
elseif deg(self.object:get_yaw()) < 0 then
|
||||
self.object:set_yaw(rad(360))
|
||||
end
|
||||
|
||||
if deg(yaw) > 360 then
|
||||
yaw = yaw % 360
|
||||
elseif deg(yaw) < 0 then
|
||||
yaw = ((360 * 5) - yaw) % 360
|
||||
-- simplified yaw clamp
|
||||
if yaw > 6.283185 then
|
||||
yaw = yaw - 6.283185
|
||||
elseif yaw < 0 then
|
||||
yaw = 6.283185 + yaw
|
||||
end
|
||||
|
||||
if delay == 0 then
|
||||
|
Loading…
x
Reference in New Issue
Block a user